Skip to content

Official Codebase of 3DCodeVerse

Python

gallery: the run-relative link helper is public run_rel — detail.py imported index's private _rel

gaoypeng092a7ab74dba
diff --git a/harness/codeverse3d/addons/gallery/detail.py b/harness/codeverse3d/addons/gallery/detail.py
index 4b806a99..ea1926a2 100644
--- a/harness/codeverse3d/addons/gallery/detail.py
+++ b/harness/codeverse3d/addons/gallery/detail.py
@@ -14,7 +14,7 @@ from urllib.parse import quote
from codeverse3d.addons.gallery.cards import fmt, gallery_figure, tier_tag, verdict_tag
from codeverse3d.addons.gallery.code import CODE_CSS, numbered, read_text, src_files
-from codeverse3d.addons.gallery.index import _rel
+from codeverse3d.addons.gallery.index import run_rel
from codeverse3d.addons.gallery.model import RunEntry
from codeverse3d.addons.gallery.theme import esc, footer, page_shell, top_bar
from codeverse3d.addons.gallery.urls import UrlMaker
@@ -241,7 +241,7 @@ def _renders_panel(entry: RunEntry, urls: UrlMaker, rec: RunRecord) -> str:
figs: list[tuple[str, str]] = []
if rnd is not None and rnd.renders is not None:
for v in rnd.renders.views:
- rel = _rel(ws, v.path)
+ rel = run_rel(ws, v.path)
if rel and (ws.root / rel).is_file():
figs.append((v.name, rel))
figs += [(link.label, link.rel) for link in entry.links
diff --git a/harness/codeverse3d/addons/gallery/index.py b/harness/codeverse3d/addons/gallery/index.py
index 14c684e4..caddcbbc 100644
--- a/harness/codeverse3d/addons/gallery/index.py
+++ b/harness/codeverse3d/addons/gallery/index.py
@@ -54,7 +54,7 @@ def default_roots(base: Path | str = ".") -> list[Path]:
return roots
-def _rel(ws: Workspace, path: Path | str | None) -> str:
+def run_rel(ws: Workspace, path: Path | str | None) -> str:
"""``path`` (rebased into this workspace) as a run-relative posix string, or ``""``
when it is outside the run."""
if not path:
@@ -75,7 +75,7 @@ def _first_file(run_dir: Path, *rels: str) -> str:
def _round_sheet(ws: Workspace, rec: RunRecord, index: int) -> str:
rnd = next((r for r in rec.rounds if r.index == index), None)
if rnd is not None and rnd.renders is not None and rnd.renders.contact_sheet:
- rel = _rel(ws, rnd.renders.contact_sheet)
+ rel = run_rel(ws, rnd.renders.contact_sheet)
if rel and (ws.root / rel).is_file():
return rel
return _first_file(ws.root, f"artifacts/renders/r{index:02d}/sheet.png")
@@ -116,7 +116,7 @@ def hero_view(ws: Workspace, rec: RunRecord, picked: int | None) -> tuple[str, s
return "", "", 0
by_name = {v.name: v for v in views}
chosen = next((by_name[n] for n in HERO_PREFERENCE if n in by_name), views[0])
- rel = _rel(ws, chosen.path)
+ rel = run_rel(ws, chosen.path)
if not rel or not (ws.root / rel).is_file():
return "", "", len(views)
return rel, humanize_view(chosen.name), len(views)
@@ -147,7 +147,7 @@ def entry_links(ws: Workspace, rec: RunRecord | None, picked: int | None) -> lis
if rnd is None:
own = [f"artifacts/{name}"]
else:
- own = [_rel(ws, out / name)] if out is not None else []
+ own = [run_rel(ws, out / name)] if out is not None else []
return _first_file(run, f"deliverable/{name}", *own, *extra)
# the texture pack is a link only when a pass SHIPPED from this round's GLB — a stray file