From 0ce1059bf31f9a4b37de5424d8bde4543976353b Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Wed, 9 Dec 2015 16:49:20 +0000 Subject: Add IMPLEMENTS for the removal of a field in a `troves` section Change-Id: I42fbb8a2f2150cfbc48e07340ecedea76f41639a --- yarns.webapp/900-implementations.yarn | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/yarns.webapp/900-implementations.yarn b/yarns.webapp/900-implementations.yarn index 6e0b380..24dcf51 100644 --- a/yarns.webapp/900-implementations.yarn +++ b/yarns.webapp/900-implementations.yarn @@ -178,6 +178,27 @@ Set a specific field for a `troves` section. yarnlib.dump_json_to_file(obj, filename) ' +Remove a specified field for a `troves` section + + IMPLEMENTS GIVEN (\S+) in (\S+) removes field (\S+) from trove (\S+) + cd "$SRCDIR"/yarns.webapp + python -c ' + import os + import yarnlib + + MATCH_1, MATCH_2, MATCH_3, MATCH_4 = yarnlib.matches() + + filename = os.path.join(yarnlib.DATADIR, MATCH_2, MATCH_1) + obj = yarnlib.load_json_from_file(filename) + + for section in obj: + if section["type"] in ["trove", "troves"]: + if section["trovehost"] == MATCH_4: + del section[MATCH_3] + + yarnlib.dump_json_to_file(obj, filename) + ' + Set the prefixmap for a Trove in a Lorry Controller configuration file. Note that the Trove must already be in the configuration file. -- cgit v1.2.1