Files
aigc-home/docs/hel-892/h3-mv-document-evidence/extend-mv.py.txt
T

29 lines
4.0 KiB
Plaintext

from pathlib import Path
import json,hashlib,os,datetime,subprocess,concurrent.futures
R=Path.cwd();REF=R/'docs/hel-892/h3-mv-reference';D=R/'docs/hel-892/h3-mv-document-evidence';REF.mkdir(exist_ok=True);D.mkdir(exist_ok=True);now=datetime.datetime.now(datetime.timezone.utc).isoformat();rows=[]
def fetch(spec):
key,repo,rev,files=spec;cache=R/('.local-evidence/mv-'+key+'-git');subprocess.run(['git','init','--bare',str(cache)],check=True,capture_output=True)
def git(*args):return subprocess.check_output(['git','-C',str(cache),*args],timeout=80)
p=subprocess.run(['git','-C',str(cache),'fetch','--filter=blob:none','--depth=1','https://github.com/'+repo+'.git',rev],capture_output=True,timeout=100);(REF/(key+'-fetch.txt')).write_bytes(p.stdout+p.stderr);assert p.returncode==0,p.stderr
commit=git('rev-parse','FETCH_HEAD^{commit}').decode().strip();obj=git('rev-parse','FETCH_HEAD').decode().strip();tree=git('rev-parse',commit+'^{tree}').decode().strip();cb=git('cat-file','commit',commit);tb=git('cat-file','tag' if obj!=commit else 'commit',obj);(REF/(key+'-commit.txt')).write_bytes(cb);(REF/(key+'-tag.txt')).write_bytes(tb);(REF/(key+'-tag.json')).write_text(json.dumps(dict(object=obj,commit=commit,tag=rev),indent=2)+'\n')
entries=[]
for line in git('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))
(REF/(key+'-tree.json')).write_text(json.dumps(dict(sha=tree,truncated=False,tree=entries),indent=2)+'\n');result=[]
for f in files:
ent=next((x for x in entries if x['path']==f),None)
if not ent:print('MISSING',key,f,flush=True);continue
raw=git('show',commit+':'+f);assert len(raw)<3000000;name=key+'__'+f.replace('/','__');(REF/name).write_bytes(raw)
result.append(dict(id=key,repo=repo,file=f,local_file=name,commit=commit,tree=tree,tag=rev,url=f'https://raw.githubusercontent.com/{repo}/{commit}/{f}',sha256=hashlib.sha256(raw).hexdigest(),git_blob_sha1=ent['sha'],acquisition_time=now,reverified_at=now,license_file=key+'__LICENSE',identity_root='.',identity_key=key,transport='filtered Git necessary text only',applicability='本图独立准确版本静态核准,不执行或认证安装/恢复'))
print('FETCH',key,commit,len(result),flush=True);return result
rows=json.loads((REF/'sources.json').read_bytes())['sources']
specs=[('selflift','slmonker/selflift-Avatar','5df288a083fa8585a563c9c2af7ebfa0e79188c7',['nodes.py','selflift.py','avatar_sampling.py','h3_tiling.py','h3_tst.py','h3_upscaler.py','avatar_masks.py','diagnostics.py','README.md']),('longvideo','Zzz1phyrf/ComfyUI-H3-LongVideo','2c1361d6ab4a270b72eb8fd9de826ac61d54e5bb',['nodes.py','core.py','controller.py','routes.py','director_rules.py','worker.py','web/h3lv.js','web/timeline.js','README.md']),('kj','kijai/ComfyUI-KJNodes','c9869eade9920a1b949de07c4a197156006bcceb',['nodes/minimax_nodes.py']),('kjattention','kijai/ComfyUI-KJNodes','3f20054214fec9f9234fd3841ae6f1e4287948f6',['nodes/minimax_nodes.py']),('crop','christian-byrne/audio-separation-nodes-comfyui','ac339561973f0c1e56db2f9d40f11b0fddda6763',['__init__.py','src/crop.py','pyproject.toml','requirements.txt','LICENSE','README.md']),('yc','yichengup/ComfyUI-YCNodes-MiniMax-H3','146207295c1d2bd6b64a6552484cb6ed8be1c9ef',['__init__.py','py/h3_sigma_refiner.py','pyproject.toml','requirements.txt','LICENSE','README.md']),('core0340','Comfy-Org/ComfyUI','v0.34.0',['nodes.py','comfy_extras/nodes_audio.py','LICENSE','requirements.txt'])]
with concurrent.futures.ThreadPoolExecutor(max_workers=4)as pool:
for rr in pool.map(fetch,specs):
for e in rr:rows=[x for x in rows if not(x['id']==e['id']and x['file']==e['file'])];rows.append(e)
for e in rows:
if e['file'].startswith('src/lib/litegraph/'):e['license_file']='frontend__src__lib__litegraph__LICENSE'
elif not(REF/e['license_file']).exists():e['license_file']='未知:准确树未取得独立许可;不推断模型/素材授权'
(REF/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n')