summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-12 17:19:14 +0000
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-12 17:19:14 +0000
commit0e926f2fded475d21ce5b400e4fad6b5146b40fe (patch)
treede7bcdadf8ad5e1a8b0d60d6e6993e81a56b9dd8
parenta009e1630a565f29ced2768740f2a9c5f9f884d1 (diff)
downloadbuildstream-0e926f2fded475d21ce5b400e4fad6b5146b40fe.tar.gz
Element.__init_defaults: init if no plugin_conf
Still initialize `Element.__defaults` as usual, even if a `plugin_conf` is not specified. As part of the work on !1101 to introduce `ArtifactElement`s, a special case for `__init_defaults` was made, such that none of the usual defaults would be loaded. This seems to be because it has no config and none of the defaults are required by ArtifactElement, although they don't seem to adversely affect it. Instead, treat a 'None' `plugin_conf` in the same way as the existing case of a missing file. This avoids the appearance of having plugin-specific behaviour in the base-class, and is perhaps less puzzling to new contributors.
-rw-r--r--buildstream/element.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 65b9694a7..491d8c699 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2383,20 +2383,18 @@ class Element(Plugin):
defaults['public'] = element_public
def __init_defaults(self, plugin_conf):
- if plugin_conf is None:
- return
-
# Defaults are loaded once per class and then reused
#
if not self.__defaults_set:
-
- # Load the plugin's accompanying .yaml file if one was provided
defaults = {}
- try:
- defaults = _yaml.load(plugin_conf, os.path.basename(plugin_conf))
- except LoadError as e:
- if e.reason != LoadErrorReason.MISSING_FILE:
- raise e
+
+ if plugin_conf is not None:
+ # Load the plugin's accompanying .yaml file if one was provided
+ try:
+ defaults = _yaml.load(plugin_conf, os.path.basename(plugin_conf))
+ except LoadError as e:
+ if e.reason != LoadErrorReason.MISSING_FILE:
+ raise e
# Special case; compose any element-wide split-rules declarations
self.__compose_default_splits(defaults)