#!/usr/bin/env python3 """ generate_checksums.py ===================== Generates SHA-256 checksums for all data files in the MatchGeo dataset. Usage: python generate_checksums.py --data-root /path/to/MatchGeo-DEM-v1 --output checksums.sha256 """ import hashlib import argparse from pathlib import Path def sha256_file(filepath): """Return SHA-256 hex digest of a file.""" h = hashlib.sha256() with open(filepath, "rb") as f: for chunk in iter(lambda: f.read(8192 * 1024), b""): h.update(chunk) return h.hexdigest() def main(): data_root = "/home/sabrina/Documents/Tese/05_Dataset/MatchGeo-DEM-v1" output = "checksums.sha256" include = [".tif", ".json", ".geojson", ".csv", ".qmd", ".cff", ".md"] data_root = Path(data_root) output_path = Path(output) print("=" * 60) print("MatchGeo-DEM Checksum Generator") print("=" * 60) entries = [] for ext in include: for filepath in sorted(data_root.rglob(f"*{ext}")): if ".git" in str(filepath): continue rel = filepath.relative_to(data_root) digest = sha256_file(filepath) entries.append(f"{digest} {rel}") print(f" {rel}") output_path.write_text("\n".join(entries) + "\n", encoding="utf-8") print(f"\nāœ… {len(entries)} files hashed → {output_path}") print("=" * 60) if __name__ == "__main__": main()