44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""Rebind existing exact text, hashes and Git identities to this graph only."""
|
|
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
REF = ROOT / "docs/hel-892/flux2-dual-reference"
|
|
|
|
|
|
def main():
|
|
rows = []
|
|
for origin, key, identity, allowed in [
|
|
("flux2-real-reference", "core", "flux2-img-reference", None),
|
|
("flux2-real-reference", "frontend", "flux2-real-reference", None),
|
|
("flux2-reference", "primitive", "flux2-reference", {"nodes.py", "LICENSE"}),
|
|
]:
|
|
parent = REF.parent / origin
|
|
for old in json.loads((parent / "sources.json").read_bytes())["sources"]:
|
|
if old["id"] != key or allowed is not None and old["file"] not in allowed:
|
|
continue
|
|
e = dict(old)
|
|
path = (parent / e["local_file"]).resolve()
|
|
assert hashlib.sha256(path.read_bytes()).hexdigest() == e["sha256"]
|
|
e["local_file"] = os.path.relpath(path, REF)
|
|
e["license_file"] = os.path.relpath(REF.parent / identity / e["license_file"], REF)
|
|
assert (REF / e["license_file"]).is_file()
|
|
e["identity_root"] = "../" + identity
|
|
e["identity_key"] = key
|
|
e["id"] = "negative" if key == "primitive" else key
|
|
e["applicability"] = (
|
|
"双图编辑独立绑定:136负向为0.9.1,其他core0.8.2及图级frontend1.40.0;同字节静态参考,安装与恢复未知"
|
|
)
|
|
rows.append(e)
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": rows}, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print("PASS rebound", len(rows), "necessary texts; no acquisition or upstream execution")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|