diff options
Diffstat (limited to 'src/buildstream/plugin.py')
-rw-r--r-- | src/buildstream/plugin.py | 87 |
1 files changed, 17 insertions, 70 deletions
diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py index 2e34106de..6a7bd78e1 100644 --- a/src/buildstream/plugin.py +++ b/src/buildstream/plugin.py @@ -273,9 +273,7 @@ class Plugin: # If this plugin has been deprecated, emit a warning. if self.BST_PLUGIN_DEPRECATED and not self.__deprecation_warning_silenced(): - detail = "Using deprecated plugin {}: {}".format( - self.__kind, self.BST_PLUGIN_DEPRECATION_MESSAGE - ) + detail = "Using deprecated plugin {}: {}".format(self.__kind, self.BST_PLUGIN_DEPRECATION_MESSAGE) self.__message(MessageType.WARN, detail) def __del__(self): @@ -316,9 +314,7 @@ class Plugin: method can be used. """ raise ImplError( - "{tag} plugin '{kind}' does not implement configure()".format( - tag=self.__type_tag, kind=self.get_kind() - ) + "{tag} plugin '{kind}' does not implement configure()".format(tag=self.__type_tag, kind=self.get_kind()) ) def preflight(self) -> None: @@ -340,9 +336,7 @@ class Plugin: will raise an error automatically informing the user that a host tool is needed. """ raise ImplError( - "{tag} plugin '{kind}' does not implement preflight()".format( - tag=self.__type_tag, kind=self.get_kind() - ) + "{tag} plugin '{kind}' does not implement preflight()".format(tag=self.__type_tag, kind=self.get_kind()) ) def get_unique_key(self) -> SourceRef: @@ -419,9 +413,7 @@ class Plugin: """ - return self.__project.get_path_from_node( - node, check_is_file=check_is_file, check_is_dir=check_is_dir - ) + return self.__project.get_path_from_node(node, check_is_file=check_is_file, check_is_dir=check_is_dir) def debug(self, brief: str, *, detail: Optional[str] = None) -> None: """Print a debugging message @@ -459,13 +451,7 @@ class Plugin: """ self.__message(MessageType.INFO, brief, detail=detail) - def warn( - self, - brief: str, - *, - detail: Optional[str] = None, - warning_token: Optional[str] = None - ) -> None: + def warn(self, brief: str, *, detail: Optional[str] = None, warning_token: Optional[str] = None) -> None: """Print a warning message, checks warning_token against project configuration Args: @@ -485,9 +471,7 @@ class Plugin: if project._warning_is_fatal(warning_token): detail = detail if detail else "" - raise PluginError( - message="{}\n{}".format(brief, detail), reason=warning_token - ) + raise PluginError(message="{}\n{}".format(brief, detail), reason=warning_token) self.__message(MessageType.WARN, brief=brief, detail=detail) @@ -505,11 +489,7 @@ class Plugin: @contextmanager def timed_activity( - self, - activity_name: str, - *, - detail: Optional[str] = None, - silent_nested: bool = False + self, activity_name: str, *, detail: Optional[str] = None, silent_nested: bool = False ) -> Generator[None, None, None]: """Context manager for performing timed activities in plugins @@ -533,20 +513,11 @@ class Plugin: self.call(... command which takes time ...) """ with self.__context.messenger.timed_activity( - activity_name, - element_name=self._get_full_name(), - detail=detail, - silent_nested=silent_nested, + activity_name, element_name=self._get_full_name(), detail=detail, silent_nested=silent_nested, ): yield - def call( - self, - *popenargs, - fail: Optional[str] = None, - fail_temporarily: bool = False, - **kwargs - ) -> int: + def call(self, *popenargs, fail: Optional[str] = None, fail_temporarily: bool = False, **kwargs) -> int: """A wrapper for subprocess.call() Args: @@ -577,14 +548,10 @@ class Plugin: "Failed to download ponies from {}".format( self.mirror_directory)) """ - exit_code, _ = self.__call( - *popenargs, fail=fail, fail_temporarily=fail_temporarily, **kwargs - ) + exit_code, _ = self.__call(*popenargs, fail=fail, fail_temporarily=fail_temporarily, **kwargs) return exit_code - def check_output( - self, *popenargs, fail=None, fail_temporarily=False, **kwargs - ) -> Tuple[int, str]: + def check_output(self, *popenargs, fail=None, fail_temporarily=False, **kwargs) -> Tuple[int, str]: """A wrapper for subprocess.check_output() Args: @@ -630,13 +597,7 @@ class Plugin: raise SourceError( fmt.format(plugin=self, track=tracking)) from e """ - return self.__call( - *popenargs, - collect_stdout=True, - fail=fail, - fail_temporarily=fail_temporarily, - **kwargs - ) + return self.__call(*popenargs, collect_stdout=True, fail=fail, fail_temporarily=fail_temporarily, **kwargs) ############################################################# # Private Methods used in BuildStream # @@ -773,14 +734,7 @@ class Plugin: # Internal subprocess implementation for the call() and check_output() APIs # - def __call( - self, - *popenargs, - collect_stdout=False, - fail=None, - fail_temporarily=False, - **kwargs - ): + def __call(self, *popenargs, collect_stdout=False, fail=None, fail_temporarily=False, **kwargs): with self._output_file() as output_file: if "stdout" not in kwargs: @@ -796,16 +750,13 @@ class Plugin: if fail and exit_code: raise PluginError( - "{plugin}: {message}".format(plugin=self, message=fail), - temporary=fail_temporarily, + "{plugin}: {message}".format(plugin=self, message=fail), temporary=fail_temporarily, ) return (exit_code, output) def __message(self, message_type, brief, **kwargs): - message = Message( - message_type, brief, element_name=self._get_full_name(), **kwargs - ) + message = Message(message_type, brief, element_name=self._get_full_name(), **kwargs) self.__context.messenger.message(message) def __note_command(self, output, *popenargs, **kwargs): @@ -834,9 +785,7 @@ class Plugin: def __get_full_name(self): project = self.__project # Set the name, depending on element or source plugin type - name = ( - self._element_name if self.__type_tag == "source" else self.name - ) # pylint: disable=no-member + name = self._element_name if self.__type_tag == "source" else self.name # pylint: disable=no-member if project.junction: return "{}:{}".format(project.junction.name, name) else: @@ -845,9 +794,7 @@ class Plugin: # A local table for _prefix_warning() # -__CORE_WARNINGS = [ - value for name, value in CoreWarnings.__dict__.items() if not name.startswith("__") -] +__CORE_WARNINGS = [value for name, value in CoreWarnings.__dict__.items() if not name.startswith("__")] # _prefix_warning(): |