Files
aigc-home/docs/hel-892/flux2-inpaint-document-evidence/index_sources.py
T

63 lines
2.2 KiB
Python

"Pinned necessary text only; verify Git objects, never import upstream."
import datetime
import hashlib
import json
import urllib.request
from pathlib import Path
REF = Path(__file__).resolve().parent.parent / "flux2-inpaint-reference"
OLD = REF.parent / "flux2-img-reference"
def main():
rows = []
for e in json.loads((OLD / "sources.json").read_bytes())["sources"]:
rows.append(
dict(
e,
local_file="../flux2-img-reference/" + e["local_file"],
license_file="../flux2-img-reference/" + e["license_file"],
applicability="本局部重绘图独立绑定;准确版本参考,不证明目标恢复",
)
)
base = next(e for e in rows if e["id"] == "lora")
tree = json.loads((OLD / "lora-tree.json").read_bytes())
for file in [
"folder_paths.py",
"node_helpers.py",
"comfy/sd.py",
"comfy_api/latest/_input_impl/__init__.py",
"comfy_api/latest/_input_impl/video_types.py",
]:
name = "inpaint__" + file.replace("/", "__")
url = f"https://raw.githubusercontent.com/{base['repo']}/{base['commit']}/{file}"
p = REF / name
if not p.exists():
with urllib.request.urlopen(url, timeout=30) as r:
p.write_bytes(r.read())
raw = p.read_bytes()
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
assert next(e["sha"] for e in tree["tree"] if e["path"] == file) == blob
rows.append(
dict(
base,
file=file,
local_file=name,
url=url,
sha256=hashlib.sha256(raw).hexdigest(),
git_blob_sha1=blob,
acquisition_time=datetime.datetime.fromtimestamp(
p.stat().st_mtime, datetime.timezone.utc
).isoformat(),
transport="HTTPS exact commit text matched exact Git tree; no upstream execution",
)
)
(REF / "sources.json").write_text(
json.dumps({"sources": rows}, ensure_ascii=False, indent=2) + "\n"
)
if __name__ == "__main__":
main()