Commit 19bbc4c4 authored by bst-marge-bot's avatar bst-marge-bot
Browse files

Merge branch 'danielsilverstone-ct/reenable-key-in-node' into 'master'

Re-enable `key in somenode` construct after YAML new world order

See merge request !1280
parents a3fe0a4c 5f21693a
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -202,11 +202,11 @@ class Context():
            _yaml.composite(defaults, user_config)

        # Give obsoletion warnings
        if _yaml.node_contains(defaults, 'builddir'):
        if 'builddir' in defaults:
            raise LoadError(LoadErrorReason.INVALID_DATA,
                            "builddir is obsolete, use cachedir")

        if _yaml.node_contains(defaults, 'artifactdir'):
        if 'artifactdir' in defaults:
            raise LoadError(LoadErrorReason.INVALID_DATA,
                            "artifactdir is obsolete")

+1 −1
Original line number Diff line number Diff line
@@ -423,7 +423,7 @@ class _GitSourceBase(Source):
                self.mark_download_url(url, primary=False)

            self.submodule_overrides[path] = url
            if self.node_has_member(submodule, 'checkout'):
            if 'checkout' in submodule:
                checkout = self.node_get_member(submodule, bool, 'checkout')
                self.submodule_checkout_overrides[path] = checkout

+2 −2
Original line number Diff line number Diff line
@@ -421,7 +421,7 @@ class Project():
        else:
            config = self.config

        if not alias or not _yaml.node_contains(config._aliases, alias):
        if not alias or alias not in config._aliases:
            return [None]

        mirror_list = []
@@ -950,7 +950,7 @@ class Project():
            plugins = _yaml.node_get(origin, Mapping, plugin_group, default_value={})
            _yaml.node_set(origin_node, 'plugins', [k for k in _yaml.node_keys(plugins)])
            for group in expected_groups:
                if _yaml.node_contains(origin_node, group):
                if group in origin_node:
                    _yaml.node_del(origin_node, group)

            if _yaml.node_get(origin_node, str, 'origin') == 'local':
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ class ProjectRefs():

        # Ensure we create our toplevel entry point on the fly here
        for node in [self._toplevel_node, self._toplevel_save]:
            if not _yaml.node_contains(node, 'projects'):
            if 'projects' not in node:
                _yaml.node_set(node, 'projects', _yaml.new_empty_node(ref_node=node))

    # lookup_ref()
+4 −16
Original line number Diff line number Diff line
@@ -63,8 +63,10 @@ from ._exceptions import LoadError, LoadErrorReason
#
class Node(namedtuple('Node', ['value', 'file_index', 'line', 'column'])):
    def __contains__(self, what):
        assert False, \
            "BUG: Attempt to do `{} in {}` test".format(what, self)
        # Delegate to the inner value, though this will likely not work
        # very well if the node is a list or string, it's unlikely that
        # code which has access to such nodes would do this.
        return what in self[0]


# File name handling
@@ -772,20 +774,6 @@ def __new_node_from_list(inlist):
    return Node(ret, None, 0, next(_SYNTHETIC_COUNTER))


# node_contains()
#
# Args:
#    node (Node): The mapping node to query the contents of
#    entry (str): The key to look for in the mapping node
#
# Returns:
#    (bool): Whether entry is in the mapping in node.
#
def node_contains(node, entry):
    assert type(node) is Node
    return entry in node[0]


# _is_composite_list
#
# Checks if the given node is a Mapping with array composition
Loading