Files
aigc-home/docs/hel-892/scail-document-evidence/final-sources-scail.py.txt
T
2026-11-01 18:11:45 +08:00

17 lines
1.5 KiB
Plaintext

from pathlib import Path
import json,hashlib,subprocess,datetime
R=Path.cwd();F=R/'docs/hel-892/scail-reference';rows=json.loads((F/'sources.json').read_bytes())['sources'];now=datetime.datetime.now(datetime.timezone.utc).isoformat()
def add(key,files):
proto=next(e for e in rows if e['id']==key);cache=R/('.local-evidence/scail-'+key+'-git');tree=json.loads((F/(key+'-tree.json')).read_bytes())['tree']
for file in files:
if any(e['id']==key and e['file']==file for e in rows):continue
ent=next((e for e in tree if e['path']==file),None)
if not ent:print('MISSING',key,file);continue
raw=subprocess.check_output(['git','-C',str(cache),'show',proto['commit']+':'+file],timeout=80);assert len(raw)<3000000;local=key+'__'+file.replace('/','__');(F/local).write_bytes(raw)
rows.append(dict(proto,file=file,local_file=local,sha256=hashlib.sha256(raw).hexdigest(),git_blob_sha1=ent['sha'],acquisition_time=now,reverified_at=now,url=f"https://raw.githubusercontent.com/{proto['repo']}/{proto['commit']}/{file}"));print('ADD',key,file)
add('core0240',['comfy_extras/nodes_resolution.py','comfy_extras/nodes_post_processing.py','comfy_extras/nodes_rebatch.py'])
rows += json.loads((F/'mathpkg-source-rows.json').read_bytes())
for e in rows:
if e['id']=='frontend' and e['file']=='src/lib/litegraph/LICENSE':e['id']='litegraph';e['license_file']=e['local_file']
(F/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n');print('ROWS',len(rows))