Files
aigc-home/docs/hel-892/zimage-inpaint-document-evidence/assemble_sources.py
T
2026-10-31 10:00:20 +08:00

77 lines
3.0 KiB
Python

"Reuse pinned necessary text; rebind each identity to this graph without imports."
import hashlib
import json
import zipfile
from pathlib import Path
OUT = Path(__file__).resolve().parent
REF = OUT.parent / "zimage-inpaint-reference"
def main():
rows = json.loads((REF / "new-sources.json").read_bytes())["sources"]
selections = {
"zimage-qwen-reference": {"load", "patch", "frontend"},
"zimage-reference": {"core"},
"flux2-img-reference": {"rgthree"},
"simple-vfi-reference": {"essentials"},
}
for folder, ids in selections.items():
root = REF.parent / folder
for original in json.loads((root / "sources.json").read_bytes())["sources"]:
if original["id"] not in ids:
continue
if original["id"] == "core" and original["file"] not in [
"nodes.py",
"folder_paths.py",
"LICENSE",
]:
continue
if original["id"] == "essentials" and original["file"] == "image.py":
continue
e = original.copy()
e.setdefault("license_file", e["id"] + "__LICENSE")
assert hashlib.sha256((root / e["local_file"]).read_bytes()).hexdigest() == e["sha256"]
e["local_file"] = "../" + folder + "/" + e["local_file"]
if not e["license_file"].startswith("未知"):
e["license_file"] = "../" + folder + "/" + e["license_file"]
if "git_blob_sha1" in e:
e["identity_root"] = "../" + folder + "/" + e.get("identity_root", ".")
e["identity_key"] = e.get("identity_key", e["id"])
else:
e["identity_root"] = "../" + folder
e.setdefault("tag", "1.1.0")
e.setdefault("tree", "发布包;Git tree未知")
e["applicability"] = (
"本图独立声明版本绑定;旧采集时间保留,本批重核字节;不证明安装或未知节点身份"
)
rows.append(e)
root = REF.parent / "simple-vfi-reference"
archive = root / "essentials-source.tar.gz"
raw = archive.read_bytes()
assert hashlib.sha256(raw).hexdigest() == (
"ebd99d7463c7be7f13cf8ddd064d6e9bda151199c267b0b9cb27ff634ccb6840"
)
# URL suffix says tar.gz, original bytes are ZIP. Read only the missing text member.
with zipfile.ZipFile(archive) as z:
text = z.read("mask.py")
info = z.getinfo("mask.py")
(REF / "essentials__mask.py").write_bytes(text)
e = next(e for e in rows if e["id"] == "essentials").copy()
e.update(
file="mask.py",
local_file="essentials__mask.py",
sha256=hashlib.sha256(text).hexdigest(),
member_crc32=info.CRC,
)
rows.append(e)
(REF / "sources.json").write_text(
json.dumps(dict(sources=rows), ensure_ascii=False, indent=2) + "\n"
)
print("PASS source assembly", len(rows), "essential exact archived ZIP; mask member only")
if __name__ == "__main__":
main()