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:37:15 UTC

[buildstream] 05/07: element.py: Remove redundant __is_cached() method

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

not-in-ldap pushed a commit to branch shared/split_out_update_state
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 920a08dcd553b829e0c47fba7bbf8fb68713859b
Author: Jonathan Maw <jo...@codethink.co.uk>
AuthorDate: Thu Apr 18 15:58:01 2019 +0100

    element.py: Remove redundant __is_cached() method
    
    Previously, there was a _cached() method that called __is_cached().
    This change moves the logic from __is_cached() into _cached().
---
 buildstream/element.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/buildstream/element.py b/buildstream/element.py
index 8cee859..c619a10 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1036,12 +1036,21 @@ class Element(Plugin):
 
     # _cached():
     #
+    # Determines whether this element is cached (using the stored
+    # cached state)
+    #
+    # Args:
+    #    (_KeyStrength) keystrength: The strength of the key to 
+    #        determine whether it is cached.
     # Returns:
     #    (bool): Whether this element is already present in
     #            the artifact cache
     #
-    def _cached(self):
-        return self.__is_cached(keystrength=None)
+    def _cached(self, keystrength=None):
+        if keystrength is None:
+            keystrength = _KeyStrength.STRONG if self._get_context().get_strict() else _KeyStrength.WEAK
+
+        return self.__strong_cached if keystrength == _KeyStrength.STRONG else self.__weak_cached
 
     # _get_build_result():
     #
@@ -2370,18 +2379,12 @@ class Element(Plugin):
                 # have been executed.
                 sandbox._callback(mark_workspace_prepared)
 
-    def __is_cached(self, keystrength):
-        if keystrength is None:
-            keystrength = _KeyStrength.STRONG if self._get_context().get_strict() else _KeyStrength.WEAK
-
-        return self.__strong_cached if keystrength == _KeyStrength.STRONG else self.__weak_cached
-
     # __assert_cached()
     #
     # Raises an error if the artifact is not cached.
     #
     def __assert_cached(self, keystrength=None):
-        assert self.__is_cached(keystrength=keystrength), "{}: Missing artifact {}".format(
+        assert self._cached(keystrength=keystrength), "{}: Missing artifact {}".format(
             self, self._get_brief_display_key())
 
     # __get_tainted():