Download runtime/src/pixelone/io.py from KangHui2200/PixelOne: direct link, hf CLI and curl.
- Browser
- Download file 505 Bytes
-
https://huggingface.co/KangHui2200/PixelOne/resolve/main/runtime/src/pixelone/io.py
- Command line
-
hf download hf://KangHui2200/PixelOne/runtime/src/pixelone/io.py
-
curl -L -o io.py https://huggingface.co/KangHui2200/PixelOne/resolve/main/runtime/src/pixelone/io.py
505 Bytes
| import hashlib | |
| from pathlib import Path | |
| def file_sha256(path): | |
| digest = hashlib.sha256() | |
| with Path(path).open('rb') as stream: | |
| for block in iter(lambda: stream.read(8 * 1024 * 1024), b''): | |
| digest.update(block) | |
| return digest.hexdigest() | |
| def bundle_member(root, name): | |
| relative = Path(name) | |
| if not name or relative.is_absolute() or '..' in relative.parts or '\\' in name: | |
| raise ValueError('Unsafe bundle member: ' + name) | |
| return Path(root) / relative | |