Skip to content

Commit d588650

Browse files
Hackshavenclaude
authored andcommitted
style: apply ruff formatting to poster build scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Eric Hackathorn <erichackathorn@gmail.com>
1 parent 41463ef commit d588650

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

poster/scripts/build_pdf.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@
2929
# ── Paths ──────────────────────────────────────────────────────────────────
3030
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
3131

32-
HTML_PATH = Path(os.environ.get(
33-
"POSTER_HTML",
34-
REPO_ROOT / "poster" / "html" / "zyra-poster-print.html",
35-
))
36-
PDF_PATH = Path(os.environ.get(
37-
"POSTER_PDF",
38-
REPO_ROOT / "poster" / "html" / "zyra-poster-print.pdf",
39-
))
32+
HTML_PATH = Path(
33+
os.environ.get(
34+
"POSTER_HTML",
35+
REPO_ROOT / "poster" / "html" / "zyra-poster-print.html",
36+
)
37+
)
38+
PDF_PATH = Path(
39+
os.environ.get(
40+
"POSTER_PDF",
41+
REPO_ROOT / "poster" / "html" / "zyra-poster-print.pdf",
42+
)
43+
)
4044

4145
# ── Poster geometry ─────────────────────────────────────────────────────────
4246
# The print CSS defines the poster at exactly 14400 × 10800 CSS pixels,
@@ -50,16 +54,17 @@
5054
# Text and SVG paths are vector in the PDF, so they print crisply at any size.
5155
# PNG/JPEG assets are embedded at their original pixel resolution.
5256

53-
PAPER_W_IN = 48 # inches
54-
PAPER_H_IN = 36 # inches
55-
CSS_PX_W = 14400
56-
CSS_PX_H = 10800
57-
CSS_DPI = 96 # Playwright's assumed CSS px density
58-
SCALE = round((PAPER_W_IN * CSS_DPI) / CSS_PX_W, 6) # ≈ 0.32
57+
PAPER_W_IN = 48 # inches
58+
PAPER_H_IN = 36 # inches
59+
CSS_PX_W = 14400
60+
CSS_PX_H = 10800
61+
CSS_DPI = 96 # Playwright's assumed CSS px density
62+
SCALE = round((PAPER_W_IN * CSS_DPI) / CSS_PX_W, 6) # ≈ 0.32
5963

6064

6165
# ── Dependency bootstrap ────────────────────────────────────────────────────
6266

67+
6368
def _ensure_playwright() -> None:
6469
"""Install the playwright Python package and Chromium if missing."""
6570
try:
@@ -73,20 +78,24 @@ def _ensure_playwright() -> None:
7378
# Verify the Chromium browser binary exists; install if not.
7479
try:
7580
from playwright.sync_api import sync_playwright
81+
7682
with sync_playwright() as pw:
7783
exe = pw.chromium.executable_path
7884
if not Path(exe).exists():
7985
raise FileNotFoundError(exe)
8086
except Exception:
81-
print("Chromium browser not found — running 'playwright install chromium' …",
82-
flush=True)
87+
print(
88+
"Chromium browser not found — running 'playwright install chromium' …",
89+
flush=True,
90+
)
8391
subprocess.check_call(
8492
[sys.executable, "-m", "playwright", "install", "chromium"],
8593
)
8694

8795

8896
# ── Main build ──────────────────────────────────────────────────────────────
8997

98+
9099
def build_pdf() -> None:
91100
_ensure_playwright()
92101

@@ -111,7 +120,7 @@ def build_pdf() -> None:
111120
with sync_playwright() as pw:
112121
browser = pw.chromium.launch(
113122
args=[
114-
"--no-sandbox", # required in WSL / container
123+
"--no-sandbox", # required in WSL / container
115124
"--disable-setuid-sandbox",
116125
"--disable-dev-shm-usage", # avoids /dev/shm crashes in containers
117126
"--font-render-hinting=none", # crisper font rendering in PDF
@@ -149,6 +158,7 @@ def build_pdf() -> None:
149158
def _open_file(path: Path) -> None:
150159
"""Best-effort: open the PDF in the system viewer."""
151160
import shutil
161+
152162
for cmd in ("xdg-open", "open", "start"):
153163
if shutil.which(cmd):
154164
subprocess.Popen([cmd, str(path)])

poster/scripts/build_poster.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
PRINT_OUTPUT = OUTPUT_DIR / "zyra-poster-print.html"
2727

2828
# Sections to exclude from each layout
29-
WEB_EXCLUDE = {"sec-09-gallery"}
29+
WEB_EXCLUDE = {"sec-09-gallery"}
3030
PRINT_EXCLUDE = {"sec-09-gallery"}
3131

3232

@@ -67,7 +67,9 @@ def build() -> None:
6767
body_open = _read(SECTIONS_DIR / "_body-open.html")
6868
footer = _read(SECTIONS_DIR / "_footer.html")
6969

70-
web_sections = [(sf, _read(sf)) for sf in section_files if sf.stem not in WEB_EXCLUDE]
70+
web_sections = [
71+
(sf, _read(sf)) for sf in section_files if sf.stem not in WEB_EXCLUDE
72+
]
7173
web_parts = [head, styles, body_open, *[html for _, html in web_sections], footer]
7274
_write(
7375
WEB_OUTPUT,

0 commit comments

Comments
 (0)