summaryrefslogtreecommitdiff
path: root/buildstream/_yaml.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildstream/_yaml.py')
-rw-r--r--buildstream/_yaml.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py
index aead2ed84..9823f7ca3 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -385,6 +385,25 @@ def node_get(node, expected_type, key, indices=[], default_value=None):
return value
+# node_items()
+#
+# A convenience generator for iterating over loaded key/value
+# tuples in a dictionary loaded from project YAML.
+#
+# Args:
+# node (dict): The dictionary node
+#
+# Yields:
+# (str): The key name
+# (anything): The value for the key
+#
+def node_items(node):
+ for key, value in node.items():
+ if key == PROVENANCE_KEY:
+ continue
+ yield (key, value)
+
+
# Gives a node a dummy provenance, in case of compositing dictionaries
# where the target is an empty {}
def ensure_provenance(node):