Download verify.py from inclusionAI/LemonDecider-4B-preview: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/inclusionAI/LemonDecider-4B-preview/resolve/main/verify.py
- Command line
-
hf download hf://inclusionAI/LemonDecider-4B-preview/verify.py
-
curl -L -o verify.py https://huggingface.co/inclusionAI/LemonDecider-4B-preview/resolve/main/verify.py
1.47 kB
| # Author:浅斟 | |
| """Verify release files using only the Python standard library.""" | |
| from pathlib import Path | |
| import hashlib | |
| def main(): | |
| root = Path(__file__).resolve().parent | |
| rows = (root / "SHA256SUMS").read_text().splitlines() | |
| seen = set() | |
| for line in rows: | |
| digest, name = line.split(" ", 1) | |
| if not name or Path(name).name != name or name in seen: | |
| raise ValueError("Invalid checksum manifest") | |
| seen.add(name) | |
| path = root / name | |
| if path.is_symlink() or not path.is_file(): | |
| raise ValueError("Missing or linked release file: " + name) | |
| hasher = hashlib.sha256() | |
| with path.open("rb") as handle: | |
| for block in iter(lambda: handle.read(4 << 20), b""): | |
| hasher.update(block) | |
| if hasher.hexdigest() != digest: | |
| raise ValueError("Checksum mismatch: " + name) | |
| extras = {p.name for p in root.iterdir() if p.is_file()} - seen - {"SHA256SUMS"} | |
| if extras: | |
| raise ValueError("Unlisted files: " + ", ".join(sorted(extras))) | |
| directories = {p.name for p in root.iterdir() if p.is_dir()} - {"__pycache__"} | |
| if directories: | |
| raise ValueError("Unexpected directories: " + ", ".join(sorted(directories))) | |
| cache = root / "__pycache__" | |
| if cache.is_symlink(): | |
| raise ValueError("__pycache__ must not be a symlink") | |
| print(f"OK: {len(seen)} release files verified") | |
| if __name__ == "__main__": | |
| main() |