Files
aigc-home/docs/hel-892/animate-mask-document-evidence/acquire-mask.py.txt
T

74 lines
7.4 KiB
Plaintext

"""Batch163 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/animate-mask-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('animate-reference','kj-00da1910');reuse('animate-reference','kj-623b5913')
reuse('animate-reference','easy134',files=['__init__.py','py/nodes/logic.py','py/libs/utils.py','pyproject.toml','requirements.txt','LICENSE','web_version/v2/easyuse.js','web_version/v2/assets/extensions-D7E6yQLT.js'])
reuse('qwen21-poses-reference','rgthree')
specs=[
('core0359','Comfy-Org/ComfyUI','v0.3.59',['nodes.py','comfy_extras/nodes_wan.py','comfy_extras/nodes_video.py','comfy_extras/nodes_images.py','comfy_extras/nodes_mask.py','comfy_extras/nodes_primitive.py','comfy_extras/nodes_model_advanced.py','comfy/samplers.py','comfy/sd.py','comfy_api/latest/_io.py','LICENSE','requirements.txt']),
('core0360','Comfy-Org/ComfyUI','v0.3.60',['comfy_extras/nodes_video.py','LICENSE','requirements.txt']),
('core051','Comfy-Org/ComfyUI','v0.5.1',['LICENSE','requirements.txt']),
('frontend','Comfy-Org/ComfyUI_frontend','v1.32.1',['package.json','package-lock.json','src/scripts/widgets.ts','src/scripts/app.ts','src/extensions/core/widgetInputs.ts','src/extensions/core/rerouteNode.ts','LICENSE']),
('sam2','kijai/ComfyUI-segment-anything-2','c59676b008a76237002926f684d0ca3a9b29ac54',['__init__.py','nodes.py','sam2/build_sam.py','requirements.txt','pyproject.toml','LICENSE']),
('dw','Fannovel16/comfyui_controlnet_aux','59b027e088c1c8facf7258f6e392d16d204b4d27',['__init__.py','node_wrappers/dwpose.py','utils.py','src/custom_controlnet_aux/dwpose/__init__.py','src/custom_controlnet_aux/dwpose/wholebody.py','requirements.txt','pyproject.toml','LICENSE']),
('kjpoints','kijai/ComfyUI-KJNodes','e81f33508b0821ea2f53f4f46a833fa6215626bd',['__init__.py','nodes/mask_nodes.py','nodes/image_nodes.py','web/js/points_editor.js','requirements.txt','pyproject.toml','LICENSE']),
('kjconstant','kijai/ComfyUI-KJNodes','16cbf238a74cac17082d6888bc8934899c850645',['__init__.py','nodes/nodes.py','requirements.txt','pyproject.toml','LICENSE']),
('gguf','city96/ComfyUI-GGUF','02dac863ee1b65852d39ce6b9180bf5d9bc8a636',['__init__.py','nodes.py','loader.py','ops.py','dequant.py','requirements.txt','pyproject.toml','LICENSE'])]
def fetch(spec):
key,repo,rev,paths=spec;cache=R/('.local-evidence/mask-'+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')
g=json.loads((R/'example_ComfyUI_workflows/6-动作迁移/Wan2.2_Animate_人物遮罩替换(官流整理).json').read_bytes())
for cnr in sorted({n.get('properties',{}).get('cnr_id')for n in g['nodes']}-{None}):
try:
u='https://api.comfy.org/nodes/'+cnr
with urllib.request.urlopen(u,timeout=25)as response:b=response.read()
(F/('registry-'+cnr+'.json')).write_bytes(b);print('REGISTRY',cnr,json.loads(b).get('repository'),flush=True)
except Exception as e:print('REGISTRYFAIL',cnr,str(e),flush=True)
print('TOTAL',len(rows),flush=True)