Return a reproducible hash of the user code of a loose PEX; excluding all `.pyc` files. If no code is found, `None` is returned.
(
cls,
directory,
exclude_dirs=(), # type: Container[str]
exclude_files=(), # type: Container[str]
)
| 81 | |
| 82 | @classmethod |
| 83 | def pex_code_hash( |
| 84 | cls, |
| 85 | directory, |
| 86 | exclude_dirs=(), # type: Container[str] |
| 87 | exclude_files=(), # type: Container[str] |
| 88 | ): |
| 89 | # type: (...) -> str |
| 90 | """Return a reproducible hash of the user code of a loose PEX; excluding all `.pyc` files. |
| 91 | |
| 92 | If no code is found, `None` is returned. |
| 93 | """ |
| 94 | digest = hashlib.sha1() |
| 95 | hashing.dir_hash( |
| 96 | directory=directory, |
| 97 | digest=digest, |
| 98 | dir_filter=lambda d: not is_pyc_dir(d) and d not in exclude_dirs, |
| 99 | file_filter=( |
| 100 | lambda f: ( |
| 101 | not is_pyc_file(f) |
| 102 | and not os.path.basename(f).startswith(".") |
| 103 | and f not in exclude_files |
| 104 | ) |
| 105 | ), |
| 106 | ) |
| 107 | return digest.hexdigest() |
| 108 | |
| 109 | @classmethod |
| 110 | def dir_hash(cls, directory, digest=None, hasher=sha1): |
no test coverage detected