diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2018-11-08 14:27:26 +0000 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2019-02-12 10:19:03 +0000 |
commit | edb3b9f4020336d315b391926b98177fec5b63f4 (patch) | |
tree | 040330021964ca4c164783d63ab3ce9e55368b6d | |
parent | 86a9048a587f67fbb562f1188f9d04db0c220f75 (diff) | |
download | buildstream-edb3b9f4020336d315b391926b98177fec5b63f4.tar.gz |
_cachekey.py: Add a variant of the calculator which take pre-sanitized input
In order to support a case where the caller already has pre-sanitized input
this variant of the cache key generator needs to exist.
Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
-rw-r--r-- | buildstream/_cachekey.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/buildstream/_cachekey.py b/buildstream/_cachekey.py index fe407e96f..4370fd15e 100644 --- a/buildstream/_cachekey.py +++ b/buildstream/_cachekey.py @@ -40,3 +40,20 @@ def generate_key(value): ordered = _yaml.node_sanitize(value) string = pickle.dumps(ordered) return hashlib.sha256(string).hexdigest() + + +# generate_key_pre_sanitized() +# +# Generate an sha256 hex digest from the given value. The value +# must be (a) compatible with generate_key() and (b) already have +# been passed through _yaml.node_sanitize() +# +# Args: +# value: A sanitized value to get a key for +# +# Returns: +# (str): An sha256 hex digest of the given value +# +def generate_key_pre_sanitized(value): + string = pickle.dumps(value) + return hashlib.sha256(string).hexdigest() |