25 lines
2.9 KiB
Plaintext
25 lines
2.9 KiB
Plaintext
from pathlib import Path
|
|
import json,os,hashlib,datetime,urllib.request,struct,zlib
|
|
R=Path.cwd();F=R/'docs/hel-892/singleloop-reference';d=json.loads((F/'sources.json').read_bytes());rows=d['sources'];now=datetime.datetime.now(datetime.timezone.utc).isoformat();rows+=json.loads((F/'rgthree-source-rows.json').read_bytes())
|
|
for folder,oldid,newid,files in [('avatar-skills-reference','vhspkg','vhs',['__init__.py','pyproject.toml','requirements.txt']),('flux2-real-reference','rgthree','rgthree',['web/comfyui/utils.js','web/comfyui/utils_widgets.js'])]:
|
|
p=R/'docs/hel-892'/folder/'sources.json'
|
|
for orig in json.loads(p.read_bytes())['sources']:
|
|
if orig['id']!=oldid or orig['file']not in files:continue
|
|
e=dict(orig,id=newid,reverified_at=now)
|
|
for k in ['local_file','license_file','identity_root']:
|
|
if k in e and(p.parent/e[k]).exists():e[k]=os.path.relpath((p.parent/e[k]).resolve(),F)
|
|
if not any(x['id']==newid and x['file']==e['file']for x in rows):rows.append(e)
|
|
# Only new necessary exact member py/utils.py, reuse verified central-directory offsets.
|
|
name='py/utils.py';e=next(x for x in json.loads((F/'rgthree-members.json').read_bytes())['members']if x['name']==name);proto=next(x for x in rows if x['id']=='rgthree');url=proto['url'];r=f"bytes={e['offset']}-{e['offset']+29+len(name)+512+e['compressed']}"
|
|
req=urllib.request.Request(url,headers={'Range':r,'User-Agent':'HEL-892-selected-members'})
|
|
with urllib.request.urlopen(req,timeout=40)as f:
|
|
assert f.status==206,'Refuse reading whole archive';data=f.read(1000000);record=dict(range=r,status=f.status,content_range=f.headers.get('Content-Range'))
|
|
h=struct.unpack_from('<4s5H3I2H',data);st=30+h[9]+h[10];raw=zlib.decompress(data[st:st+e['compressed']],-15)if e['method']==8 else data[st:st+e['compressed']];assert len(raw)==e['size']and zlib.crc32(raw)==e['crc'];local='rgthree__py__utils.py';(F/local).write_bytes(raw);rows.append(dict(proto,file=name,local_file=local,sha256=hashlib.sha256(raw).hexdigest(),acquisition_time=now,reverified_at=now));(F/'rgthree-utils-range.json').write_text(json.dumps(dict(url=url,request=record,member=e,full_archive_acquired=False),indent=2)+'\n')
|
|
# Do not cite unneeded Wan model internals when exact candidate class is absent.
|
|
rows=[e for e in rows if not(e['id']=='core051'and e['file']=='comfy/ldm/wan/model.py')];(F/'core051__comfy__ldm__wan__model.py').unlink()
|
|
for e in rows:
|
|
e.setdefault('acquisition_time','未知:旧成员记录未载首次时间')
|
|
if not e.get('license_file','').startswith('未知')and not(F/e.get('license_file','')).is_file():e['license_file']=next((x['local_file']for x in rows if x['id']==e['id']and x['file'].lower()in ['license','license.txt','license.md']),'未知:准确树无LICENSE,保留缺口')
|
|
assert hashlib.sha256((F/e['local_file']).read_bytes()).hexdigest()==e['sha256']
|
|
(F/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n');print('PASS',len(rows),'necessary source texts; no plugins executed')
|