summaryrefslogtreecommitdiff
path: root/src/buildstream/_yaml.pyx
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-06-27 11:18:20 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:03 +0000
commit1d970eef4be03909873ed9fa16748e8248238127 (patch)
treead4f7d0e6bbd5027d87b872ee96094a923205db6 /src/buildstream/_yaml.pyx
parent8bfe8dd6ad49445c900662f304072eb20f0ff606 (diff)
downloadbuildstream-1d970eef4be03909873ed9fa16748e8248238127.tar.gz
_yaml: Remove 'key' from node_find_target
- node_find_target with 'key' is only used once in the codebase. We can remove and simplify this function - Allow 'MappingNode.get_node()' to be called without any 'expected_types'
Diffstat (limited to 'src/buildstream/_yaml.pyx')
-rw-r--r--src/buildstream/_yaml.pyx13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index b2a7f88aa..e0c04b655 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -173,7 +173,7 @@ cdef class MappingNode(Node):
return value
- cpdef Node get_node(self, str key, list allowed_types, bint allow_none = False):
+ cpdef Node get_node(self, str key, list allowed_types = None, bint allow_none = False):
cdef value = self.value.get(key, _sentinel)
if value is _sentinel:
@@ -184,7 +184,7 @@ cdef class MappingNode(Node):
raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: Dictionary did not contain expected key '{}'".format(provenance, key))
- if type(value) not in allowed_types:
+ if allowed_types and type(value) not in allowed_types:
provenance = node_get_provenance(self)
raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: Value of '{}' is not one of the following: {}.".format(
@@ -1339,19 +1339,12 @@ def assert_symbol_name(ProvenanceInformation provenance, str symbol_name, str pu
# Args:
# node (Node): The node at the root of the tree to search
# target (Node): The node you are looking for in that tree
-# key (str): Optional string key within target node
#
# Returns:
# (list): A path from `node` to `target` or None if `target` is not in the subtree
-cpdef list node_find_target(MappingNode node, Node target, str key=None):
- if key is not None:
- target = target.value[key]
-
+cpdef list node_find_target(MappingNode node, Node target):
cdef list path = []
if _walk_find_target(node, path, target):
- if key:
- # Remove key from end of path
- path = path[:-1]
return path
return None