summaryrefslogtreecommitdiff
path: root/src/buildstream/_yaml.pyx
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-03 12:20:27 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:03 +0000
commitd8466183f77c75bbd7ad27c7cbf5e58189945be1 (patch)
tree3ab6c9fa8f02ce355b0543608fafcd5fa4b5db28 /src/buildstream/_yaml.pyx
parent9e801b5e1c19c46de8b1e88f416e34e180df83e9 (diff)
downloadbuildstream-d8466183f77c75bbd7ad27c7cbf5e58189945be1.tar.gz
_yaml: Create 'from_dict' on Node and remove node creation methods
Using 'Node.from_dict({})' can replace new_empty_node, and the rest is not needed anymore. - Adapt all call sites
Diffstat (limited to 'src/buildstream/_yaml.pyx')
-rw-r--r--src/buildstream/_yaml.pyx26
1 files changed, 5 insertions, 21 deletions
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index d89ba74cb..07209aa1f 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -71,7 +71,11 @@ cdef class Node:
@classmethod
def from_dict(cls, dict value):
- return _new_node_from_dict(value, Node(None, _SYNTHETIC_FILE_INDEX, 0, next_synthetic_counter()))
+ if value:
+ return _new_node_from_dict(value, Node(None, _SYNTHETIC_FILE_INDEX, 0, next_synthetic_counter()))
+ else:
+ # We got an empty dict, we can shortcut
+ return MappingNode({}, _SYNTHETIC_FILE_INDEX, 0, next_synthetic_counter())
cdef bint _walk_find(self, Node target, list path) except *:
raise NotImplementedError()
@@ -1134,26 +1138,6 @@ def new_synthetic_file(str filename, object project=None):
return node
-# new_empty_node()
-#
-# Args:
-# ref_node (Node): Optional node whose provenance should be referenced
-#
-# Returns
-# (Node): A new empty YAML mapping node
-#
-def new_empty_node(Node ref_node=None):
- if ref_node is not None:
- return MappingNode({}, ref_node.file_index, ref_node.line, next_synthetic_counter())
- else:
- return MappingNode({}, _SYNTHETIC_FILE_INDEX, 0, 0)
-
-
-# FIXME: we should never need that
-def new_empty_list_node():
- return SequenceNode([], _SYNTHETIC_FILE_INDEX, 0, 0)
-
-
# new_node_from_dict()
#
# Args: