summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-08-06 13:15:58 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-08-08 13:52:36 +0000
commit1701aa1239f472317edfc6f675378dc91b1fcd61 (patch)
tree5beca5f8acfbccea618b1bd2898b7f0bb33d2644
parent6a4ef84614cd0914270797a46fb7f94e289eff32 (diff)
downloadbuildstream-1701aa1239f472317edfc6f675378dc91b1fcd61.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.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py
index d9639161d..3cce0fbf1 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
+ # Get the full_name as project & type_tag are resolved
+ self.__full_name = self.__get_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 __get_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()
#