55 lines
7.7 KiB
Plaintext
55 lines
7.7 KiB
Plaintext
"""Batch164 selected exact text only; never import upstream. Times sampled per completed read."""
|
|
from pathlib import Path
|
|
import subprocess,json,hashlib,datetime,concurrent.futures,os,zlib,urllib.request
|
|
R=Path.cwd();F=R/'docs/hel-892/animate2-loop-reference';F.mkdir(exist_ok=True)
|
|
def utc():return datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
def sha(b):return hashlib.sha256(b).hexdigest()
|
|
rows=[];failures=[]
|
|
def reuse(folder,key,newkey=None,files=None):
|
|
src=R/'docs/hel-892'/folder;data=json.loads((src/'sources.json').read_bytes());xs=data.get('sources',[])if isinstance(data,dict)else data
|
|
for old in xs:
|
|
if old.get('id')!=key or files is not None and old['file']not in files:continue
|
|
e=dict(old);raw=(src/e['local_file']).read_bytes();assert sha(raw)==e['sha256']
|
|
if 'member_crc32'in e:assert zlib.crc32(raw)&0xffffffff==e['member_crc32']
|
|
root=(src/e.get('identity_root','.')).resolve();ik=e.get('identity_key',key)
|
|
if len(e.get('git_blob_sha1',''))==40:
|
|
assert hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()==e['git_blob_sha1']
|
|
tree=json.loads((root/(ik+'-tree.json')).read_bytes());assert tree['sha']==e['tree'];assert next(x['sha']for x in tree['tree']if x['path']==e['file'])==e['git_blob_sha1']
|
|
cb=(root/(ik+'-commit.txt')).read_bytes();assert hashlib.sha1(b'commit '+str(len(cb)).encode()+b'\0'+cb).hexdigest()==e['commit'];assert cb.splitlines()[0]==('tree '+e['tree']).encode()
|
|
for k in ['local_file','license_file','identity_root','canonical_identity_record']:
|
|
if e.get(k)and not e[k].startswith('未知'):e[k]=os.path.relpath((src/e[k]).resolve(),F)
|
|
if 'member_crc32'in e:
|
|
for suffix in ['-members.json','-range-proof.json']:
|
|
p=src/(key+suffix)
|
|
if p.exists():(F/((newkey or key)+suffix)).write_bytes(p.read_bytes())
|
|
e.update(id=newkey or key,reverified_at=utc(),reuse_from=str(src.relative_to(R))+'/'+old['local_file'],applicability='本图逐源静态重读SHA/身份后实际UTC;首次获取原值或未知保留,不执行上游')
|
|
rows.append(e)
|
|
reuse('scail-reference','mathpkg')
|
|
specs=[('core0311', 'Comfy-Org/ComfyUI', 'v0.31.1', ['nodes.py', 'comfy_extras/nodes_wan.py', 'comfy_extras/nodes_video.py', 'comfy_extras/nodes_context_windows.py', 'comfy_extras/nodes_post_processing.py', 'comfy_extras/nodes_logic.py', 'comfy_extras/nodes_custom_sampler.py', 'comfy_extras/nodes_primitive.py', 'comfy_extras/nodes_images.py', 'comfy_extras/nodes_math.py', 'comfy_extras/nodes_preview_any.py', 'comfy_extras/nodes_model_advanced.py', 'comfy_api/latest/_io.py', 'comfy_api/latest/_io_public.py', 'comfy_api/latest/_input/video_types.py', 'comfy_api/latest/_input_impl/video_types.py', 'comfy_api/latest/_util/video_types.py', 'comfy/samplers.py', 'comfy/sd.py', 'LICENSE', 'requirements.txt']), ('core0130', 'Comfy-Org/ComfyUI', 'v0.13.0', ['comfy_extras/nodes_video.py', 'comfy_extras/nodes_images.py', 'comfy_api/latest/_io.py', 'comfy_api/latest/_input_impl/video_types.py', 'LICENSE', 'requirements.txt']), ('core0240', 'Comfy-Org/ComfyUI', 'v0.24.0', ['comfy_extras/nodes_rebatch.py', 'comfy_api/latest/_io.py', 'LICENSE', 'requirements.txt']), ('frontend', 'Comfy-Org/ComfyUI_frontend', 'v1.48.6', ['package.json', 'pnpm-lock.yaml', 'src/scripts/widgets.ts', 'src/scripts/app.ts', 'src/extensions/core/widgetInputs.ts', 'src/lib/litegraph/src/LGraphNode.ts', 'src/lib/litegraph/src/LGraph.ts', 'src/lib/litegraph/src/subgraph/Subgraph.ts', 'src/lib/litegraph/src/subgraph/SubgraphNode.ts', 'src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts', 'src/lib/litegraph/src/subgraph/SubgraphInput.ts', 'src/lib/litegraph/src/subgraph/SubgraphOutput.ts', 'src/lib/litegraph/LICENSE', 'LICENSE']), ('tt', 'AICoderTudou/ComfyUI-TT-Resolution_selector-Node', 'b69cf75c2ce5f864e3db5301dba46a6b5eeaa8fb', ['__init__.py', 'nodes/resolution_selector.py', 'LICENSE', 'requirements.txt', 'pyproject.toml']), ('kjint', 'kijai/ComfyUI-KJNodes', '60cd6bc1870db94c6eeb05fbe455147a8e91c4e9', ['__init__.py', 'nodes/nodes.py', 'LICENSE', 'requirements.txt', 'pyproject.toml']), ('vhs', 'Kosinkadink/ComfyUI-VideoHelperSuite', '173652f200c49d2908dc1907c187af416b9d6264', ['__init__.py', 'videohelpersuite/nodes.py', 'videohelpersuite/load_video_nodes.py', 'videohelpersuite/utils.py', 'videohelpersuite/documentation.py', 'videohelpersuite/server.py', 'web/js/VHS.core.js', 'LICENSE', 'requirements.txt', 'pyproject.toml']), ('easystart', 'yolain/ComfyUI-Easy-Use', '625efbfa2fc20c31797dfffcbb41a26b6d91ab7b', ['__init__.py', 'py/nodes/logic.py', 'py/libs/utils.py', 'py/libs/cache.py', 'py/libs/log.py', 'web_version/v1/js/easy/easy.js', 'web_version/v1/js/easy/easyDynamicWidgets.js', 'LICENSE', 'requirements.txt', 'pyproject.toml']), ('easyend', 'yolain/ComfyUI-Easy-Use', '595e0738a9e3f8d0d9c4d875461b2d2c9e7559c7', ['__init__.py', 'py/nodes/logic.py', 'py/libs/utils.py', 'py/libs/cache.py', 'py/libs/log.py', 'web_version/v1/js/easy/easy.js', 'web_version/v1/js/easy/easyDynamicWidgets.js', 'LICENSE', 'requirements.txt', 'pyproject.toml'])]
|
|
def fetch(spec):
|
|
key,repo,rev,paths=spec;cache=R/('.local-evidence/a2loop-'+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=100)
|
|
result=subprocess.run(['git','-C',str(cache),'fetch','--filter=blob:none','--depth=1','https://github.com/'+repo+'.git',rev],capture_output=True,timeout=120)
|
|
(F/(key+'-fetch.txt')).write_bytes(result.stdout+result.stderr)
|
|
if result.returncode:raise RuntimeError(result.stderr.decode())
|
|
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)
|
|
(F/(key+'-commit.txt')).write_bytes(cb);(F/(key+'-tag.txt')).write_bytes(git('cat-file','tag'if obj!=commit else'commit',obj));(F/(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,h=meta.split();entries.append(dict(path=path,mode=mode,type=typ,sha=h))
|
|
(F/(key+'-tree.json')).write_text(json.dumps(dict(sha=tree,truncated=False,tree=entries),indent=2)+'\n');out=[];missing=[]
|
|
for f in paths:
|
|
e=next((x for x in entries if x['path']==f),None)
|
|
if not e:missing.append(f);continue
|
|
raw=git('show',commit+':'+f);assert len(raw)<3000000;acquired=utc();name=key+'__'+f.replace('/','__');(F/name).write_bytes(raw)
|
|
assert hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()==e['sha'];verified=utc()
|
|
out.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=sha(raw),git_blob_sha1=e['sha'],acquisition_time=acquired,reverified_at=verified,license_file=key+'__LICENSE'if any(x['path']=='LICENSE'for x in entries)else'未知:准确树无LICENSE;其它许可路径另核',identity_root='.',identity_key=key,transport='filtered Git selected necessary text only',applicability='本图准确声明;逐路径读后实际UTC,未执行源码或获取权重/资产/字体/运行库'))
|
|
(F/(key+'-missing-paths.json')).write_text(json.dumps(missing,indent=2)+'\n');print('FETCH',key,len(out),'missing',missing,flush=True);return out
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=4)as pool:
|
|
futures={pool.submit(fetch,s):s for s in specs}
|
|
for f in concurrent.futures.as_completed(futures):
|
|
try:rows+=f.result()
|
|
except Exception as e:failures.append(dict(spec=futures[f],error=str(e)));print('FAIL',futures[f][0],str(e),flush=True)
|
|
(F/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n')
|
|
(F/'fetch-failures.json').write_text(json.dumps(failures,ensure_ascii=False,indent=2)+'\n')
|