summaryrefslogtreecommitdiff
path: root/src/buildstream/source.py
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-06-09 14:22:35 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:02 +0000
commitfcef3658433f74a2f396ed353bb3534f0001f3d8 (patch)
treea3c74347254332f06583fbdc1c6a6fc4411d21aa /src/buildstream/source.py
parentf6616bc9d51a791aba1e177c61e27f768bebd9cb (diff)
downloadbuildstream-fcef3658433f74a2f396ed353bb3534f0001f3d8.tar.gz
_yaml: add 'get_mapping()' to MappingNode
This allows to get a mapping node from another 'MappingNode', replacing 'node_get(my_mapping, key, type=dict)' Also changes all places where 'node_get' was called like that by the new API.
Diffstat (limited to 'src/buildstream/source.py')
-rw-r--r--src/buildstream/source.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index f8b5d3f88..5015bc18f 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -258,8 +258,7 @@ class Source(Plugin):
All Sources derive from this class, this interface defines how
the core will be interacting with Sources.
"""
- __defaults = {} # The defaults from the project
- __defaults_set = False # Flag, in case there are not defaults at all
+ __defaults = None # The defaults from the project
BST_REQUIRES_PREVIOUS_SOURCES_TRACK = False
"""Whether access to previous sources is required during track
@@ -1267,20 +1266,19 @@ class Source(Plugin):
@classmethod
def __init_defaults(cls, project, meta):
- if not cls.__defaults_set:
+ if cls.__defaults is None:
if meta.first_pass:
sources = project.first_pass_config.source_overrides
else:
sources = project.source_overrides
- cls.__defaults = _yaml.node_get(sources, dict, meta.kind, default_value={})
- cls.__defaults_set = True
+ cls.__defaults = sources.get_mapping(meta.kind, default={})
# This will resolve the final configuration to be handed
# off to source.configure()
#
@classmethod
def __extract_config(cls, meta):
- config = _yaml.node_get(cls.__defaults, dict, 'config', default_value={})
+ config = cls.__defaults.get_mapping('config', default={})
config = _yaml.node_copy(config)
_yaml.composite(config, meta.config)