diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-08-06 13:15:58 +0100 |
---|---|---|
committer | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-08-06 13:40:11 +0100 |
commit | c5db3d822a2433b97ee52e9108da135edf4ba13e (patch) | |
tree | 32d7b0e276eed8a84c425038353970892e5b1777 | |
parent | 456da5723d447789260a7c970dcfca736567e240 (diff) | |
download | buildstream-c5db3d822a2433b97ee52e9108da135edf4ba13e.tar.gz |
plugin.py: cache full_name member in __init__
Once project & type are resolved, the full_name can be computed
and cached for efficiency. The accessor for getting the private
member should also be moved to the correct section.
-rw-r--r-- | src/buildstream/plugin.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py index d9639161d..506eba536 100644 --- a/src/buildstream/plugin.py +++ b/src/buildstream/plugin.py @@ -246,6 +246,9 @@ class Plugin(): self.__type_tag = type_tag # The type of plugin (element or source) self.__configuring = False # Whether we are currently configuring + # Set the full_name as project & type_tag are resolved + self.__full_name = self.__set_full_name() + # Infer the kind identifier modulename = type(self).__module__ self.__kind = modulename.split('.')[-1] @@ -672,6 +675,18 @@ class Plugin(): def _preflight(self): self.preflight() + # _get_full_name(): + # + # The instance full name of the plugin prepended with the owning + # junction if appropriate. This being the name of the given element, + # as appose to the class name of the underlying plugin __kind identifier. + # + # Returns: + # (str): element full name, with prepended owning junction if appropriate + # + def _get_full_name(self): + return self.__full_name + # _get_args_for_child_job_pickling(self) # # Return data necessary to reconstruct this object in a child job process. @@ -728,13 +743,6 @@ class Plugin(): output.flush() self.status('Running host command', detail=command) - def _get_full_name(self): - project = self.__project - if project.junction: - return '{}:{}'.format(project.junction.name, self.name) - else: - return self.name - def __deprecation_warning_silenced(self): if not self.BST_PLUGIN_DEPRECATED: return False @@ -751,6 +759,13 @@ class Plugin(): return self.get_kind() in silenced_warnings + def __set_full_name(self): + project = self.__project + if project.junction: + return '{}:{}'.format(project.junction.name, self.name) + else: + return self.name + # A local table for _prefix_warning() # |