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

26 lines
3.2 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_sam3.py','comfy_extras/nodes_color.py','comfy_extras/nodes_image_compare.py','comfy_extras/nodes_image_transform.py','comfy_extras/nodes_batch.py','comfy_extras/nodes_math.py','comfy/samplers.py'])
add('frontend',['src/lib/litegraph/src/subgraph/SubgraphNode.ts','src/lib/litegraph/src/subgraph/Subgraph.ts','src/core/graph/subgraph/legacyProxyWidgetNormalization.ts','src/core/graph/subgraph/resolvePromotedWidgetSource.ts','src/core/graph/subgraph/resolveSubgraphInputLink.ts','src/core/graph/subgraph/resolveSubgraphInputTarget.ts'])
# Easy exact identity metadata fetched; reused source bytes retain first acquisition metadata.
key='easy';cache=R/'.local-evidence/scail-easy-git';subprocess.run(['git','init','--bare',str(cache)],check=True,capture_output=True)
rev='625efbfa2fc20c31797dfffcbb41a26b6d91ab7b';repo='yolain/ComfyUI-Easy-Use';p=subprocess.run(['git','-C',str(cache),'fetch','--filter=blob:none','--depth=1','https://github.com/'+repo+'.git',rev],capture_output=True,timeout=100);(F/'easy-fetch.txt').write_bytes(p.stdout+p.stderr);assert p.returncode==0
commit=subprocess.check_output(['git','-C',str(cache),'rev-parse','FETCH_HEAD^{commit}']).decode().strip();treeSHA=subprocess.check_output(['git','-C',str(cache),'rev-parse',commit+'^{tree}']).decode().strip();(F/'easy-commit.txt').write_bytes(subprocess.check_output(['git','-C',str(cache),'cat-file','commit',commit]));entries=[]
for line in subprocess.check_output(['git','-C',str(cache),'ls-tree','-r',commit]).decode().splitlines():
meta,path=line.split('\t');mode,typ,sha=meta.split();entries.append(dict(path=path,mode=mode,type=typ,sha=sha))
(F/'easy-tree.json').write_text(json.dumps(dict(sha=treeSHA,truncated=False,tree=entries),indent=2)+'\n')
for e in rows:
if e['id']!='easy':continue
e.update(repo=repo,commit=commit,tree=treeSHA,identity_root='.',identity_key='easy',git_blob_sha1=next(x['sha']for x in entries if x['path']==e['file']))
add('easy',['py/libs/utils.py','requirements.txt','pyproject.toml','web_version/v1/js/easy/easy.js','web_version/v1/js/easy/easyDynamicWidgets.js'])
(F/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n');print('ROWS',len(rows))