Files
aigc-home/docs/hel-892/flux2-print-document-evidence/bind_sources.py
T
2026-10-31 07:59:52 +08:00

45 lines
1.7 KiB
Python

"""Rebind existing exact text to this graph; no downloads or upstream execution."""
import hashlib
import json
import os
from pathlib import Path
ROOT = Path(__file__).resolve().parents[3]
REF = ROOT / "docs/hel-892/flux2-print-reference"
def main():
rows = []
for stem, keys in [
("flux2-img", {"core", "lora", "tt", "kj"}),
("flux2-restore", {"frontend"}),
]:
origin = REF.parent / (stem + "-reference")
for old in json.loads((origin / "sources.json").read_bytes())["sources"]:
if old["id"] not in keys:
continue
e = dict(old)
e.setdefault("identity_root", ".")
e.setdefault("identity_key", e["id"])
for key in ["local_file", "identity_root", "license_file"]:
if key == "license_file" and e["id"] == "tt":
continue
e[key] = os.path.relpath((origin / e[key]).resolve(), REF)
e["applicability"] = (
"仅印花提取本图:core0.8.2、LoRA0.21.1、frontend1.36.13、TT完整提交与146 KJ1.3.9。"
"147 ImageConcanate缺身份,仅KJ1.3.9参考假设;148 Preview缺身份,仅core0.8.2假设。"
"149宿主/Label身份、UE/tab恢复、安装未知;TT许可未知;完整KJ包SHA/Git未知。"
)
assert hashlib.sha256((REF / e["local_file"]).read_bytes()).hexdigest() == e["sha256"]
rows.append(e)
(REF / "sources.json").write_text(
json.dumps({"sources": rows, "upstream_executed": False}, ensure_ascii=False, indent=2)
+ "\n"
)
print("PASS", len(rows), "static original texts rebound")
if __name__ == "__main__":
main()