diff options
author | Stéphane Bidoul <stephane.bidoul@gmail.com> | 2023-04-15 11:38:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-15 11:38:38 +0200 |
commit | dbf4e6842c9603792f6d3944a5c9cec17bd0a92a (patch) | |
tree | a9e4630d04fa03dea335d5a93a6041cf736c0bde /src/pip/_internal/utils/hashes.py | |
parent | f7787f8798712e475ebbf71f5487f92158f043a9 (diff) | |
parent | efe2d27451d50b165df78093bf5885da713fbdf8 (diff) | |
download | pip-dbf4e6842c9603792f6d3944a5c9cec17bd0a92a.tar.gz |
Merge pull request #11897 from sbidoul/cache-hash-checking-sbi
Support wheel cache when using --require-hashes
Diffstat (limited to 'src/pip/_internal/utils/hashes.py')
-rw-r--r-- | src/pip/_internal/utils/hashes.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pip/_internal/utils/hashes.py b/src/pip/_internal/utils/hashes.py index 76727306a..843cffc6b 100644 --- a/src/pip/_internal/utils/hashes.py +++ b/src/pip/_internal/utils/hashes.py @@ -105,6 +105,13 @@ class Hashes: with open(path, "rb") as file: return self.check_against_file(file) + def has_one_of(self, hashes: Dict[str, str]) -> bool: + """Return whether any of the given hashes are allowed.""" + for hash_name, hex_digest in hashes.items(): + if self.is_hash_allowed(hash_name, hex_digest): + return True + return False + def __bool__(self) -> bool: """Return whether I know any known-good hashes.""" return bool(self._allowed) |