"""Install new comparison fixtures; refuse to replace any existing runtime file.""" from pathlib import Path import hashlib,json ROOT=Path(__file__).resolve().parent PUBLIC=ROOT.parents[1]/'card-harness/public/card-art' def sha(p): return hashlib.sha256(p.read_bytes()).hexdigest() validation=json.loads((ROOT/'validation.json').read_text());assert validation['status']=='passed' preserved=json.loads((ROOT/'preserved-runtime-hashes.json').read_text()) for name,digest in preserved.items(): assert sha(PUBLIC/name)==digest,name files=sorted(ROOT.glob('*/output/runtime/*.png'));assert len(files)==9 for src in files: assert not (PUBLIC/src.name).exists(),src.name installed=[] for src in files: dest=PUBLIC/src.name;dest.write_bytes(src.read_bytes());assert sha(dest)==sha(src) installed.append({'name':dest.name,'sha256':sha(dest)}) for name,digest in preserved.items(): assert sha(PUBLIC/name)==digest,name (ROOT/'install-report.json').write_text(json.dumps({'status':'passed','existingPngFilesPreserved':len(preserved),'files':installed,'userMovingLightReview':'Pending'},indent=2)+'\n') print('Installed three comparison fixtures; preserved '+str(len(preserved))+' existing PNGs.')