diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-03-04 16:01:48 +0000 |
---|---|---|
committer | James Ennis <james.ennis@codethink.co.uk> | 2019-03-06 12:16:40 +0000 |
commit | 3b6b538e2210cdf9daca79e04148ab5571b5e2ed (patch) | |
tree | a99f1da860a7bcc116fa19e445d5a64c00bd514a /buildstream/_yaml.py | |
parent | 66edc2818ebcc8a470e6dc9878c15e2cca672e3b (diff) | |
download | buildstream-jennis/compose_backwards.tar.gz |
_include.py: Move yaml related logic to _yaml.pyjennis/compose_backwards
Diffstat (limited to 'buildstream/_yaml.py')
-rw-r--r-- | buildstream/_yaml.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 230094c22..74ed1bbf8 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -903,6 +903,18 @@ def composite(target, source): e.actual_type.__name__)) from e +# Like composite(target, source), but where target overrides source instead. +# +def composite_and_move(target, source): + composite(source, target) + + to_delete = [key for key, _ in node_items(target) if key not in source] + for key, value in source.items(): + target[key] = value + for key in to_delete: + del target[key] + + # SanitizedDict is an OrderedDict that is dumped as unordered mapping. # This provides deterministic output for unordered mappings. # |