summaryrefslogtreecommitdiff
path: root/src/buildstream/_options
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/_options
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/_options')
-rw-r--r--src/buildstream/_options/optionbool.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/buildstream/_options/optionbool.py b/src/buildstream/_options/optionbool.py
index caeff9711..1e5935e48 100644
--- a/src/buildstream/_options/optionbool.py
+++ b/src/buildstream/_options/optionbool.py
@@ -34,13 +34,13 @@ class OptionBool(Option):
super().load(node)
_yaml.node_validate(node, OPTION_SYMBOLS + ['default'])
- self.value = _yaml.node_get(node, bool, 'default')
+ self.value = node.get_bool('default')
def load_value(self, node, *, transform=None):
if transform:
self.set_value(transform(node.get_str(self.name)))
else:
- self.value = _yaml.node_get(node, bool, self.name)
+ self.value = node.get_bool(self.name)
def set_value(self, value):
if value in ('True', 'true'):