summaryrefslogtreecommitdiff
path: root/src/buildstream/_yaml.pyx
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-06-28 17:36:33 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:03 +0000
commit7b9a478868ba7a2a1f5b49142496d0eb77322e21 (patch)
treea7e99ac0e5c43ad31be73d6df8489371e1e395ac /src/buildstream/_yaml.pyx
parent06faf60f47d270bc9ce3c6945c31861302882ae9 (diff)
downloadbuildstream-7b9a478868ba7a2a1f5b49142496d0eb77322e21.tar.gz
_yaml: remove node_sanitize
Some call places do not need calls to 'node_sanitize' anymore, therefore removing the call entirely. Other still use it for convenience, but that doesn't seem the right way to do it for consistency. Those places have been replaced by calls to 'Node.strip_node_info()'.
Diffstat (limited to 'src/buildstream/_yaml.pyx')
-rw-r--r--src/buildstream/_yaml.pyx54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index 81c456932..cc5b9128e 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -1212,60 +1212,6 @@ def composite_and_move(MappingNode target, MappingNode source):
del target.value[key]
-# Types we can short-circuit in node_sanitize for speed.
-__SANITIZE_SHORT_CIRCUIT_TYPES = (int, float, str, bool)
-
-
-# node_sanitize()
-#
-# Returns an alphabetically ordered recursive copy
-# of the source node with internal provenance information stripped.
-#
-# Only dicts are ordered, list elements are left in order.
-#
-cpdef object node_sanitize(object node, object dict_type=OrderedDict):
- node_type = type(node)
-
- # If we have an unwrappable node, unwrap it
- # FIXME: we should only ever have Nodes here
- if node_type in [MappingNode, SequenceNode]:
- node = node.value
- node_type = type(node)
-
- if node_type is ScalarNode:
- return node.value
-
- # Short-circuit None which occurs ca. twice per element
- if node is None:
- return node
-
- # Next short-circuit integers, floats, strings, booleans, and tuples
- if node_type in __SANITIZE_SHORT_CIRCUIT_TYPES:
- return node
-
- # Now short-circuit lists.
- elif node_type is list:
- return [node_sanitize(elt, dict_type=dict_type) for elt in node]
-
- # Finally dict, and other Mappings need special handling
- elif node_type is dict:
- result = dict_type()
-
- key_list = [key for key, _ in node.items()]
- for key in sorted(key_list):
- result[key] = node_sanitize(node[key], dict_type=dict_type)
-
- return result
-
- # Sometimes we're handed tuples and we can't be sure what they contain
- # so we have to sanitize into them
- elif node_type is tuple:
- return tuple([node_sanitize(v, dict_type=dict_type) for v in node])
-
- # Everything else just gets returned as-is.
- return node
-
-
# node_validate()
#
# Validate the node so as to ensure the user has not specified