summaryrefslogtreecommitdiff
path: root/src/buildstream/_yaml.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildstream/_yaml.pyx')
-rw-r--r--src/buildstream/_yaml.pyx27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index 6bcf569a9..fbdaac908 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -229,6 +229,15 @@ cdef class MappingNode(Node):
cdef ScalarNode scalar = self.get_scalar(key, default)
return scalar.as_str()
+ cpdef void safe_del(self, str key):
+ try:
+ del self.value[key]
+ except KeyError:
+ pass
+
+ def __delitem__(self, str key):
+ del self.value[key]
+
cdef class SequenceNode(Node):
def __init__(self, list value, int file_index, int line, int column):
@@ -855,24 +864,6 @@ cpdef list node_keys(Node node):
return list(node.value.keys())
-# node_del()
-#
-# A convenience generator for iterating over loaded key/value
-# tuples in a dictionary loaded from project YAML.
-#
-# Args:
-# node (dict): The dictionary node
-# key (str): The key we want to remove
-# safe (bool): Whether to raise a KeyError if unable
-#
-cpdef void node_del(Node node, str key, bint safe=False) except *:
- try:
- del node.value[key]
- except KeyError:
- if not safe:
- raise
-
-
# is_node()
#
# A test method which returns whether or not the passed in value