refactor: split the emulator card module

File badges and the romset and version rows get modules of their own.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 06:02:03 +01:00
1 parent 9cdca28e52
commit 2786b3be34
13 files changed
+364 -352

No files matched your search

+1
View File
@@ -82,6 +82,7 @@ COMMANDS = {
"sitegen/systemsindex.py",
"sitegen/provenance.py", "sitegen/fields.py", "sitegen/consolecards.py",
"sitegen/startwith.py", "sitegen/systempages.py", "sitegen/emulatorcards.py",
"sitegen/filebadges.py", "sitegen/emulatormetadata.py",
"sitegen/emulatorpage.py", "sitegen/gaps.py", "sitegen/crossref.py", "sitegen/reference.py",
"sitegen/whichpack.py", "sitegen/nav.py", "sitegen/build.py", "sitegen/coverage.py",
"sitegen/extraction.py", "sitegen/releasepacks.py", "sitegen/archivecounts.py",
+2 -2
View File
@@ -1049,13 +1049,13 @@ class FaqRegressions(unittest.TestCase):
# Typed by hand, the table and the prose under it kept MAME 0.160
# and FinalBurn Neo 1.0.0.2, versions no source at the pins states,
# and the test holding them to the profiles kept the errors in step.
from sitegen import emulatorcards
from sitegen import emulatormetadata
from model.profiles import load_emulator_profiles
profiles = load_emulator_profiles(str(ROOT / "emulators"), skip_aliases=False)
page = (ROOT / "wiki" / "technical-faq.md").read_text(encoding="utf-8")
self.assertEqual(
page, emulatorcards.with_romset_table(page, profiles),
page, emulatormetadata.with_romset_table(page, profiles),
"wiki/technical-faq.md romset table is stale: run scripts/generate_site.py",
)
prose = page.split("### How this is known", 1)[1].split("\n## ", 1)[0]
+1 -1
View File
@@ -17,7 +17,7 @@ import yaml
from model.database import load_database
from sitegen.emulatorpage import availability_check
from sitegen.emulatorcards import file_badges
from sitegen.filebadges import file_badges
REPO_ROOT = Path(__file__).resolve().parent.parent
+4 -4
View File
@@ -76,7 +76,7 @@ class WhoShipsTheBuildAndWhy(unittest.TestCase):
def test_the_version_links_its_proof(self):
"""`0.97, stated in libretro/handy.h` was bare text beside a pinned
Revision link: the #define it reads was one search away."""
from sitegen import emulatorcards
from sitegen import emulatormetadata
from sitegen import sources
import yaml
@@ -84,15 +84,15 @@ class WhoShipsTheBuildAndWhy(unittest.TestCase):
path = handy["version_basis"]["path"]
self.assertIn(path, sources.cited_paths(handy))
self.assertIn(f"stated in [`{path}`](https://github.com/libretro/libretro-handy/blob/"
f"{handy['source_commit']}/{path})", emulatorcards.version_markdown(handy))
f"{handy['source_commit']}/{path})", emulatormetadata.version_markdown(handy))
tagged = {"source": "https://github.com/owner/emu", "source_commit": "a" * 40,
"core_version": "1.2-3-gaaaaaaa",
"version_basis": {"kind": "tag", "tag": "1.2", "distance": 3}}
self.assertEqual(emulatorcards.version_markdown(tagged), "1.2-3-gaaaaaaa, 3 commits after tag "
self.assertEqual(emulatormetadata.version_markdown(tagged), "1.2-3-gaaaaaaa, 3 commits after tag "
"[`1.2`](https://github.com/owner/emu/tree/1.2)")
# A file no recorded tree confirms stays plain: no link beats a 404.
unread = {**tagged, "version_basis": {"kind": "file", "path": "src/none.h"}}
self.assertEqual(emulatorcards.version_markdown(unread), "1.2-3-gaaaaaaa, stated in `src/none.h`")
self.assertEqual(emulatormetadata.version_markdown(unread), "1.2-3-gaaaaaaa, stated in `src/none.h`")
def test_the_upstream_pin_says_why_it_is_held(self):
"""mupen64plus showed its core revision and not that AmberELEC
+13 -11
View File
@@ -40,6 +40,8 @@ import json
from sitegen import guidedata
from sitegen import cards
from sitegen import emulatorcards
from sitegen import emulatormetadata
from sitegen import filebadges
from sitegen import emulatorpage
from sitegen import emulatorsindex
from sitegen import install as sitegen_install
@@ -210,7 +212,7 @@ class TheSummaryLineIsProse(unittest.TestCase):
self.assertIn("By kind: 1,563 BIOS ZIPs and 2 game data.", text)
def test_category_badge_in_words(self):
badges = " ".join(emulatorcards.file_badges({"name": "a", "category": "game_data"}, True))
badges = " ".join(filebadges.file_badges({"name": "a", "category": "game_data"}, True))
self.assertIn(">game data</span>", badges)
@@ -242,15 +244,15 @@ def _emulator_page(name: str, profile: dict | None = None) -> str:
class EachArcadePageNamesItsRomset(unittest.TestCase):
def test_the_romset_by_profile(self):
self.assertEqual(emulatorcards.emulator_romset(_profile("mame2003")), "MAME 0.78")
self.assertEqual(emulatormetadata.emulator_romset(_profile("mame2003")), "MAME 0.78")
# The app's version is 1.38.1, its MAME is 0.289.
self.assertEqual(emulatorcards.emulator_romset(_profile("mame4droid-2024")), "MAME 0.289")
self.assertEqual(emulatorcards.emulator_romset(_profile("mame2003_plus")), "MAME 0.78 (plus backports)")
self.assertTrue(emulatorcards.emulator_romset(_profile("fbneo")).startswith("FinalBurn Neo "))
self.assertTrue(emulatorcards.emulator_romset(_profile("fbalpha2012")).startswith("FB Alpha "))
self.assertEqual(emulatorcards.emulator_romset(_profile("duckstation")), "")
self.assertEqual(emulatormetadata.emulator_romset(_profile("mame4droid-2024")), "MAME 0.289")
self.assertEqual(emulatormetadata.emulator_romset(_profile("mame2003_plus")), "MAME 0.78 (plus backports)")
self.assertTrue(emulatormetadata.emulator_romset(_profile("fbneo")).startswith("FinalBurn Neo "))
self.assertTrue(emulatormetadata.emulator_romset(_profile("fbalpha2012")).startswith("FB Alpha "))
self.assertEqual(emulatormetadata.emulator_romset(_profile("duckstation")), "")
# HBMAME publishes no MAME release number.
self.assertEqual(emulatorcards.emulator_romset(_profile("hbmame")), "")
self.assertEqual(emulatormetadata.emulator_romset(_profile("hbmame")), "")
def test_a_row_and_a_line_under_the_intro(self):
page = _emulator_page("mame2003")
@@ -275,14 +277,14 @@ class WhatTheAppShipsIsNoFileToGet(unittest.TestCase):
def test_the_badge(self):
font = next(f for f in self.profile["files"] if f["name"] == "Roboto-Regular.ttf")
badges = " ".join(emulatorcards.file_badges(font, False))
badges = " ".join(filebadges.file_badges(font, False))
self.assertIn(">comes with the app</span>", badges)
self.assertNotIn(">required</span>", badges)
self.assertNotIn(">missing</span>", badges)
# Narrowed to one build, the entry is that build's alone, as verify
# and the pack read it: EightyOne installs its ROMs, and the libretro
# core, which embeds them, reads no entry. Nothing to fetch.
dual = " ".join(emulatorcards.file_badges({"name": "a", "bundled": True, "mode": "standalone",
dual = " ".join(filebadges.file_badges({"name": "a", "bundled": True, "mode": "standalone",
"required": True}, False))
self.assertNotIn(">required</span>", dual)
self.assertNotIn(">missing</span>", dual)
@@ -725,7 +727,7 @@ class DataFolderPrinted(unittest.TestCase):
"standalone_path": "a"}), "a")
def test_the_metadata_card_has_a_row_per_system(self) -> None:
rows = emulatorcards.render_metadata_rows(_profile("cxbx-reloaded"))
rows = emulatormetadata.render_metadata_rows(_profile("cxbx-reloaded"))
self.assertIn("| Data folder (Windows) | `%APPDATA%/Cxbx-Reloaded/` |", rows)
self.assertFalse(any("Data folder (Linux)" in row for row in rows))
+1 -1
View File
@@ -1173,7 +1173,7 @@ class ACardSaysWhyAFileIsLeftOut(unittest.TestCase):
could not tell why a RetroArch pack carried PPSSPP's assets."""
def test_the_build_and_the_platforms_are_named(self):
from sitegen.emulatorcards import file_badges
from sitegen.filebadges import file_badges
badges = " ".join(file_badges({"name": "a", "bundled": True, "mode": "standalone"}, True))
self.assertIn("installed with the standalone emulator", badges)