diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-11 18:19:46 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:02 +0000 |
commit | 7298136642010d4e02a607f4275ffe3ad5657a14 (patch) | |
tree | aab93ac4d78c6d7b85ac2b1de89eb11280829b21 /src/buildstream/_options | |
parent | ad5aa05826431b1b34c220f20e93bf6e05b292a0 (diff) | |
download | buildstream-7298136642010d4e02a607f4275ffe3ad5657a14.tar.gz |
_yaml: Introduce 'get_sequence()' and 'sequence_at()'/'mapping_at()'
- Adding 'get_sequence' on MappingNode to access sequences in a mapping
- Adding 'sequence_at' on SequenceNode to access sequences in a sequence
- Adding 'mapping_at' on SequenceNode to access mappings in a sequence
Using "*_at" in sequences allows us to quickly understand if we are
dealing with a sequence or a mapping.
Diffstat (limited to 'src/buildstream/_options')
-rw-r--r-- | src/buildstream/_options/optionenum.py | 2 | ||||
-rw-r--r-- | src/buildstream/_options/optionflags.py | 6 | ||||
-rw-r--r-- | src/buildstream/_options/optionpool.py | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/buildstream/_options/optionenum.py b/src/buildstream/_options/optionenum.py index 04a19395b..f04cecd8b 100644 --- a/src/buildstream/_options/optionenum.py +++ b/src/buildstream/_options/optionenum.py @@ -46,7 +46,7 @@ class OptionEnum(Option): _yaml.node_validate(node, valid_symbols) - self.values = _yaml.node_get(node, list, 'values', default_value=[]) + self.values = node.get_sequence('values', default=[]).as_str_list() if not self.values: raise LoadError(LoadErrorReason.INVALID_DATA, "{}: No values specified for {} option '{}'" diff --git a/src/buildstream/_options/optionflags.py b/src/buildstream/_options/optionflags.py index eba3a8dd5..c9758e403 100644 --- a/src/buildstream/_options/optionflags.py +++ b/src/buildstream/_options/optionflags.py @@ -53,11 +53,11 @@ class OptionFlags(Option): "{}: No values specified for {} option '{}'" .format(_yaml.node_get_provenance(node), self.OPTION_TYPE, self.name)) - self.value = _yaml.node_get(node, list, 'default', default_value=[]) + self.value = node.get_sequence('default', default=[]).as_str_list() self.validate(self.value, _yaml.node_get_provenance(node, 'default')) def load_value(self, node, *, transform=None): - self.value = _yaml.node_get(node, list, self.name) + self.value = node.get_sequence(self.name).as_str_list() if transform: self.value = [transform(x) for x in self.value] self.value = sorted(self.value) @@ -90,4 +90,4 @@ class OptionFlags(Option): def load_valid_values(self, node): # Allow the more descriptive error to raise when no values # exist rather than bailing out here (by specifying default_value) - return _yaml.node_get(node, list, 'values', default_value=[]) + return node.get_sequence('values', default=[]).as_str_list() diff --git a/src/buildstream/_options/optionpool.py b/src/buildstream/_options/optionpool.py index 25b96fa98..9a4a88c36 100644 --- a/src/buildstream/_options/optionpool.py +++ b/src/buildstream/_options/optionpool.py @@ -248,7 +248,7 @@ class OptionPool(): # Return true if a conditional was processed. # def _process_one_node(self, node): - conditions = _yaml.node_get(node, list, '(?)', default_value=None) + conditions = node.get_sequence('(?)', default=None) assertion = node.get_str('(!)', default=None) # Process assersions first, we want to abort on the first encountered |