File size: 714 Bytes
f758236 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #!/usr/bin/env python3
from pathlib import Path
import hashlib
ROOT = Path(__file__).resolve().parent
MANIFEST = ROOT / "BUNDLE_SHA256SUMS.txt"
def digest(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
files = sorted(
path for path in ROOT.rglob("*")
if path.is_file() and path != MANIFEST and "__pycache__" not in path.parts
)
MANIFEST.write_text(
"\n".join(f"{digest(path)} ./{path.relative_to(ROOT).as_posix()}" for path in files) + "\n",
encoding="utf-8",
)
assert all(
digest(ROOT / line.split(" ./", 1)[1]) == line.split(" ./", 1)[0]
for line in MANIFEST.read_text(encoding="utf-8").splitlines()
)
print(f"manifest verified: {len(files)} files")
|