You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:30:56 UTC

[buildstream] 02/19: plugin.py: cache full_name member in __init__

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch phil/ui-split-refactor
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c5db3d822a2433b97ee52e9108da135edf4ba13e
Author: Tom Pollard <to...@codethink.co.uk>
AuthorDate: Tue Aug 6 13:15:58 2019 +0100

    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.
---
 src/buildstream/plugin.py | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py
index d963916..506eba5 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()
 #