File size: 844 Bytes
d1c6c9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python3
"""Create SHA256SUMS for release files; not a cryptographic authorship signature."""
import hashlib
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
IGNORE_DIRS={'.git','.pytest_cache','__pycache__','.venv','_renders'}
IGNORE_SUFFIX={'.aux','.log','.out','.toc','.fls','.fdb_latexmk','.bbl','.blg','.pyc'}
entries=[]
for path in sorted(ROOT.rglob('*')):
    rel=path.relative_to(ROOT)
    if not path.is_file() or any(part in IGNORE_DIRS or part.endswith('.egg-info') for part in rel.parts): continue
    if path.name in {'SHA256SUMS','main.pdf'} or path.suffix in IGNORE_SUFFIX: continue
    entries.append(f'{hashlib.sha256(path.read_bytes()).hexdigest()}  {rel.as_posix()}')
(ROOT/'SHA256SUMS').write_text('\n'.join(entries)+'\n',encoding='utf-8')
print(f'Wrote SHA256SUMS for {len(entries)} files.')