diff options
Diffstat (limited to 'src/buildstream/_pluginfactory')
-rw-r--r-- | src/buildstream/_pluginfactory/elementfactory.py | 2 | ||||
-rw-r--r-- | src/buildstream/_pluginfactory/pluginfactory.py | 17 | ||||
-rw-r--r-- | src/buildstream/_pluginfactory/pluginorigin.py | 4 | ||||
-rw-r--r-- | src/buildstream/_pluginfactory/pluginoriginjunction.py | 6 | ||||
-rw-r--r-- | src/buildstream/_pluginfactory/pluginoriginpip.py | 12 | ||||
-rw-r--r-- | src/buildstream/_pluginfactory/sourcefactory.py | 2 |
6 files changed, 24 insertions, 19 deletions
diff --git a/src/buildstream/_pluginfactory/elementfactory.py b/src/buildstream/_pluginfactory/elementfactory.py index 7d94c2541..f23ace809 100644 --- a/src/buildstream/_pluginfactory/elementfactory.py +++ b/src/buildstream/_pluginfactory/elementfactory.py @@ -48,6 +48,6 @@ class ElementFactory(PluginFactory): # LoadError (if the element itself took issue with the config) # def create(self, context, project, load_element): - element_type, default_config = self.lookup(context.messenger, load_element.kind, load_element.provenance) + element_type, default_config = self.lookup(context.messenger, load_element.kind, load_element.node) element = element_type(context, project, load_element, default_config) return element diff --git a/src/buildstream/_pluginfactory/pluginfactory.py b/src/buildstream/_pluginfactory/pluginfactory.py index f997d9017..fb5389b3e 100644 --- a/src/buildstream/_pluginfactory/pluginfactory.py +++ b/src/buildstream/_pluginfactory/pluginfactory.py @@ -26,7 +26,7 @@ from .. import _site from ..plugin import Plugin from ..source import Source from ..element import Element -from ..node import ProvenanceInformation +from ..node import Node from ..utils import UtilError from .._exceptions import PluginError from .._messenger import Messenger @@ -122,8 +122,7 @@ class PluginFactory: # Args: # messenger (Messenger): The messenger # kind (str): The kind of Plugin to create - # provenance (ProvenanceInformation): The provenance from where - # the plugin was referenced + # provenance_node (Node): The node from where the plugin was referenced # # Returns: # (type): The type associated with the given kind @@ -131,8 +130,8 @@ class PluginFactory: # # Raises: PluginError # - def lookup(self, messenger: Messenger, kind: str, provenance: ProvenanceInformation) -> Tuple[Type[Plugin], str]: - plugin_type, defaults = self._ensure_plugin(kind, provenance) + def lookup(self, messenger: Messenger, kind: str, provenance_node: Node) -> Tuple[Type[Plugin], str]: + plugin_type, defaults = self._ensure_plugin(kind, provenance_node) # We can be called with None for the messenger here in the # case that we've been pickled through the scheduler (see jobpickler.py), @@ -150,7 +149,7 @@ class PluginFactory: if plugin_type.BST_PLUGIN_DEPRECATED and not self._allow_deprecated[kind]: message = Message( MessageType.WARN, - "{}: Using deprecated plugin '{}'".format(provenance, kind), + "{}: Using deprecated plugin '{}'".format(provenance_node.get_provenance(), kind), detail=plugin_type.BST_PLUGIN_DEPRECATION_MESSAGE, ) messenger.message(message) @@ -214,7 +213,7 @@ class PluginFactory: # Raises: # (PluginError): In case something went wrong loading the plugin # - def _ensure_plugin(self, kind: str, provenance: ProvenanceInformation) -> Tuple[Type[Plugin], str]: + def _ensure_plugin(self, kind: str, provenance_node: Node) -> Tuple[Type[Plugin], str]: if kind not in self._types: @@ -239,7 +238,9 @@ class PluginFactory: # Try getting it from the core plugins if kind not in self._site_source.list_plugins(): raise PluginError( - "{}: No {} plugin registered for kind '{}'".format(provenance, self._plugin_type, kind), + "{}: No {} plugin registered for kind '{}'".format( + provenance_node.get_provenance(), self._plugin_type, kind + ), reason="plugin-not-found", ) diff --git a/src/buildstream/_pluginfactory/pluginorigin.py b/src/buildstream/_pluginfactory/pluginorigin.py index e75b8cb58..f464b22ea 100644 --- a/src/buildstream/_pluginfactory/pluginorigin.py +++ b/src/buildstream/_pluginfactory/pluginorigin.py @@ -79,7 +79,7 @@ class PluginOrigin: self.origin_type = origin_type # The PluginOriginType self.elements = {} # A dictionary of PluginConfiguration self.sources = {} # A dictionary of PluginConfiguration objects - self.provenance = None + self.provenance_node = None self.project = None # Private @@ -102,7 +102,7 @@ class PluginOrigin: # def initialize(self, project, origin_node): - self.provenance = origin_node.get_provenance() + self.provenance_node = origin_node self.project = project self.load_config(origin_node) diff --git a/src/buildstream/_pluginfactory/pluginoriginjunction.py b/src/buildstream/_pluginfactory/pluginoriginjunction.py index c32a7956c..55e6849a6 100644 --- a/src/buildstream/_pluginfactory/pluginoriginjunction.py +++ b/src/buildstream/_pluginfactory/pluginoriginjunction.py @@ -35,7 +35,7 @@ class PluginOriginJunction(PluginOrigin): # Get access to the project indicated by the junction, # possibly loading it as a side effect. # - loader = self.project.loader.get_loader(self._junction, self.provenance) + loader = self.project.loader.get_loader(self._junction, self.provenance_node) project = loader.project project.ensure_fully_loaded() @@ -54,7 +54,7 @@ class PluginOriginJunction(PluginOrigin): # raise PluginError( "{}: Error loading {} plugin '{}' from project '{}' referred to by junction '{}': {}".format( - self.provenance, plugin_type, kind, project.name, self._junction, e + self.provenance_node.get_provenance(), plugin_type, kind, project.name, self._junction, e ), reason="junction-plugin-load-error", detail=e.detail, @@ -69,7 +69,7 @@ class PluginOriginJunction(PluginOrigin): # raise PluginError( "{}: project '{}' referred to by junction '{}' does not declare any {} plugin kind: '{}'".format( - self.provenance, project.name, self._junction, plugin_type, kind + self.provenance_node.get_provenance(), project.name, self._junction, plugin_type, kind ), reason="junction-plugin-not-found", ) diff --git a/src/buildstream/_pluginfactory/pluginoriginpip.py b/src/buildstream/_pluginfactory/pluginoriginpip.py index 013cd67f3..59b5d5251 100644 --- a/src/buildstream/_pluginfactory/pluginoriginpip.py +++ b/src/buildstream/_pluginfactory/pluginoriginpip.py @@ -50,27 +50,31 @@ class PluginOriginPip(PluginOrigin): package = pkg_resources.get_entry_info(self._package_name, entrypoint_group, kind) except pkg_resources.DistributionNotFound as e: raise PluginError( - "{}: Failed to load {} plugin '{}': {}".format(self.provenance, plugin_type, kind, e), + "{}: Failed to load {} plugin '{}': {}".format( + self.provenance_node.get_provenance(), plugin_type, kind, e + ), reason="package-not-found", ) from e except pkg_resources.VersionConflict as e: raise PluginError( "{}: Version conflict encountered while loading {} plugin '{}'".format( - self.provenance, plugin_type, kind + self.provenance_node.get_provenance(), plugin_type, kind ), detail=e.report(), reason="package-version-conflict", ) from e except pkg_resources.RequirementParseError as e: raise PluginError( - "{}: Malformed package-name '{}' encountered: {}".format(self.provenance, self._package_name, e), + "{}: Malformed package-name '{}' encountered: {}".format( + self.provenance_node.get_provenance(), self._package_name, e + ), reason="package-malformed-requirement", ) from e if package is None: raise PluginError( "{}: Pip package {} does not contain a plugin named '{}'".format( - self.provenance, self._package_name, kind + self.provenance_node.get_provenance(), self._package_name, kind ), reason="plugin-not-found", ) diff --git a/src/buildstream/_pluginfactory/sourcefactory.py b/src/buildstream/_pluginfactory/sourcefactory.py index 2ed78f838..3375d182b 100644 --- a/src/buildstream/_pluginfactory/sourcefactory.py +++ b/src/buildstream/_pluginfactory/sourcefactory.py @@ -49,6 +49,6 @@ class SourceFactory(PluginFactory): # LoadError (if the source itself took issue with the config) # def create(self, context, project, meta, variables): - source_type, _ = self.lookup(context.messenger, meta.kind, meta.provenance) + source_type, _ = self.lookup(context.messenger, meta.kind, meta.config) source = source_type(context, project, meta, variables) return source |