diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-07-10 13:59:12 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:03 +0000 |
commit | 301d40d1a42c056f7c9e8e734b6ce6251378cafb (patch) | |
tree | d3b3f57bf620c54e0796d353ad55f4408c42e2d9 /src/buildstream/_options | |
parent | 53019a61c926787b622b6a5f94f81096b043cf99 (diff) | |
download | buildstream-301d40d1a42c056f7c9e8e734b6ce6251378cafb.tar.gz |
_yaml: Split Node-related parts into 'node.pyx'
This makes the 'Node' API public, and available for use directly for
plugins.
Diffstat (limited to 'src/buildstream/_options')
-rw-r--r-- | src/buildstream/_options/option.py | 4 | ||||
-rw-r--r-- | src/buildstream/_options/optionpool.py | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/buildstream/_options/option.py b/src/buildstream/_options/option.py index ae5d56beb..98090e1b5 100644 --- a/src/buildstream/_options/option.py +++ b/src/buildstream/_options/option.py @@ -17,7 +17,7 @@ # Authors: # Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> -from .. import _yaml +from ..node import assert_symbol_name # Shared symbols for validation purposes @@ -66,7 +66,7 @@ class Option(): # Assert valid symbol name for variable name if self.variable is not None: - _yaml.assert_symbol_name(self.variable, 'variable name', ref_node=node.get_node('variable')) + assert_symbol_name(self.variable, 'variable name', ref_node=node.get_node('variable')) # load_value() # diff --git a/src/buildstream/_options/optionpool.py b/src/buildstream/_options/optionpool.py index 38e9e6769..56adf68f2 100644 --- a/src/buildstream/_options/optionpool.py +++ b/src/buildstream/_options/optionpool.py @@ -20,8 +20,8 @@ import jinja2 -from .. import _yaml from .._exceptions import LoadError, LoadErrorReason +from ..node import MappingNode, SequenceNode, assert_symbol_name from .optionbool import OptionBool from .optionenum import OptionEnum from .optionflags import OptionFlags @@ -68,7 +68,7 @@ class OptionPool(): for option_name, option_definition in options.items(): # Assert that the option name is a valid symbol - _yaml.assert_symbol_name(option_name, "option name", ref_node=option_definition, allow_dashes=False) + assert_symbol_name(option_name, "option name", ref_node=option_definition, allow_dashes=False) opt_type_name = option_definition.get_str('type') try: @@ -186,9 +186,9 @@ class OptionPool(): # for value in node.values(): value_type = type(value) - if value_type is _yaml.MappingNode: + if value_type is MappingNode: self.process_node(value) - elif value_type is _yaml.SequenceNode: + elif value_type is SequenceNode: self._process_list(value) ####################################################### @@ -238,9 +238,9 @@ class OptionPool(): def _process_list(self, values): for value in values: value_type = type(value) - if value_type is _yaml.MappingNode: + if value_type is MappingNode: self.process_node(value) - elif value_type is _yaml.SequenceNode: + elif value_type is SequenceNode: self._process_list(value) # Process a single conditional, resulting in composition @@ -278,7 +278,7 @@ class OptionPool(): provenance = condition.get_provenance() raise LoadError(e.reason, "{}: {}".format(provenance, e)) from e - if type(value) is not _yaml.MappingNode: # pylint: disable=unidiomatic-typecheck + if type(value) is not MappingNode: # pylint: disable=unidiomatic-typecheck provenance = condition.get_provenance() raise LoadError(LoadErrorReason.ILLEGAL_COMPOSITE, "{}: Only values of type 'dict' can be composed.".format(provenance)) |