"""Refresh the package integrity manifest after intentional local edits.""" from pathlib import Path import hashlib ROOT=Path(__file__).resolve().parents[1] def update(root=ROOT): files=sorted(p for p in root.rglob("*") if p.is_file() and p!=root/"SHA256SUMS.txt" and not any(part in {"__pycache__",".git",".cache"} for part in p.relative_to(root).parts)) lines=[hashlib.sha256(p.read_bytes()).hexdigest()+" "+p.relative_to(root).as_posix() for p in files] (root/"SHA256SUMS.txt").write_text("\n".join(lines)+"\n",encoding="utf-8") return len(lines) if __name__=="__main__":print(f"Hashed {update()} repository files.")