summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_context.py4
-rw-r--r--buildstream/_project.py4
-rw-r--r--buildstream/_projectrefs.py2
-rw-r--r--buildstream/_yaml.py14
-rw-r--r--buildstream/element.py2
-rw-r--r--buildstream/sandbox/_sandboxremote.py8
6 files changed, 10 insertions, 24 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py
index a7d308a6f..fffeea17e 100644
--- a/buildstream/_context.py
+++ b/buildstream/_context.py
@@ -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")
diff --git a/buildstream/_project.py b/buildstream/_project.py
index c6d0f29fd..843def2ca 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -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_items(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':
diff --git a/buildstream/_projectrefs.py b/buildstream/_projectrefs.py
index b1443ef32..09205a7c3 100644
--- a/buildstream/_projectrefs.py
+++ b/buildstream/_projectrefs.py
@@ -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()
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py
index 647b59c90..856d03158 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -757,20 +757,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
diff --git a/buildstream/element.py b/buildstream/element.py
index 2bb492cb3..5c28b4753 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -753,7 +753,7 @@ class Element(Plugin):
if workspace and old_dep_keys:
dep.__assert_cached()
- if _yaml.node_contains(old_dep_keys, dep.name):
+ if dep.name in old_dep_keys:
key_new = dep._get_cache_key()
key_old = _yaml.node_get(old_dep_keys, str, dep.name)
diff --git a/buildstream/sandbox/_sandboxremote.py b/buildstream/sandbox/_sandboxremote.py
index 14e160dc5..4eaf4ec8a 100644
--- a/buildstream/sandbox/_sandboxremote.py
+++ b/buildstream/sandbox/_sandboxremote.py
@@ -136,8 +136,8 @@ class SandboxRemote(Sandbox):
# Maintain some backwards compatibility with older configs, in which
# 'url' was the only valid key for remote-execution:
- if _yaml.node_contains(remote_config, 'url'):
- if not _yaml.node_contains(remote_config, 'execution-service'):
+ if 'url' in remote_config:
+ if 'execution-service' not in remote_config:
exec_config = _yaml.new_node_from_dict({'url': remote_config['url']})
else:
provenance = _yaml.node_get_provenance(remote_config, key='url')
@@ -157,7 +157,7 @@ class SandboxRemote(Sandbox):
for config_key, config in zip(service_keys, service_configs):
# Either both or none of the TLS client key/cert pair must be specified:
- if _yaml.node_contains(config, 'client-key') != _yaml.node_contains(config, 'client-cert'):
+ if 'client-key' in config != 'client-cert' in config:
provenance = _yaml.node_get_provenance(remote_config, key=config_key)
raise _yaml.LoadError(_yaml.LoadErrorReason.INVALID_DATA,
"{}: TLS client key/cert pair is incomplete. "
@@ -166,7 +166,7 @@ class SandboxRemote(Sandbox):
.format(str(provenance)))
for tls_key in tls_keys:
- if _yaml.node_contains(config, tls_key):
+ if tls_key in config:
_yaml.node_set(config, tls_key, resolve_path(_yaml.node_get(config, str, tls_key)))
return RemoteExecutionSpec(*[_yaml.node_sanitize(conf) for conf in service_configs])