#!/usr/bin/env python3 from __future__ import annotations import csv import html import json import os from pathlib import Path REPO_ROOT = Path("/workspace/SchemID") SOURCE_ROOT = REPO_ROOT / "derived" / "Source" ROWS_PATH = SOURCE_ROOT / "metadata" / "rows.jsonl" VIS_ROOT = SOURCE_ROOT / "visuals" CSV_PATH = VIS_ROOT / "four_column_table.csv" HTML_PATH = VIS_ROOT / "four_column_table.html" def rel_to_visuals(path: Path) -> str: return os.path.relpath(path, VIS_ROOT) def image_rel(path_str: str) -> str: path = Path(path_str) return rel_to_visuals(path) def main() -> None: VIS_ROOT.mkdir(parents=True, exist_ok=True) rows: list[dict[str, str]] = [] with ROWS_PATH.open() as handle: for line in handle: raw = json.loads(line) source_payload = json.loads(raw["Source"]) original_path = Path(raw["Circuit generated image"]) no_text_path = Path(raw["Circuit Generated image with no text"]) eps_path = SOURCE_ROOT / source_payload["eps_path"] row = { "Circuit Generation Code": raw["Circuit Generation Code"], "Circuit generated image": image_rel(str(original_path)), "Circuit Generated image with no text": image_rel(str(no_text_path)), "Source": json.dumps(source_payload, sort_keys=True), "Code File": rel_to_visuals(eps_path), } rows.append(row) with CSV_PATH.open("w", newline="") as handle: writer = csv.DictWriter( handle, fieldnames=[ "Circuit Generation Code", "Circuit generated image", "Circuit Generated image with no text", "Source", "Code File", ], ) writer.writeheader() writer.writerows(rows) parts = [ "", "", "
", "", "", "| Circuit Generation Code | Circuit generated image | Circuit Generated image with no text | Source |
|---|---|---|---|
"
f"{code_text}"
f"File: {code_file} "
" | "
),
(
"" f"" f"" " | " ), ( "" f"" f"" " | " ), f"{source_text} | ",
"