summaryrefslogtreecommitdiff
path: root/buildstream/source.py
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-05-16 16:29:48 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-05-17 17:17:55 +0100
commitae96d215aa830b5421b8aa5805e7bbab38b27473 (patch)
tree89d3a28c17774dd3bc9a3634726944eb5512d1c1 /buildstream/source.py
parent3dbbf07927a167614efd885d697f3cf5cd6093e9 (diff)
downloadbuildstream-ae96d215aa830b5421b8aa5805e7bbab38b27473.tar.gz
source.py: Make initialisation more classy
Construction of the plugin defaults and the config construction don't actually need access to the source instance, so make them into classmethods ready for extraction into the loader. Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
Diffstat (limited to 'buildstream/source.py')
-rw-r--r--buildstream/source.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index dd1dbd40a..fe94a15d7 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -319,7 +319,7 @@ class Source(Plugin):
# Collect the composited element configuration and
# ask the element to configure itself.
- self.__init_defaults(meta)
+ self.__init_defaults(project, meta)
self.__config = self.__extract_config(meta)
self.__first_pass = meta.first_pass
@@ -1231,21 +1231,22 @@ class Source(Plugin):
reason="ensure-stage-dir-fail") from e
return directory
- def __init_defaults(self, meta):
- if not self.__defaults_set:
- project = self._get_project()
+ @classmethod
+ def __init_defaults(cls, project, meta):
+ if not cls.__defaults_set:
if meta.first_pass:
sources = project.first_pass_config.source_overrides
else:
sources = project.source_overrides
- type(self).__defaults = _yaml.node_get(sources, Mapping, self.get_kind(), default_value={})
- type(self).__defaults_set = True
+ cls.__defaults = _yaml.node_get(sources, Mapping, meta.kind, default_value={})
+ cls.__defaults_set = True
# This will resolve the final configuration to be handed
# off to source.configure()
#
- def __extract_config(self, meta):
- config = _yaml.node_get(self.__defaults, Mapping, 'config', default_value={})
+ @classmethod
+ def __extract_config(cls, meta):
+ config = _yaml.node_get(cls.__defaults, Mapping, 'config', default_value={})
config = _yaml.node_copy(config)
_yaml.composite(config, meta.config)