summaryrefslogtreecommitdiff
path: root/src/buildstream/_context.py
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-06-09 14:22:35 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:02 +0000
commitfcef3658433f74a2f396ed353bb3534f0001f3d8 (patch)
treea3c74347254332f06583fbdc1c6a6fc4411d21aa /src/buildstream/_context.py
parentf6616bc9d51a791aba1e177c61e27f768bebd9cb (diff)
downloadbuildstream-fcef3658433f74a2f396ed353bb3534f0001f3d8.tar.gz
_yaml: add 'get_mapping()' to MappingNode
This allows to get a mapping node from another 'MappingNode', replacing 'node_get(my_mapping, key, type=dict)' Also changes all places where 'node_get' was called like that by the new API.
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r--src/buildstream/_context.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 2bdf5b0b4..5f23552f0 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -242,7 +242,7 @@ class Context():
# Load quota configuration
# We need to find the first existing directory in the path of our
# cachedir - the cachedir may not have been created yet.
- cache = _yaml.node_get(defaults, dict, 'cache')
+ cache = defaults.get_mapping('cache')
_yaml.node_validate(cache, ['quota', 'pull-buildtrees', 'cache-buildtrees'])
self.config_cache_quota_string = _yaml.node_get(cache, str, 'quota')
@@ -262,7 +262,7 @@ class Context():
self.source_cache_specs = SourceCache.specs_from_config_node(defaults)
# Load remote execution config getting pull-artifact-files from it
- remote_execution = _yaml.node_get(defaults, dict, 'remote-execution', default_value=None)
+ remote_execution = defaults.get_mapping('remote-execution', default=None)
if remote_execution:
self.pull_artifact_files = _yaml.node_get(
remote_execution, bool, 'pull-artifact-files', default_value=True)
@@ -284,7 +284,7 @@ class Context():
cache, 'cache-buildtrees', ['always', 'auto', 'never'])
# Load logging config
- logging = _yaml.node_get(defaults, dict, 'logging')
+ logging = defaults.get_mapping('logging')
_yaml.node_validate(logging, [
'key-length', 'verbose',
'error-lines', 'message-lines',
@@ -299,7 +299,7 @@ class Context():
self.log_message_format = _yaml.node_get(logging, str, 'message-format')
# Load scheduler config
- scheduler = _yaml.node_get(defaults, dict, 'scheduler')
+ scheduler = defaults.get_mapping('scheduler')
_yaml.node_validate(scheduler, [
'on-error', 'fetchers', 'builders',
'pushers', 'network-retries'
@@ -312,7 +312,7 @@ class Context():
self.sched_network_retries = _yaml.node_get(scheduler, int, 'network-retries')
# Load per-projects overrides
- self._project_overrides = _yaml.node_get(defaults, dict, 'projects', default_value={})
+ self._project_overrides = defaults.get_mapping('projects', default={})
# Shallow validation of overrides, parts of buildstream which rely
# on the overrides are expected to validate elsewhere.
@@ -412,7 +412,7 @@ class Context():
# (dict): The overrides dictionary for the specified project
#
def get_overrides(self, project_name):
- return _yaml.node_get(self._project_overrides, dict, project_name, default_value={})
+ return self._project_overrides.get_mapping(project_name, default={})
# get_strict():
#