summaryrefslogtreecommitdiff
path: root/src/buildstream/_context.py
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-06-10 14:20:23 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:02 +0000
commitd14b809cc7b56b7be9e3e40c2e12e8f7245ba680 (patch)
tree3afa82437bb3dcda6b63979c88c20d70f8dfd4f4 /src/buildstream/_context.py
parent38671fb53f4522d046bed94699db8cc344ac2862 (diff)
downloadbuildstream-d14b809cc7b56b7be9e3e40c2e12e8f7245ba680.tar.gz
_yaml: Add 'as_bool()' and 'is_none()' to ScalarNode
- 'as_bool()' casts a ScalarNode into a boolean, understanding both 'True' and 'False' as truthy-falsy values, as per node_get(type=bool) behavior - 'is_none()' allwos checking whether the scalar node contains a 'None' value. Since 'None' cannot be used when working with booleans, we need to have a way of checking for 'None' when we actually need the information of whether the value is unset. - Adapt all call places to use the new API
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r--src/buildstream/_context.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 3c3e32de3..0510bb9a7 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -264,8 +264,7 @@ class Context():
# Load remote execution config getting pull-artifact-files from it
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)
+ self.pull_artifact_files = remote_execution.get_bool('pull-artifact-files', default=True)
# This stops it being used in the remote service set up
_yaml.node_del(remote_execution, 'pull-artifact-files', safe=True)
# Don't pass the remote execution settings if that was the only option
@@ -277,7 +276,7 @@ class Context():
self.remote_execution_specs = SandboxRemote.specs_from_config_node(defaults)
# Load pull build trees configuration
- self.pull_buildtrees = _yaml.node_get(cache, bool, 'pull-buildtrees')
+ self.pull_buildtrees = cache.get_bool('pull-buildtrees')
# Load cache build trees configuration
self.cache_buildtrees = _node_get_option_str(
@@ -291,8 +290,8 @@ class Context():
'debug', 'element-format', 'message-format'
])
self.log_key_length = _yaml.node_get(logging, int, 'key-length')
- self.log_debug = _yaml.node_get(logging, bool, 'debug')
- self.log_verbose = _yaml.node_get(logging, bool, 'verbose')
+ self.log_debug = logging.get_bool('debug')
+ self.log_verbose = logging.get_bool('verbose')
self.log_error_lines = _yaml.node_get(logging, int, 'error-lines')
self.log_message_lines = _yaml.node_get(logging, int, 'message-lines')
self.log_element_format = logging.get_str('element-format')
@@ -427,7 +426,7 @@ class Context():
# so work out if we should be strict, and then cache the result
toplevel = self.get_toplevel_project()
overrides = self.get_overrides(toplevel.name)
- self._strict_build_plan = _yaml.node_get(overrides, bool, 'strict', default_value=True)
+ self._strict_build_plan = overrides.get_bool('strict', default=True)
# If it was set by the CLI, it overrides any config
# Ditto if we've already computed this, then we return the computed