Files
aigc-home/docs/hel-892/zimage-outpaint-document-evidence/finish_sources.py
T

53 lines
1.8 KiB
Python

"""Merge independently acquired exact release and Git text, preserve unknown licenses."""
import json
from pathlib import Path
REF = Path(__file__).resolve().parent.parent / "zimage-outpaint-reference"
def main():
rows = [
e
for e in json.loads((REF / "sources.json").read_bytes())["sources"]
if e["id"] not in ["seedpkg", "litegraph"]
]
rows += json.loads((REF / "seedpkg-sources.json").read_bytes())["sources"]
for original in json.loads((REF.parent / "zimage-reference/sources.json").read_bytes())[
"sources"
]:
if original["id"] != "litegraph":
continue
e = original.copy()
for k in ["local_file", "license_file", "identity_root"]:
e[k] = "../zimage-reference/" + e[k]
e["applicability"] = (
"本图frontend1.23.0同树锁对应0.15.15包;只复核成员SHA,整包摘要沿用、Git绑定未知"
)
rows.append(e)
for e in rows:
if not (REF / e["license_file"]).is_file():
candidate = next(
(
x
for x in rows
if x["id"] == e["id"]
and x["file"].lower().split("/")[-1] in ["license", "license.txt", "license.md"]
),
None,
)
e["license_file"] = (
candidate["local_file"]
if candidate
else "未知:准确树/必要发布成员缺许可文本,不推定授权"
)
e.setdefault("tag", e["commit"])
(REF / "sources.json").write_text(
json.dumps(dict(sources=rows), ensure_ascii=False, indent=2) + "\n"
)
print("PASS assembled", len(rows), "exact text source rows")
if __name__ == "__main__":
main()