summaryrefslogtreecommitdiff
path: root/buildstream/_yaml.py
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-03-04 16:01:48 +0000
committerJames Ennis <james.ennis@codethink.co.uk>2019-03-06 12:16:40 +0000
commit3b6b538e2210cdf9daca79e04148ab5571b5e2ed (patch)
treea99f1da860a7bcc116fa19e445d5a64c00bd514a /buildstream/_yaml.py
parent66edc2818ebcc8a470e6dc9878c15e2cca672e3b (diff)
downloadbuildstream-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.py12
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.
#