"""Produce Arrakis material v7 from the published v6; replace exactly one UV texture.""" import argparse, hashlib, importlib.util, json, pathlib, zipfile ROOT=pathlib.Path(__file__).resolve().parents[1] spec=importlib.util.spec_from_file_location('repair',ROOT/'tools/build-resourcepack-repair.py'); repair=importlib.util.module_from_spec(spec); spec.loader.exec_module(repair) UV='assets/dunerealms/textures/entity/jerboa.png' def build(baseline,output): if hashlib.sha1(baseline.read_bytes()).hexdigest()!='2ad1703e99de297e72663fdd5d02bf928b53b0de':raise ValueError('Expected immutable Arrakis v6') old=repair.read_pack(baseline,hashlib.sha256(baseline.read_bytes()).hexdigest()) texture=(ROOT/'DuneRealmsGUI/ecology/textures/jerboa-beta.png').read_bytes(); assert texture[:8]==b'\x89PNG\r\n\x1a\n' and texture[16:24]==b'\x00\x00\x00@\x00\x00\x00@' and UV in old output.mkdir(parents=True,exist_ok=True);record=repair.write_pack(output,'DuneRealms-Materials-arrakis-v7.zip',{**old,UV:texture}) with zipfile.ZipFile(output/record['filename']) as pack: assert pack.testzip() is None and set(pack.namelist())==set(old) and {n for n in old if old[n]!=pack.read(n)}=={UV} return record if __name__=='__main__': p=argparse.ArgumentParser(description=__doc__);p.add_argument('baseline',type=pathlib.Path);p.add_argument('output',type=pathlib.Path);a=p.parse_args();print(json.dumps(build(a.baseline,a.output),indent=2))