68 lines
6.6 KiB
Plaintext
68 lines
6.6 KiB
Plaintext
实际获取脚本(仅记录,不要求重新联网)
|
|
|
|
|
|
--- fetch-krea-random.py ---
|
|
from pathlib import Path
|
|
import json,hashlib,subprocess,datetime,os,urllib.request,concurrent.futures
|
|
R=Path.cwd();REF=R/'docs/hel-892/krea-random-reference';REF.mkdir(exist_ok=True);now=datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
url='https://api.comfy.org/nodes/comfyui-easy-use'
|
|
with urllib.request.urlopen(url,timeout=20) as res:raw=res.read(500001);assert len(raw)<=500000
|
|
(REF/'easy-registry.json').write_bytes(raw);registry=json.loads(raw);assert registry['repository'].rstrip('/')=='https://github.com/yolain/ComfyUI-Easy-Use'
|
|
(REF/'registry-acquisition.json').write_text(json.dumps(dict(url=url,sha256=hashlib.sha256(raw).hexdigest(),acquisition_time=now,byte_limit=500000,upstream_executed=False),indent=2)+'\n')
|
|
def git(cache,*args):return subprocess.check_output(['git','-C',str(cache),*args],timeout=50)
|
|
def fetch(spec):
|
|
key,repo,rev,files=spec;cache=R/('.local-evidence/krea-random-'+key+'-git');subprocess.run(['git','init','--bare',str(cache)],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL);p=subprocess.run(['git','-C',str(cache),'fetch','--filter=blob:none','--depth=1','https://github.com/'+repo+'.git',rev],capture_output=True,timeout=55);(REF/(key+'-fetch.txt')).write_bytes(p.stdout+p.stderr);assert p.returncode==0,p.stderr
|
|
c=git(cache,'rev-parse','FETCH_HEAD^{commit}').decode().strip();obj=git(cache,'rev-parse','FETCH_HEAD').decode().strip();tree=git(cache,'rev-parse',c+'^{tree}').decode().strip();(REF/(key+'-commit.txt')).write_bytes(git(cache,'cat-file','commit',c));(REF/(key+'-tag.txt')).write_bytes(git(cache,'cat-file','-p',obj));(REF/(key+'-tag.json')).write_text(json.dumps(dict(requested=rev,object=obj,commit=c))+'\n');items=[]
|
|
for row in git(cache,'ls-tree','-r','-z',c).split(b'\0'):
|
|
if not row:continue
|
|
meta,path=row.split(b'\t',1);mode,typ,oid=meta.decode().split();items.append(dict(path=path.decode(),mode=mode,type=typ,sha=oid))
|
|
(REF/(key+'-tree.json')).write_text(json.dumps(dict(sha=tree,truncated=False,tree=items),indent=2)+'\n');(REF/(key+'-text-paths.json')).write_text(json.dumps([e['path'] for e in items if e['path'].endswith(('.py','.js','.ts','.json','.toml','.txt'))],indent=2)+'\n');result=[]
|
|
for f in files:
|
|
ent=next((e for e in items if e['path']==f),None)
|
|
if not ent:continue
|
|
raw=git(cache,'show',c+':'+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=c,tree=tree,tag=rev,url=f'https://raw.githubusercontent.com/{repo}/{c}/{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 selected text only',applicability='仅本图准确独立版本的声明/注册/实现静态参考,不执行或认证目标安装'))
|
|
return result
|
|
front=['package.json','pnpm-lock.yaml','pnpm-workspace.yaml','LICENSE','src/scripts/widgets.ts','src/scripts/app.ts','src/lib/litegraph/src/litegraph.ts','src/lib/litegraph/src/LGraphNode.ts','src/lib/litegraph/src/LGraph.ts','src/lib/litegraph/LICENSE','src/lib/litegraph/src/subgraph/SubgraphNode.ts','src/core/graph/widgets/dynamicWidgets.ts','src/core/graph/widgets/dynamicTypes.ts']
|
|
specs=[('easy','yolain/ComfyUI-Easy-Use','58e077a7435631301cf7443412515cf958e7f3d1',['__init__.py','LICENSE','requirements.txt','pyproject.toml']),('frontend','Comfy-Org/ComfyUI_frontend','v1.47.10',front),('core0342','Comfy-Org/ComfyUI','v0.34.2',['nodes.py','comfy_extras/nodes_seed.py','comfy_extras/nodes_primitive.py','comfy_extras/nodes_logic.py','comfy_api/latest/__init__.py','comfy_api/latest/_io.py','comfy_api/latest/_io_public.py','LICENSE','requirements.txt'])]
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=3) as pool:rows=[e for r in pool.map(fetch,specs) for e in r]
|
|
old=R/'docs/hel-892/krea-n-reference'
|
|
for e0 in json.load(open(old/'sources.json'))['sources']:
|
|
if e0['id']!='core0250':continue
|
|
e=dict(e0)
|
|
for k in ['local_file','license_file','identity_root']:e[k]=os.path.relpath((old/e[k]).resolve(),REF)
|
|
e['reverified_at']=now;e['applicability']='本图内部与根49准确0.25.0必要原文复核;不传播宿主版本';rows.append(e)
|
|
(REF/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n');print('Fetched exact sources',len(rows))
|
|
|
|
--- extend-krea-random.py ---
|
|
from pathlib import Path
|
|
import json,hashlib,subprocess,datetime
|
|
R=Path.cwd();REF=R/'docs/hel-892/krea-random-reference';m=json.load(open(REF/'sources.json'));now=datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
def add(key,files):
|
|
e=next(e for e in m['sources'] if e['id']==key);cache=R/('.local-evidence/krea-random-'+key+'-git');tree=json.load(open(REF/e['identity_root']/(e['identity_key']+'-tree.json')))
|
|
for f in files:
|
|
if any(x['id']==key and x['file']==f for x in m['sources']):continue
|
|
ent=next((x for x in tree['tree'] if x['path']==f),None)
|
|
if not ent:print('MISSING',key,f);continue
|
|
raw=subprocess.check_output(['git','-C',str(cache),'show',e['commit']+':'+f],timeout=45);assert len(raw)<3000000,(f,len(raw));name=key+'__'+f.replace('/','__');(REF/name).write_bytes(raw);m['sources'].append(dict(e,file=f,local_file=name,url=f"https://raw.githubusercontent.com/{e['repo']}/{e['commit']}/{f}",sha256=hashlib.sha256(raw).hexdigest(),git_blob_sha1=ent['sha'],acquisition_time=now,reverified_at=now));print(key,f,len(raw))
|
|
add('easy',['py/nodes/prompt.py','py/nodes/util.py','py/libs/wildcards.py','web_version/v2/easyuse.js','web_version/v1/js/easy/easyDynamicWidgets.js','web_version/v1/js/easy/easyWidgets.js','py/config.py'])
|
|
add('core0342',['comfy_extras/nodes_preview_any.py'])
|
|
# The accurate core0250 requirements are already approved and can be reused verbatim.
|
|
old=R/'docs/hel-892/krea-auto-reference';e0=next(e for e in json.load(open(old/'sources.json'))['sources'] if e['id']=='core0250' and e['file']=='requirements.txt');e=dict(e0)
|
|
import os
|
|
for k in ['local_file','license_file','identity_root']:e[k]=os.path.relpath((old/e[k]).resolve(),REF)
|
|
e['reverified_at']=now;m['sources'].append(e)
|
|
(REF/'sources.json').write_text(json.dumps(m,ensure_ascii=False,indent=2)+'\n')
|
|
|
|
--- fetch-krea-random-log.txt ---
|
|
Fetched exact sources 39
|
|
|
|
--- extend-krea-random-log.txt ---
|
|
easy py/nodes/prompt.py 34877
|
|
easy py/nodes/util.py 15163
|
|
easy py/libs/wildcards.py 17624
|
|
easy web_version/v2/easyuse.js 88552
|
|
easy web_version/v1/js/easy/easyDynamicWidgets.js 49075
|
|
easy web_version/v1/js/easy/easyWidgets.js 12692
|
|
easy py/config.py 22339
|
|
core0342 comfy_extras/nodes_preview_any.py 1468
|