diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-06-25 21:14:40 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:03 +0000 |
commit | 1aa0fb1fefa7e86586831a13200a92f6dd9bd3b4 (patch) | |
tree | 8e675fc215ab9f1fcf8851470c95c0e2039f42ee /src/buildstream/_workspaces.py | |
parent | 42d3d8406a15cd5f6f4a7d00e298dba019a50ed6 (diff) | |
download | buildstream-1aa0fb1fefa7e86586831a13200a92f6dd9bd3b4.tar.gz |
_yaml: Remove 'node_items' and add 'MappingNode.items()'
One difference is that 'MappingNode.items()' does not strip the
provenance from scalars and lists, which ends up not affecting the
code much.
Diffstat (limited to 'src/buildstream/_workspaces.py')
-rw-r--r-- | src/buildstream/_workspaces.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py index 3847c7a85..a674ce1f5 100644 --- a/src/buildstream/_workspaces.py +++ b/src/buildstream/_workspaces.py @@ -577,16 +577,14 @@ class Workspaces(): if version == 0: # Pre-versioning format can be of two forms - for element, config in _yaml.node_items(workspaces): - if _yaml.is_node(config): - # Get a dict - config = _yaml.node_sanitize(config, dict_type=dict) + for element, config in workspaces.items(): + config_type = type(config) - if isinstance(config, str): + if config_type is _yaml.ScalarNode: pass - elif isinstance(config, dict): - sources = list(config.items()) + elif config_type is _yaml.MappingNode: + sources = list(config.values()) if len(sources) > 1: detail = "There are multiple workspaces open for '{}'.\n" + \ "This is not supported anymore.\n" + \ @@ -594,21 +592,21 @@ class Workspaces(): raise LoadError(LoadErrorReason.INVALID_DATA, detail.format(element, self._get_filename())) - _yaml.node_set(workspaces, element, sources[0][1]) + _yaml.node_set(workspaces, element, sources[0]) else: raise LoadError(LoadErrorReason.INVALID_DATA, "Workspace config is in unexpected format.") res = { - element: Workspace(self._toplevel_project, path=config) - for element, config in _yaml.node_items(workspaces) + element: Workspace(self._toplevel_project, path=config.as_str()) + for element, config in workspaces.items() } elif 1 <= version <= BST_WORKSPACE_FORMAT_VERSION: workspaces = workspaces.get_mapping("workspaces", default={}) res = {element: self._load_workspace(node) - for element, node in _yaml.node_items(workspaces)} + for element, node in workspaces.items()} else: raise LoadError(LoadErrorReason.INVALID_DATA, |