52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
"Acquire only supporting exact-tree source/registration/license text."
|
|
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
REF = Path(__file__).resolve().parent.parent / "zimage-generalb-reference"
|
|
|
|
|
|
def main():
|
|
data = json.loads((REF / "sources.json").read_bytes())
|
|
additions = {
|
|
"rgold": ["py/context_utils.py", "web/comfyui/display_any.js"],
|
|
"rgnew": ["py/context_utils.py", "py/power_prompt_utils.py"],
|
|
"frontend": ["src/lib/litegraph/LICENSE", "src/lib/litegraph/src/LGraph.ts"],
|
|
}
|
|
absent = []
|
|
for key, files in additions.items():
|
|
prototype = next((e for e in data["sources"] if e["id"] == key))
|
|
tree = json.loads((REF / (key + "-tree.json")).read_bytes())["tree"]
|
|
for file in files:
|
|
if any((e["id"] == key and e["file"] == file for e in data["sources"])):
|
|
continue
|
|
entry = next((e for e in tree if e["path"] == file), None)
|
|
if entry is None:
|
|
absent.append([key, file])
|
|
continue
|
|
cache = ROOT / ".local-evidence" / ("zimage-generalb-" + key + "-git")
|
|
raw = subprocess.check_output(
|
|
["git", "-C", str(cache), "show", prototype["commit"] + ":" + file]
|
|
)
|
|
name = key + "__" + file.replace("/", "__")
|
|
(REF / name).write_bytes(raw)
|
|
e = dict(prototype)
|
|
e.update(
|
|
file=file,
|
|
local_file=name,
|
|
url=f"https://raw.githubusercontent.com/{e['repo']}/{e['commit']}/{file}",
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=entry["sha"],
|
|
)
|
|
data["sources"].append(e)
|
|
(REF / "supporting-absent.json").write_text(json.dumps(absent, indent=2) + "\n")
|
|
(REF / "sources.json").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n")
|
|
print("PASS selected supporting exact text", absent)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|