refactor: move the site image tools into sitegen

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 14:59:03 +01:00
1 parent 0b91bc9e37
commit f158f1d485
14 files changed
+561 -477

No files matched your search

+3
View File
@@ -121,6 +121,9 @@ COMMANDS = {
"schemas/romfolders.py", "schemas/games.py", "schemas/run.py",
),
"site_insights.py": ("sitegen/insights.py",),
"fetch_site_images.py": ("sitegen/imagefetch.py", "sitegen/imagenormalize.py"),
"make_site_icons.py": ("sitegen/brand.py", "sitegen/chromium.py"),
"make_og_cards.py": ("sitegen/ogcards.py", "sitegen/chromium.py"),
"generate_readme.py": ("sitegen/readme.py",),
"make_demo.py": (
"sitegen/demovariants.py", "sitegen/democard.py", "sitegen/demosession.py",
+2 -2
View File
@@ -39,8 +39,8 @@ SIBLING_IMPORTS: dict[str, frozenset[str]] = {
"romrecipes": frozenset(),
# The site prints the recipe counts and the dump-catalog coverage report
# those two packages compute, serves the handheld launchers and prints the
# CI checks.
"sitegen": frozenset({"acquire", "packs", "romrecipes", "installer_build", "devtools"}),
# CI checks. The logo copier downloads through the scrapers' fetch_bytes.
"sitegen": frozenset({"acquire", "packs", "romrecipes", "installer_build", "devtools", "scraper"}),
# The record names its packs as the pack builder does.
"release": frozenset({"packs"}),
# The launcher archives are written by the pack member writer.
+2 -3
View File
@@ -65,9 +65,8 @@ class SuiteWithoutJsonschema(unittest.TestCase):
# is committed under docs_assets/ and the build only reads it, so the build
# keeps to the standard library and pyyaml.
MAINTENANCE_TOOLS = {
"fetch_site_images.py": "PIL",
"make_og_cards.py": "playwright",
"make_site_icons.py": "playwright",
"imagenormalize.py": "PIL",
"chromium.py": "playwright",
}
+2 -2
View File
@@ -721,7 +721,7 @@ class LogosAtTheirDisplaySize(unittest.TestCase):
if path.suffix == ".webp":
self.assertEqual(_webp_size(path.read_bytes()), (LOGO_PIXELS, LOGO_PIXELS))
self.assertEqual(sorted(p.name for p in LOGOS.glob("*.png")), [])
script = _read(REPO_ROOT / "scripts" / "fetch_site_images.py")
script = script_source("fetch_site_images.py")
self.assertIn(f"LOGO_SIZE = {LOGO_PIXELS}", script)
self.assertIn('square_image(\n data, LOGO_SIZE, "WEBP"', script)
@@ -1069,7 +1069,7 @@ class LogosAtTheirWeight(unittest.TestCase):
self.assertLessEqual(max(width, height), 80)
def test_the_fetcher_writes_them_so(self):
script = _read(REPO_ROOT / "scripts" / "fetch_site_images.py")
script = script_source("fetch_site_images.py")
self.assertIn('minify_svg(shrink_embedded(safe_svg(data, url)))', script)
+4 -3
View File
@@ -121,9 +121,10 @@ class TheCollectionDoesNotDependOnTheWorkingDirectory(unittest.TestCase):
self.assertEqual(siteinputs.bios_dir({"bios_dir": "/abs/bios"}), Path("/abs/bios"))
def test_the_image_tools_do_not_load_the_page_generator(self) -> None:
for module in ("make_og_cards.py", "fetch_site_images.py", "sitegen/render.py"):
with self.subTest(module=module):
source = (REPO_ROOT / "scripts" / module).read_text(encoding="utf-8")
tools = ("make_og_cards.py", "fetch_site_images.py", "make_site_icons.py")
for path in (*(p for tool in tools for p in script_paths(tool)), SCRIPTS / "sitegen" / "render.py"):
with self.subTest(module=path.name):
source = path.read_text(encoding="utf-8")
self.assertNotIn("from generate_site import", source)
+7 -6
View File
@@ -54,7 +54,8 @@ from sitegen import systemsindex
from sitegen import render as siterender
from model import systemnames
from packs.crossref import FileConsumers
import make_og_cards
from sitegen import ogcards
from sitegen.diagrams import wrap
from core.anchors import toc_slug
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -585,15 +586,15 @@ class ArcadeIsItsOwnGroup(unittest.TestCase):
class EachManufacturerHasItsCard(unittest.TestCase):
def test_a_tagline_holds_three_lines_and_counts_the_rest(self) -> None:
names = [f"Console number {n}" for n in range(40)]
text = make_og_cards.consoles_tagline(names)
text = ogcards.consoles_tagline(names)
self.assertRegex(text, r" and \d+ more$")
lines = make_og_cards.wrap(text, make_og_cards.TAGLINE_WIDTH, make_og_cards.TAGLINE_SIZE)
self.assertLessEqual(len(lines), make_og_cards.TAGLINE_LINES)
self.assertEqual(make_og_cards.consoles_tagline(["Saturn", "Dreamcast"]),
lines = wrap(text, ogcards.TAGLINE_WIDTH, ogcards.TAGLINE_SIZE)
self.assertLessEqual(len(lines), ogcards.TAGLINE_LINES)
self.assertEqual(ogcards.consoles_tagline(["Saturn", "Dreamcast"]),
"BIOS files for Dreamcast and Saturn")
def test_every_manufacturer_page_has_a_committed_card(self) -> None:
cards = make_og_cards.system_cards()
cards = ogcards.system_cards()
missing = [key for key in cards
if not (REPO_ROOT / "docs_assets" / "og" / f"{key}.png").is_file()]
self.assertEqual(missing, [], "run python scripts/make_og_cards.py --only systems")