92 lines
3.1 KiB
Python
92 lines
3.1 KiB
Python
"Local byte/blob verification of exact textual originals, no plugin import."
|
|
|
|
import hashlib
|
|
import json
|
|
|
|
from build_definition import OUT, REF, build
|
|
|
|
|
|
def main():
|
|
pins = json.loads((REF / "pins.json").read_bytes())
|
|
entries = []
|
|
for key, pin in pins.items():
|
|
tree = json.loads((REF / (key + "-tree.json")).read_bytes())
|
|
assert tree["sha"] == pin["commit"] and not tree["truncated"]
|
|
by_name = {e["path"]: e for e in tree["tree"]}
|
|
for local in sorted(REF.glob(key + "__*")):
|
|
path = next(p for p in by_name if key + "__" + p.replace("/", "__") == local.name)
|
|
raw = local.read_bytes()
|
|
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
|
|
assert blob == by_name[path]["sha"]
|
|
entries.append(
|
|
dict(
|
|
local_file=local.name,
|
|
path=path,
|
|
commit=pin["commit"],
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=blob,
|
|
)
|
|
)
|
|
release = json.loads((REF / "layer-registry-2.0.38.json").read_bytes())
|
|
assert (
|
|
release["version"] == "2.0.38" and release["id"] == "db305def-250b-448d-88b6-e43acbeb03af"
|
|
)
|
|
assert 'version = "2.0.38"' in (REF / "layer__pyproject.toml").read_text()
|
|
for local in sorted(REF.glob("layer__*")):
|
|
raw = local.read_bytes()
|
|
entries.append(
|
|
dict(
|
|
local_file=local.name,
|
|
registry_version="2.0.38",
|
|
git_commit_binding="unknown",
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
)
|
|
)
|
|
block = build()
|
|
graph = json.loads((OUT.parents[2] / block["source_path"]).read_bytes())
|
|
(OUT / "source-graphs.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
source_path=block["source_path"],
|
|
raw_sha256=block["source_sha256"],
|
|
canonical_sha256=block["canonical_sha256"],
|
|
nodes=graph["nodes"],
|
|
links=graph["links"],
|
|
extra=graph["extra"],
|
|
saved_positions=56,
|
|
scalar_positions=56,
|
|
notes=0,
|
|
missing_widgets=[12, 14],
|
|
empty_widgets=[1, 16, 17, 7, 8, 9, 15, 11, 13],
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
for e in block["sources"]:
|
|
raw = (OUT / e["local_file"]).read_bytes()
|
|
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
|
|
(OUT / "source-check.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
local_file_base="docs/hel-892/watermark-reference",
|
|
files=entries,
|
|
citations=len(block["sources"]),
|
|
no_upstream_execution=True,
|
|
no_assets_fetched=True,
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print(
|
|
f"PASS {len(entries)} exact local originals and "
|
|
f"{len(block['sources'])} citations; no upstream import"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|