64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
"""Read exact release archive members as text; no install or execution."""
|
|
|
|
import hashlib
|
|
import io
|
|
import json
|
|
import urllib.request
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
REF = Path(__file__).resolve().parent.parent / "resize-compare-reference"
|
|
|
|
|
|
def main():
|
|
entries = json.loads((REF / "sources.json").read_bytes())["sources"]
|
|
entries = [e for e in entries if e["id"] not in ["impact", "rgthree"]]
|
|
for key in ["impact", "rgthree"]:
|
|
meta = json.loads((REF / f"{key}-registry.json").read_bytes())
|
|
with urllib.request.urlopen(meta["downloadUrl"], timeout=40) as r:
|
|
raw = r.read(15000001)
|
|
assert len(raw) < 15000000
|
|
(REF / f"{key}-source.zip").write_bytes(raw)
|
|
sha = hashlib.sha256(raw).hexdigest()
|
|
with zipfile.ZipFile(io.BytesIO(raw)) as z:
|
|
names = z.namelist()
|
|
(REF / f"{key}-members.json").write_text(json.dumps(names, indent=2) + "\n")
|
|
wanted = (
|
|
["__init__.py", "modules/impact/logics.py", "LICENSE.txt", "LICENSE"]
|
|
if key == "impact"
|
|
else [
|
|
"__init__.py",
|
|
"py/display_any.py",
|
|
"py/constants.py",
|
|
"web/comfyui/display_any.js",
|
|
"py/utils.py",
|
|
"LICENSE",
|
|
]
|
|
)
|
|
for f in wanted:
|
|
if f not in names:
|
|
continue
|
|
b = z.read(f)
|
|
name = key + "__" + f.replace("/", "__")
|
|
(REF / name).write_bytes(b)
|
|
entries.append(
|
|
dict(
|
|
id=key,
|
|
file=f,
|
|
local_file=name,
|
|
url=meta["downloadUrl"],
|
|
commit="发布包SHA256:" + sha,
|
|
git_commit_binding="unknown",
|
|
package_sha256=sha,
|
|
sha256=hashlib.sha256(b).hexdigest(),
|
|
)
|
|
)
|
|
print(key, "SHA256", sha, "selected", [e["file"] for e in entries if e["id"] == key])
|
|
(REF / "sources.json").write_text(
|
|
json.dumps(dict(sources=entries), ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|