Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Union | |
| import hashlib | |
| import os | |
| def get_checksum(path_to_file: str, algorithm: Union[str, callable] = hashlib.sha256) -> str: | |
| """A function that computes checksum of a file using one of hashlib algorithms (default: SHA-256). It combines | |
| a "modern" implementation with a pre-Python3.11 compatible alternative.""" | |
| if not os.path.exists(path_to_file): | |
| raise FileNotFoundError(f"File {path_to_file!r} doesn't seem to exist") |
OlderNewer