"""Copy original local Valve assets, validate WAV/MDL, record SHA256 provenance.""" import pathlib, shutil, struct, wave, hashlib, json project = pathlib.Path(__file__).resolve().parents[1] source = pathlib.Path.home()/'.steam/steam/steamapps/common/Half-Life/valve' files = ['models/v_9mmar.mdl','models/w_9mmar.mdl','models/p_9mmar.mdl'] files += ['sound/weapons/'+n+'.wav' for n in ['hks1','hks2','hks3','dryfire1']] files += ['sound/items/'+n+'.wav' for n in ['clipinsert1','cliprelease1','guncock1']] files += ['sound/zombie/'+p.name for p in sorted((source/'sound/zombie').glob('*.wav'))] files += ['sound/player/pl_metal%d.wav'%i for i in range(1,5)] files += ['sound/debris/bustglass%d.wav'%i for i in range(1,4)] manifest=[] for relative in files: src=source/relative dst=project/'assets'/('weapons/'+src.name if relative.startswith('models/') else 'audio/'+relative.removeprefix('sound/')) dst.parent.mkdir(parents=True,exist_ok=True) shutil.copyfile(src,dst) row={'source':relative,'destination':str(dst.relative_to(project)),'sha256':hashlib.sha256(src.read_bytes()).hexdigest()} assert src.read_bytes()==dst.read_bytes() if src.suffix=='.wav': with wave.open(str(dst)) as w: assert w.getcomptype()=='NONE' row.update(channels=w.getnchannels(),bits=w.getsampwidth()*8,rate=w.getframerate(),duration=w.getnframes()/w.getframerate()) else: d=dst.read_bytes(); assert d[:4]==b'IDST' and struct.unpack_from('