forked from mtusi2026/mtusi2026lab4
16 lines
651 B
Python
16 lines
651 B
Python
"""Verify that every file supplied in the lab4 skeleton is byte-for-byte unchanged."""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
root=Path(__file__).resolve().parents[1]
|
|
baseline=json.loads((root/'course-files.sha256.json').read_text())
|
|
changed=[]
|
|
for name,digest in baseline['files'].items():
|
|
path=root/name
|
|
if not path.is_file() or hashlib.sha256(path.read_bytes()).hexdigest()!=digest:
|
|
changed.append(name)
|
|
if changed:
|
|
raise SystemExit('Изменены исходные файлы преподавателя: '+', '.join(changed))
|
|
print('PASS: all '+str(len(baseline['files']))+' supplied lab4 files are unchanged')
|