summaryrefslogtreecommitdiff
path: root/buildstream/plugins/sources/zip.py
diff options
context:
space:
mode:
authorThomas Coldrick <othko97@gmail.com>2018-12-20 11:41:05 +0000
committerThomas Coldrick <othko97@gmail.com>2018-12-20 11:41:29 +0000
commitecaf433fa507ce0ec95ddc86e2fe2c7692667b74 (patch)
tree79b4588f4a93724739ab8b4fddcfbeacec26f53b /buildstream/plugins/sources/zip.py
parent9b5e21337660f7085093c8d745497bce90c7f59e (diff)
downloadbuildstream-coldtom/bst-fmt.tar.gz
bst-fmt: Allow greater control over node ordercoldtom/bst-fmt
Allow authors of plugins to utilise the Plugin.keyorder attribute to define an order for the sub-headers in config. Modify `bst fmt` to modify the yaml into that order. Add canonical keyorder for every plugin already in core. In terms of implementation, this adds a custom yaml dumper subclassed from ruamel.yaml's RoundTripDumper, which will dump a dict in the order defined in the keyorder attribute. The Plugin class is given a keyorder attribute, which defines the order in which keys should be dumped. The element and source classes add the common fields used in them, so as to minimise work for plugin authors. Plugin authors should add their custom keys at configure time. This causes some stripping of comments, which seems to be due to a bug in the ruamel.yaml RoundTripDumper, as that also strips the same comments. It also will remove blank spaces, again probably due to limitations in ruamel.
Diffstat (limited to 'buildstream/plugins/sources/zip.py')
-rw-r--r--buildstream/plugins/sources/zip.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/buildstream/plugins/sources/zip.py b/buildstream/plugins/sources/zip.py
index f5fac3a48..27e5fd915 100644
--- a/buildstream/plugins/sources/zip.py
+++ b/buildstream/plugins/sources/zip.py
@@ -75,6 +75,7 @@ class ZipSource(DownloadableFileSource):
self.base_dir = self.node_get_member(node, str, 'base-dir', '*') or None
self.node_validate(node, DownloadableFileSource.COMMON_CONFIG_KEYS + ['base-dir'])
+ self.keyorder += ['base-dir']
def get_unique_key(self):
return super().get_unique_key() + [self.base_dir]