87 lines
3.1 KiB
Python
87 lines
3.1 KiB
Python
"""Fetch only exact textual sources, never import upstream implementations."""
|
|
|
|
import hashlib
|
|
import json
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
OUT = Path(__file__).resolve().parent
|
|
REF = OUT.parent / "storyboard-reference"
|
|
PINS = {
|
|
"kj": (
|
|
"kijai/ComfyUI-KJNodes",
|
|
"79f529a84a8c20fe5dcdfa984c6be7a94102c014",
|
|
["__init__.py", "nodes/nodes.py", "nodes/image_nodes.py", "LICENSE"],
|
|
),
|
|
"layer": (
|
|
"chflame163/ComfyUI_LayerStyle",
|
|
"3b17c7f488006c872f4cb3d6b37029a9464f1d7b",
|
|
["__init__.py", "py/purge_vram.py", "LICENSE"],
|
|
),
|
|
"math": (
|
|
"pythongosssss/ComfyUI-Custom-Scripts",
|
|
"f2838ed5e59de4d73cde5c98354b87a8d3200190",
|
|
["__init__.py", "py/math_expression.py", "LICENSE"],
|
|
),
|
|
}
|
|
|
|
|
|
def fetch(url):
|
|
with urllib.request.urlopen(
|
|
urllib.request.Request(url, headers={"User-Agent": "HEL-892-text-review"}), timeout=35
|
|
) as r:
|
|
return r.read()
|
|
|
|
|
|
def main():
|
|
entries = []
|
|
for key, (repo, commit, files) in PINS.items():
|
|
tree = fetch(f"https://api.github.com/repos/{repo}/git/trees/{commit}?recursive=1")
|
|
(REF / (key + "-tree.json")).write_bytes(tree)
|
|
t = json.loads(tree)
|
|
assert t["sha"] == commit and not t["truncated"]
|
|
blobs = {x["path"]: x["sha"] for x in t["tree"] if x["type"] == "blob"}
|
|
for file in files:
|
|
if file not in blobs:
|
|
print("MISSING", key, file, [p for p in blobs if "purge" in p.lower()])
|
|
continue
|
|
url = f"https://raw.githubusercontent.com/{repo}/{commit}/{file}"
|
|
raw = fetch(url)
|
|
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
|
|
assert blob == blobs[file]
|
|
name = key + "__" + file.replace("/", "__")
|
|
(REF / name).write_bytes(raw)
|
|
entries.append(
|
|
dict(
|
|
id=key,
|
|
file=file,
|
|
local_file=name,
|
|
url=url,
|
|
commit=commit,
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=blob,
|
|
)
|
|
)
|
|
# Reuse exact VHS1.7.7 members only, including package hash and unknown Git binding.
|
|
for e in json.loads((OUT.parent / "reverse-reference/sources.json").read_bytes())["sources"]:
|
|
if e["id"] == "vhs":
|
|
entries.append({**e, "local_file": "../reverse-reference/" + e["local_file"]})
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": entries}, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
for id, version in [("comfyui-easy-use", "1.3.4"), ("comfy-mtb", "0.5.4")]:
|
|
url = f"https://api.comfy.org/nodes/{id}/versions/{version}"
|
|
try:
|
|
raw = fetch(url)
|
|
(REF / (id + "-version.json")).write_bytes(raw)
|
|
print(id, raw.decode()[:1200])
|
|
except Exception as exc:
|
|
print(id, type(exc).__name__, str(exc))
|
|
raw = fetch("https://api.github.com/repos/Comfy-Org/ComfyUI/git/ref/tags/v0.6.0")
|
|
(REF / "core-tag.json").write_bytes(raw)
|
|
print("core", raw.decode())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|