summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-12-04 16:45:58 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-12-07 17:53:03 +0900
commitf9cf2e59be5ea6798aa4b9cba4f62de28693b5c4 (patch)
treef9b9ae1479b9762c62fceca0d107052b66fccf29 /src
parent5ace573dc045ca5cab38d4baeff3abf874b152ee (diff)
downloadbuildstream-f9cf2e59be5ea6798aa4b9cba4f62de28693b5c4.tar.gz
_artifact.py: Added properties for cache key access
These properties allow easy addressing of the different cache keys, and report a cached value if the artifact was cached, otherwise report the value assigned to the Artifact at instantiation time.
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/_artifact.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index 1cea03092..6e2bc9342 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -71,6 +71,51 @@ class Artifact:
self._metadata_workspaced_dependencies = None # List of which dependencies are workspaced from the artifact
self._cached = None # Boolean of whether the artifact is cached
+ # strong_key():
+ #
+ # A property which evaluates to the strong key, regardless of whether
+ # it was the strong key that the Artifact object was initialized with
+ # or whether it was the strong key loaded from artifact metadata.
+ #
+ @property
+ def strong_key(self) -> str:
+ if self.cached():
+ key, _, _ = self.get_metadata_keys()
+ else:
+ key = self._cache_key
+
+ return key
+
+ # strict_key():
+ #
+ # A property which evaluates to the strict key, regardless of whether
+ # it was the strict key that the Artifact object was initialized with
+ # or whether it was the strict key loaded from artifact metadata.
+ #
+ @property
+ def strict_key(self) -> str:
+ if self.cached():
+ _, key, _ = self.get_metadata_keys()
+ else:
+ key = self._strict_key
+
+ return key
+
+ # weak_key():
+ #
+ # A property which evaluates to the weak key, regardless of whether
+ # it was the weak key that the Artifact object was initialized with
+ # or whether it was the weak key loaded from artifact metadata.
+ #
+ @property
+ def weak_key(self) -> str:
+ if self.cached():
+ _, _, key = self.get_metadata_keys()
+ else:
+ key = self._weak_cache_key
+
+ return key
+
# get_files():
#
# Get a virtual directory for the artifact files content