Datasets:
File size: 1,441 Bytes
0a7933d | 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/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()
|