From e8b3cef5d579ea50ebd07727dc46174eebc93e81 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 22 Nov 2026 03:18:29 +0100 Subject: [PATCH] fix: read the platform guides on first use model.guides read and checked _registry.yml and _guides.yml at import, from the repository: a pack build died on a registry entry without a guide before parsing its options, and a site run on another platforms folder took the repository's guides. The guides now load on first use, keyed on siteinputs.current().platforms, behind accessor functions. --- scripts/model/guides.py | 100 +++++++++++++++++++++---------- scripts/packs/readme.py | 18 +++--- scripts/sitegen/build.py | 7 ++- scripts/sitegen/consolecards.py | 8 ++- scripts/sitegen/getpages.py | 12 ++-- scripts/sitegen/guidepage.py | 12 ++-- scripts/sitegen/guides.py | 6 +- scripts/sitegen/home.py | 13 ++-- scripts/sitegen/imagefetch.py | 6 +- scripts/sitegen/install.py | 22 +++---- scripts/sitegen/nav.py | 11 ++-- scripts/sitegen/pageprep.py | 8 +-- scripts/sitegen/platformindex.py | 8 +-- scripts/sitegen/platformpage.py | 11 ++-- scripts/sitegen/validate.py | 4 +- scripts/sitegen/whichpack.py | 24 ++++---- tests/test_audit_regressions.py | 14 ++--- tests/test_doc_pages.py | 12 ++-- tests/test_pack_readme.py | 10 ++-- tests/test_release_packs.py | 2 +- tests/test_site_bootstrap.py | 34 +++++------ tests/test_site_content_data.py | 45 ++++++++++++-- tests/test_site_emulators.py | 2 +- tests/test_site_entry.py | 62 +++++++++---------- tests/test_site_funnel.py | 14 ++--- tests/test_site_handheld.py | 2 +- tests/test_site_integration.py | 4 +- tests/test_site_nav.py | 9 +-- tests/test_site_page_text.py | 4 +- tests/test_site_steps.py | 4 +- tests/test_site_wiki.py | 6 +- 31 files changed, 290 insertions(+), 204 deletions(-) diff --git a/scripts/model/guides.py b/scripts/model/guides.py index 062d206b8..7d22a9ce7 100644 --- a/scripts/model/guides.py +++ b/scripts/model/guides.py @@ -2,22 +2,22 @@ from __future__ import annotations +import functools import re import textwrap from dataclasses import dataclass, fields from pathlib import Path +from model import siteinputs from model.registry import load_platform_registry -from core.paths import REPO_ROOT from model.sources import source_yaml SH_NAME = "i" PS1_NAME = "i.ps1" - - -PLATFORMS_DIR = REPO_ROOT / "platforms" -GUIDES_FILE = PLATFORMS_DIR / "_guides.yml" +GUIDES_NAME = "_guides.yml" +# The same installer from PyPI (scripts/build_pypi.py builds the package). +PACKAGE_COMMAND = "uvx retrobios" class GuideError(ValueError): @@ -182,7 +182,7 @@ def _folder_rows(value: object, extract_to: str, where: str) -> tuple[tuple[str, def _guide(name: str, data: object, extract_to: str, terminals: dict) -> Guide: - where = f"{GUIDES_FILE.name}: guides.{name}" + where = f"{GUIDES_NAME}: guides.{name}" if not isinstance(data, dict): raise GuideError(f"{where}: expected a mapping") _unknown(data, _GUIDE_KEYS, where) @@ -336,7 +336,7 @@ def _group_tiles(raw: list, at: str) -> tuple[Tile, ...]: return tuple(group_tiles) -def load_guides(path: Path = GUIDES_FILE, registry: dict | None = None) -> dict: +def load_guides(path: Path, registry: dict | None = None) -> dict: """The guides file, checked against the registry. Every registered platform has a guide and a device group the file @@ -344,7 +344,7 @@ def load_guides(path: Path = GUIDES_FILE, registry: dict | None = None) -> dict: never built from half a guide. """ if registry is None: - registry = load_platform_registry(PLATFORMS_DIR, required=True) + registry = load_platform_registry(path.parent, required=True) with open(path, encoding="utf-8") as handle: data = source_yaml(handle) or {} if not isinstance(data, dict): @@ -404,32 +404,70 @@ def load_guides(path: Path = GUIDES_FILE, registry: dict | None = None) -> dict: } -_LOADED = load_guides() -INSTALL_BASE: str = _LOADED["install_base"] -# The bootstraps the site serves (sitegen/bootstrap.py writes them). -INSTALL_SH: str = f"{INSTALL_BASE}/{SH_NAME}" -INSTALL_PS1: str = f"{INSTALL_BASE}/{PS1_NAME}" -# The same installer from PyPI (scripts/build_pypi.py builds the package). -PACKAGE_COMMAND = "uvx retrobios" -DEVICE_GROUPS: dict[str, tuple[str, str]] = _LOADED["device_groups"] -GROUP_ANCHORS: dict[str, str] = _LOADED["group_anchors"] -ALSO_RUNS: dict[str, tuple[tuple[str, str, str, str, str], ...]] = _LOADED["also_runs"] -GROUP_TILES: dict[str, tuple[Tile, ...]] = _LOADED["tiles"] -HANDHELD_GUIDE: HandheldGuide | None = _LOADED["handheld_guide"] -TERMINALS: dict[str, tuple[str, str, str]] = _LOADED["terminals"] -TRUST_ITEMS: tuple[str, ...] = _LOADED["trust_items"] -GUIDES: dict[str, Guide] = _LOADED["guides"] -_REGISTRY: dict = _LOADED["registry"] +@functools.cache +def _guides_in(platforms: Path) -> dict: + return load_guides(platforms / GUIDES_NAME) + + +def loaded() -> dict: + """The guides of the platforms folder the run describes, read on first use.""" + return _guides_in(siteinputs.current().platforms) + + +def platform_guides() -> dict[str, Guide]: + return loaded()["guides"] + + +def install_base() -> str: + return loaded()["install_base"] + + +def install_sh() -> str: + """The sh bootstrap the site serves (sitegen/bootstrap.py writes it).""" + return f"{install_base()}/{SH_NAME}" + + +def install_ps1() -> str: + """The PowerShell bootstrap the site serves.""" + return f"{install_base()}/{PS1_NAME}" + + +def device_groups() -> dict[str, tuple[str, str]]: + return loaded()["device_groups"] + + +def group_anchors() -> dict[str, str]: + return loaded()["group_anchors"] + + +def also_runs() -> dict[str, tuple[tuple[str, str, str, str, str], ...]]: + return loaded()["also_runs"] + + +def group_tiles() -> dict[str, tuple[Tile, ...]]: + return loaded()["tiles"] + + +def handheld_guide() -> HandheldGuide | None: + return loaded()["handheld_guide"] + + +def terminals() -> dict[str, tuple[str, str, str]]: + return loaded()["terminals"] + + +def trust_items() -> tuple[str, ...]: + return loaded()["trust_items"] def folder_list(name: str, registry: dict | None = None) -> list[tuple[str, str]]: """Every folder a guide names, as (where, path): the common ones, the rarer builds, and the systems the registry detects when the guide says so.""" - guide = GUIDES[name] + guide = platform_guides()[name] rows = [*guide.folders, *guide.more_folders] if guide.more_folders_detected: rows += [(system, f"`{folder}`") - for system, folder in detected_systems(registry or _REGISTRY, name)] + for system, folder in detected_systems(registry or loaded()["registry"], name)] return rows @@ -442,12 +480,12 @@ def _plain_folders(name: str) -> str: def setup_count() -> int: """Setups the site covers: every registered platform, since each keeps its page, its pack and its command. The one count every page states.""" - return len(GUIDES) + return len(platform_guides()) def pack_manual(name: str) -> str: """The manual part of a pack README, indented as the README is, or empty.""" - guide = GUIDES.get(name) + guide = platform_guides().get(name) if not guide or not guide.pack_manual: return "" text = guide.pack_manual.rstrip("\n") @@ -465,7 +503,7 @@ def install_command(shell: str, args: str = "") -> str: takes none. """ if shell == "sh": - return f"curl -fsSL {INSTALL_SH} | sh" + (f" -s -- {args}" if args else "") + return f"curl -fsSL {install_sh()} | sh" + (f" -s -- {args}" if args else "") if args: - return f"&([scriptblock]::Create((irm {INSTALL_PS1}))) {args}" - return f"irm {INSTALL_PS1} | iex" + return f"&([scriptblock]::Create((irm {install_ps1()}))) {args}" + return f"irm {install_ps1()} | iex" diff --git a/scripts/packs/readme.py b/scripts/packs/readme.py index 5b565bd39..dd652bae8 100644 --- a/scripts/packs/readme.py +++ b/scripts/packs/readme.py @@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, TypedDict from core.options import reject_unknown from model.region import label as region_label -from model.guides import INSTALL_PS1, INSTALL_SH, pack_manual +from model.guides import install_ps1, install_sh, pack_manual if TYPE_CHECKING: from typing_extensions import Unpack @@ -32,9 +32,9 @@ def _from_pack(platform_name: str, posix: bool, windows: bool, lines = [" Already have this ZIP? Add --from-pack and its path: the files", " come from it, not from the network. For a pack in parts, name one part.", ""] if posix: - lines.append(f" curl -fsSL {INSTALL_SH} | sh -s -- {args} /path/to/pack.zip{dest[0]}") + lines.append(f" curl -fsSL {install_sh()} | sh -s -- {args} /path/to/pack.zip{dest[0]}") if windows: - lines.append(f" &([scriptblock]::Create((irm {INSTALL_PS1}))) {args} C:\\path\\to\\pack.zip" + lines.append(f" &([scriptblock]::Create((irm {install_ps1()}))) {args} C:\\path\\to\\pack.zip" f"{dest[1]}") return [*lines, ""] @@ -50,9 +50,9 @@ def _card_section(platform_name: str, display: str) -> str: " ---------------------------------\n" " With the SD card mounted on a computer, name its root with --dest.\n" " Linux and macOS: run this in a terminal:\n\n" - f" curl -fsSL {INSTALL_SH} | sh -s -- --platform {platform_name} --dest /path/to/card\n\n" + f" curl -fsSL {install_sh()} | sh -s -- --platform {platform_name} --dest /path/to/card\n\n" " Windows: run this in PowerShell (E: being the card):\n\n" - f" &([scriptblock]::Create((irm {INSTALL_PS1}))) --platform {platform_name} --dest E:\\\n\n" + f" &([scriptblock]::Create((irm {install_ps1()}))) --platform {platform_name} --dest E:\\\n\n" f" The installer writes each file where {display} hands it to the core\n" " and checks every file.\n\n" + "\n".join(_from_pack(platform_name, True, True, (" --dest /path/to/card", " --dest E:\\"))) @@ -100,9 +100,9 @@ def _automatic_section( else: labels = {"linux": "Linux", "darwin": "macOS"} where = f"{' and '.join(labels[name] for name in posix)}: run this in a terminal:" - lines += [f" {where}", "", f" curl -fsSL {INSTALL_SH} | sh", ""] + lines += [f" {where}", "", f" curl -fsSL {install_sh()} | sh", ""] if "windows" in systems: - lines += [" Windows: run this in PowerShell:", "", f" irm {INSTALL_PS1} | iex", ""] + lines += [" Windows: run this in PowerShell:", "", f" irm {install_ps1()} | iex", ""] lines += [ f" The installer finds the {display} BIOS folder on this machine and", " installs there, checking every file. --dest names another folder.", @@ -119,9 +119,9 @@ def _automatic_section( "", ] if posix: - lines.append(f" curl -fsSL {INSTALL_SH} | sh -s -- --standalone-copies") + lines.append(f" curl -fsSL {install_sh()} | sh -s -- --standalone-copies") if "windows" in systems: - lines.append(f" &([scriptblock]::Create((irm {INSTALL_PS1}))) --standalone-copies") + lines.append(f" &([scriptblock]::Create((irm {install_ps1()}))) --standalone-copies") lines.append("") return "\n".join(lines) + "\n" diff --git a/scripts/sitegen/build.py b/scripts/sitegen/build.py index d6dce27c5..2c3366b16 100644 --- a/scripts/sitegen/build.py +++ b/scripts/sitegen/build.py @@ -19,7 +19,7 @@ from model.collection import group_by_manufacturer, manufacturer_slug from model.composition import compute_composition from model.database import load_database from model.dumpcatalog import load_provenance_snapshots -from model.guides import HANDHELD_GUIDE +from model.guides import handheld_guide from model.profiles import is_emulator, lists_files, load_emulator_profiles from model.registry import list_registered_platforms, load_platform_registry from model.systemnames import program_names, set_console_sections, system_name @@ -337,8 +337,9 @@ def _write_platform_pages(run: _SiteRun) -> dict[str, str]: str(docs / "platforms" / "index.md"), generate_platform_index(coverages, run.registry), ) - if HANDHELD_GUIDE: - write_if_changed(str(docs / HANDHELD_GUIDE.path), generate_handheld_guide(HANDHELD_GUIDE)) + handhelds = handheld_guide() + if handhelds: + write_if_changed(str(docs / handhelds.path), generate_handheld_guide(handhelds)) published_parts = load_published_parts() for name, cov in coverages.items(): # The emulators this platform runs, not every one of the system. diff --git a/scripts/sitegen/consolecards.py b/scripts/sitegen/consolecards.py index 876676599..323edca16 100644 --- a/scripts/sitegen/consolecards.py +++ b/scripts/sitegen/consolecards.py @@ -8,7 +8,7 @@ from typing import TypeVar from core.text import series from model.collection import profiles_on_disk from model.composition import GAME_DATA_TOPS -from model.guides import INSTALL_PS1, INSTALL_SH +from model.guides import install_ps1, install_sh from model.profiles import entry_system_ids from packs.consumers import FileConsumers from sitegen.cards import emulator_display, romset_releases, system_file_card @@ -41,14 +41,16 @@ SYSTEM_SUMMARY_HTML = 500_000 # bootstrap, 66 characters (67 for PowerShell). A box is weighed with its # address at that length, so the shorter site address moves no console off # or onto a summary and no card changes address. -FITTED_ADDRESS_CHARS = {INSTALL_PS1: 67, INSTALL_SH: 66} +FITTED_ADDRESS_CHARS = {"ps1": 67, "sh": 66} def install_box_weight(lines: list[str]) -> int: + fitted_chars = {install_ps1(): FITTED_ADDRESS_CHARS["ps1"], + install_sh(): FITTED_ADDRESS_CHARS["sh"]} weight = 0 for line in lines: weight += len(line) + 1 - for address, fitted in FITTED_ADDRESS_CHARS.items(): + for address, fitted in fitted_chars.items(): found = line.count(address) line = line.replace(address, "") weight += found * (fitted - len(address)) diff --git a/scripts/sitegen/getpages.py b/scripts/sitegen/getpages.py index 42e2e2c32..a9153047b 100644 --- a/scripts/sitegen/getpages.py +++ b/scripts/sitegen/getpages.py @@ -7,7 +7,7 @@ import re from model import releaserecord from model import siteinputs -from model.guides import DEVICE_GROUPS, GROUP_TILES, GUIDES, HANDHELD_GUIDE +from model.guides import device_groups, group_tiles, platform_guides, handheld_guide from model.platforms import load_platform_config from model.registry import load_platform_registry from installer_build.handhelds import GROUP_PAGE @@ -38,7 +38,8 @@ def _unzip_into(platform_name: str, display: str, extract_to: str | None, parts: what = "them all" if parts > 1 else "it" if not setup_relative(extract_to): return [f"- Unzip {what} into {folder_words(display, extract_to)}.", ""] - lead = GUIDES[platform_name].lead if platform_name in GUIDES else "" + guide = platform_guides().get(platform_name) + lead = guide.lead if guide else "" return [ f"- Unzip {what} into {folder_words(display, extract_to)}. " f"[Where is it?](../platforms/{platform_name}.md#where-the-files-go)", @@ -157,7 +158,8 @@ def generate_get_index() -> str: "# BIOS files by setup", "", "One page per setup. Its address stays the same, so it is the one to share.", "", ] - for group, (label, _description) in DEVICE_GROUPS.items(): + handhelds = handheld_guide() + for group, (label, _description) in device_groups().items(): names = [name for name, entry in registry.items() if entry.get("device_group") == group] if not names: continue @@ -167,8 +169,8 @@ def generate_get_index() -> str: lines.append(f"- [{get_page_title(name, display)}]({name}.md)") # The handheld app sits with the group whose tile leads to the # handheld guide. - if any(HANDHELD_GUIDE and tile.link == HANDHELD_GUIDE.path - for tile in GROUP_TILES.get(group, ())): + if any(handhelds and tile.link == handhelds.path + for tile in group_tiles().get(group, ())): lines.append(f"- [{sitehandheld.GROUP_TITLE}]({GROUP_PAGE}.md)") lines.append("") return "\n".join(lines) diff --git a/scripts/sitegen/guidepage.py b/scripts/sitegen/guidepage.py index ff4668682..03f79140e 100644 --- a/scripts/sitegen/guidepage.py +++ b/scripts/sitegen/guidepage.py @@ -10,11 +10,11 @@ from model import releaserecord from model import siteinputs from model.collection import profiles_on_disk from model.guides import ( - GUIDES, + platform_guides, Guide, HandheldGuide, HandheldSystem, - TERMINALS, + terminals, detected_systems as _detected_systems, ) from model.registry import load_platform_registry @@ -258,7 +258,7 @@ def setup_routes(name: str, display: str, page_link: bool = False) -> list[str]: computer, the card from a computer when the device has no network, and the device's own terminal. *page_link* adds the get/ page, on the setup page only.""" - guide = GUIDES[name] + guide = platform_guides()[name] share = _network_share(name, guide) card = _card_route(name, display, guide) shared = _get_page_line(name, display) if page_link else [] @@ -371,7 +371,7 @@ def _guide_install(name: str, guide: Guide, heading: str) -> list[str]: "**E:**. Put the card's path after `--dest`.", "", ] - device = guide.terminal or f"{TERMINALS['device'][1]} {DEVICE_TERMINAL_FALLBACK}" + device = guide.terminal or f"{terminals()['device'][1]} {DEVICE_TERMINAL_FALLBACK}" return [ *lines, *terminal_tabs(guide.run, platform_args(name, guide), how={"device": device}), @@ -431,7 +431,7 @@ def generate_handheld_guide(guide: HandheldGuide) -> str: A handheld owner starts from the device name. The systems were named only in a closed note, with a path seen from inside the device.""" - uses = GUIDES[guide.uses] + uses = platform_guides()[guide.uses] display = platform_display(guide.uses) args = {"windows": f"--platform {guide.uses} --dest E:\\BIOS", "macos": f"--platform {guide.uses} --dest /path/to/card/BIOS", @@ -479,7 +479,7 @@ def platform_guide(name: str, display: str, cov: dict, registry: dict, no_list: A system that runs only on its own device puts the computer route (download, unzip into the network folder) before the command.""" - guide = GUIDES[name] + guide = platform_guides()[name] entry = registry.get(name, {}) extract_to = entry.get("extract_to") # An app's page opens on the command: one line to paste is the shortest diff --git a/scripts/sitegen/guides.py b/scripts/sitegen/guides.py index ff10fe18b..d97be06d0 100644 --- a/scripts/sitegen/guides.py +++ b/scripts/sitegen/guides.py @@ -13,7 +13,7 @@ from __future__ import annotations from sitegen import markup -from model.guides import Guide, TERMINALS, TRUST_ITEMS, install_command +from model.guides import Guide, terminals, trust_items, install_command # The title over each command block, by the shell it is written for. @@ -42,7 +42,7 @@ def terminal_tabs( after its text and after its command (sitegen.steps.install_box).""" items = [] for key in tabs: - label, shared, shell = TERMINALS[key] + label, shared, shell = terminals()[key] if len(tabs) == 1 and key in PLACES: label = "" # one place, which the text around already names text = (how or {}).get(key) or shared @@ -70,7 +70,7 @@ def platform_args(name: str, guide: Guide) -> dict[str, str]: def trust_box(prefix: str, indent: str = "") -> list[str]: """Is it safe, under every command on a guide page: the trust items.""" return markup.details("note", "Is it safe?", [ - *(f"- {item}" for item in TRUST_ITEMS), + *(f"- {item}" for item in trust_items()), "", f"[Read the script first]({prefix}wiki/faq.md#is-piping-the-installer-into-a-shell-safe)", ], indent) diff --git a/scripts/sitegen/home.py b/scripts/sitegen/home.py index 6af0023b8..f5ffd754f 100644 --- a/scripts/sitegen/home.py +++ b/scripts/sitegen/home.py @@ -7,7 +7,7 @@ import html from core.paths import PLATFORMS_DIR from core.sizes import size_text from model.composition import compute_composition -from model.guides import DEVICE_GROUPS, GROUP_TILES, GUIDES, Guide, TRUST_ITEMS, setup_count +from model.guides import device_groups, group_tiles, platform_guides, Guide, trust_items, setup_count from model.profiles import unique_emulator_profiles from model.registry import load_platform_registry from sitegen import markup @@ -47,13 +47,14 @@ def _tiles(registry: dict, members: list[str], display: dict[str, str], prefix: """The setup tiles of one device group: logo, name and the hardware it runs on, then the group's other tiles: a kind of device that runs one of the setups (Android handhelds, Linux handhelds).""" + guides = platform_guides() return markup.platform_tiles([ *((display[name], f"{prefix}platforms/{name}.md", str(registry.get(name, {}).get("logo") or ""), - GUIDES[name].runs_on or runs_on_text(registry.get(name, {}), GUIDES[name])) + guides[name].runs_on or runs_on_text(registry.get(name, {}), guides[name])) for name in members), *((tile.name, f"{prefix}{tile.link}", tile.logo, tile.text) - for tile in GROUP_TILES.get(group, ())), + for tile in group_tiles().get(group, ())), ], eager=eager) @@ -64,9 +65,9 @@ def setup_picker(registry: dict, display: dict[str, str], prefix: str = "") -> l page: the 19 logos were most of the bytes of the home page.""" lines: list[str] = [] alone: list[str] = [] - for group, (label, _description) in DEVICE_GROUPS.items(): + for group, (label, _description) in device_groups().items(): members = group_keys(registry, group, display) - if len(members) == 1 and not GROUP_TILES.get(group): + if len(members) == 1 and not group_tiles().get(group): alone += members elif members: eager = 0 if lines else markup.FIRST_ROW_TILES @@ -136,7 +137,7 @@ def generate_home( *setup_picker(registry, display), "## Is it safe?", "", - *(f"- {item}" for item in TRUST_ITEMS), + *(f"- {item}" for item in trust_items()), "", "[How the command is checked](wiki/faq.md#is-piping-the-installer-into-a-shell-safe). " "Details: [Is it legal?](wiki/legal.md)", diff --git a/scripts/sitegen/imagefetch.py b/scripts/sitegen/imagefetch.py index 51700b158..7a124fa4a 100644 --- a/scripts/sitegen/imagefetch.py +++ b/scripts/sitegen/imagefetch.py @@ -11,7 +11,7 @@ from pathlib import Path from core.paths import DB_FILE, PLATFORMS_DIR, REPO_ROOT from model.collection import group_by_manufacturer from model.database import load_database -from model.guides import GROUP_TILES, GUIDES +from model.guides import group_tiles, platform_guides from model.registry import load_platform_registry from scraper.base_scraper import FetchError, fetch_bytes from sitegen.imagenormalize import ( @@ -53,10 +53,10 @@ def fetch_logos() -> Iterator[tuple[str, str]]: entries = [] # The tiles of a kind of device (Android handhelds) beside the setups # carry a logo too, named after the tile. - sources = [(name, entry.get("logo"), entry, GUIDES.get(name)) + sources = [(name, entry.get("logo"), entry, platform_guides().get(name)) for name, entry in sorted(platforms.items())] sources += [(re.sub(r"[^a-z0-9]+", "-", tile.name.lower()).strip("-"), tile.logo, {}, tile) - for tiles in GROUP_TILES.values() for tile in tiles] + for tiles in group_tiles().values() for tile in tiles] for name, url, entry, guide in sources: if not url: # No logo of its own: the tile shows initials, and an old copy diff --git a/scripts/sitegen/install.py b/scripts/sitegen/install.py index 3ce75beaa..21d07ea60 100644 --- a/scripts/sitegen/install.py +++ b/scripts/sitegen/install.py @@ -13,7 +13,7 @@ from pathlib import Path from core.text import series from model import siteinputs from model.collection import profiles_in -from model.guides import GUIDES, TERMINALS, install_command +from model.guides import platform_guides, terminals, install_command from model.platforms import load_platform_config from model.registry import list_release_pack_platforms from model.profiles import reads_own_files @@ -99,7 +99,7 @@ def install_commands(args: str = "", indent: str = "", download page and the platform, system and emulator pages, so none of them loses the Android or Windows form. - ``oses`` names the terminals (keys of TERMINALS) the command runs in, + ``oses`` names the terminals (keys of terminals()) the command runs in, written as the synced OS tabs: MAME4droid runs on Android only, and its page offered a PowerShell command. None keeps the three blocks. """ @@ -159,7 +159,7 @@ def emulator_install_route(name: str, profile: dict) -> tuple[str, list[str], tu standalone = profile.get("type") == "standalone" accepted: dict[str, set[str]] = {} for platform, names in _published_emulator_names().items(): - if platform not in GUIDES: + if platform not in platform_guides(): continue # Decided per setup, as the manifest decides it: Batocera's hcl # package leaves out the 667 files every other setup's install brings. @@ -167,7 +167,7 @@ def emulator_install_route(name: str, profile: dict) -> tuple[str, list[str], tu continue if standalone and not runs_standalone(name, profile, _standalone_cores(platform)): continue - if any("--dest" in args for args in platform_args(platform, GUIDES[platform]).values()): + if any("--dest" in args for args in platform_args(platform, platform_guides()[platform]).values()): continue own = {n for n, target in names.items() if target == name} if own: @@ -179,15 +179,16 @@ def emulator_install_route(name: str, profile: dict) -> tuple[str, list[str], tu candidates = set().union(*accepted.values()) command = min(candidates, key=lambda n: ( -sum(n in own for own in accepted.values()), n != name, n)) - order = list(GUIDES) + guides = platform_guides() + order = list(guides) setups = sorted((p for p, own in accepted.items() if command in own), key=order.index) - terminals = {key for setup in setups for key in GUIDES[setup].run} + runs_in = {key for setup in setups for key in guides[setup].run} if isinstance(profile.get("data_root"), dict): # Only the systems the program is built for (Cemu has no Android # build). A device setup runs it itself: its terminal stays. - terminals &= {"device", *(t for key in profile["data_root"] + runs_in &= {"device", *(t for key in profile["data_root"] for t in _DATA_ROOT_TERMINALS.get(key, ()))} - oses = tuple(key for key in _COMMAND_TERMINALS if key in terminals) + oses = tuple(key for key in _COMMAND_TERMINALS if key in runs_in) if not oses: return "", [], () return command, setups, oses @@ -452,7 +453,8 @@ def _default_setup(declared: list[tuple[str, str]]) -> tuple[str, str]: most systems overall, then one the release publishes a ZIP for. """ def reach(pair: tuple[str, str]) -> tuple[int, int, bool]: - runs = GUIDES[pair[0]].run if pair[0] in GUIDES else () + guide = platform_guides().get(pair[0]) + runs = guide.run if guide else () return (len(set(runs) & set(INSTALL_PICKER_OSES)), len(runs), has_release_pack(pair[0])) return max(declared, key=reach) @@ -482,7 +484,7 @@ def _install_picker(declared: list[tuple[str, str]]) -> list[str]: quote=False) + "" for platform, system in declared) - args = {key: _install_args(*lead, TERMINALS[key][2]) for key in INSTALL_PICKER_OSES} + args = {key: _install_args(*lead, terminals()[key][2]) for key in INSTALL_PICKER_OSES} return [ "Each platform names the system its own way.", "", diff --git a/scripts/sitegen/nav.py b/scripts/sitegen/nav.py index acf55e161..491d17843 100644 --- a/scripts/sitegen/nav.py +++ b/scripts/sitegen/nav.py @@ -8,7 +8,7 @@ from pathlib import Path from model.collection import manufacturer_slug from model.composition import GAME_DATA_TOPS -from model.guides import DEVICE_GROUPS, GROUP_TILES, HANDHELD_GUIDE +from model.guides import device_groups, group_tiles, handheld_guide from model.profiles import unique_emulator_profiles from sitegen import measurements as sitemeasurements, starlight as sitestarlight from core.paths import REPO_ROOT @@ -71,16 +71,17 @@ def _system_nav(manufacturers: dict) -> list: def _platform_nav(coverages: dict, registry: dict) -> list: """Platforms by the kind of device they run on, as on the device picker.""" nav: list = ["platforms/index.md"] - for group, (label, _description) in DEVICE_GROUPS.items(): + handhelds = handheld_guide() + for group, (label, _description) in device_groups().items(): members = [ {coverages[name]["platform"]: f"platforms/{name}.md"} for name in sorted(coverages, key=lambda n: coverages[n]["platform"].casefold()) if registry.get(name, {}).get("device_group") == group ] # The handheld guide sits with the group whose tile leads to it. - members += [{HANDHELD_GUIDE.title: HANDHELD_GUIDE.path} - for tile in GROUP_TILES.get(group, ()) - if HANDHELD_GUIDE and tile.link == HANDHELD_GUIDE.path] + members += [{handhelds.title: handhelds.path} + for tile in group_tiles().get(group, ()) + if handhelds and tile.link == handhelds.path] if members: nav.append({label: members}) return nav diff --git a/scripts/sitegen/pageprep.py b/scripts/sitegen/pageprep.py index accfede59..20201c601 100644 --- a/scripts/sitegen/pageprep.py +++ b/scripts/sitegen/pageprep.py @@ -104,10 +104,10 @@ FENCE_TITLES = {"sh": "Terminal", "powershell": "PowerShell"} def _installer_args(body: str) -> str: """The options of a one-line install command, continuation lines joined.""" - from model.guides import INSTALL_SH + from model.guides import install_sh line = " ".join(part.strip().rstrip("\\").strip() for part in body.splitlines()) - match = re.fullmatch(rf"curl -fsSL {re.escape(INSTALL_SH)} \| sh(?: -s -- (.+))?", line) + match = re.fullmatch(rf"curl -fsSL {re.escape(install_sh())} \| sh(?: -s -- (.+))?", line) if not match: raise ValueError(f"an os-tabs block holds no install command: {line!r}") return match.group(1) or "" @@ -127,7 +127,7 @@ def expand_commands(markdown: str) -> str: gives a tab its own options, for a folder that differs there.""" if "os-tabs" not in markdown: return markdown - from model.guides import TERMINALS, install_command + from model.guides import terminals, install_command def replace(match: re.Match[str]) -> str: indent = match.group("indent") @@ -135,7 +135,7 @@ def expand_commands(markdown: str) -> str: own_args = _own_args(match.group("own")) items = [] for key in OS_TAB_KEYS: - label, _how, shell = TERMINALS[key] + label, _how, shell = terminals()[key] own = own_args.get(key) or args items.append((label, [f'```{shell} title="{FENCE_TITLES[shell]}"', install_command(shell, own), "```"])) diff --git a/scripts/sitegen/platformindex.py b/scripts/sitegen/platformindex.py index aeef758aa..9b15d2631 100644 --- a/scripts/sitegen/platformindex.py +++ b/scripts/sitegen/platformindex.py @@ -3,7 +3,7 @@ from __future__ import annotations from model import releaserecord -from model.guides import DEVICE_GROUPS, GROUP_TILES, GUIDES +from model.guides import device_groups, group_tiles, platform_guides from resolve.nativemode import check_label from sitegen import markup from sitegen.guidepage import NO_ZIP_FAQ @@ -25,7 +25,7 @@ def generate_platform_index(coverages: dict, registry: dict | None = None) -> st "Each setup's page gives the folder and the command.", "", ] - for group, (label, _description) in DEVICE_GROUPS.items(): + for group, (label, _description) in device_groups().items(): members = group_members(coverages, registry, group) if not members: continue @@ -34,10 +34,10 @@ def generate_platform_index(coverages: dict, registry: dict | None = None) -> st # follow, as on the home tiles. lines += [f"## {label}", ""] lines += markup.card_grid([ - *((f"[{coverages[name]['platform']}]({name}.md)", [GUIDES[name].summary]) + *((f"[{coverages[name]['platform']}]({name}.md)", [platform_guides()[name].summary]) for name in members), *((f"[{tile.name}](../{tile.link})", [tile.text]) - for tile in GROUP_TILES.get(group, ())), + for tile in group_tiles().get(group, ())), ]) lines += [ f"Comparing setups? [Every setup side by side](../{SETUP_TABLE_LINK})", diff --git a/scripts/sitegen/platformpage.py b/scripts/sitegen/platformpage.py index 973f397d6..f002d7f4d 100644 --- a/scripts/sitegen/platformpage.py +++ b/scripts/sitegen/platformpage.py @@ -5,7 +5,7 @@ from __future__ import annotations import json import re -from model.guides import GUIDES +from model.guides import platform_guides from model.systemnames import system_name from resolve.nativemode import check_label, reads_file_contents from sitegen import markup @@ -146,11 +146,12 @@ def _platform_head(name: str, cov: dict, registry: dict, no_list: bool) -> list[ "", ] - summary = GUIDES[name].summary if name in GUIDES else "" + guide = platform_guides().get(name) + summary = guide.summary if guide else "" if summary: lines += [summary + (f" [{display} website]({homepage})." if homepage else ""), ""] - if name in GUIDES: + if guide: lines += platform_guide(name, display, cov, registry, no_list) lines += [ "## Reference: every file by system { #reference-every-file-by-system }", @@ -159,7 +160,7 @@ def _platform_head(name: str, cov: dict, registry: dict, no_list: bool) -> list[ "", "For checking the work: counts, the list's source and each file's hashes.", "", - *(line for note in (GUIDES[name].reference_notes if name in GUIDES else ()) + *(line for note in (guide.reference_notes if guide else ()) for line in (note, "")), ] if no_list: @@ -197,7 +198,7 @@ def generate_platform_page( "| Detail | Value |", "|---|---|"]) lines.extend(_platform_meta_rows(name, config, cov["mode"], registry)) lines.extend(["", ""]) - if name not in GUIDES: + if name not in platform_guides(): detect = (registry.get(name, {}).get("install") or {}).get("detect") or [] on_card = any(rule.get("method") == "card_marker" for rule in detect) lines.extend(["", *platform_install_block(name, display, on_card)]) diff --git a/scripts/sitegen/validate.py b/scripts/sitegen/validate.py index 06fe6cb63..0a2100d3d 100644 --- a/scripts/sitegen/validate.py +++ b/scripts/sitegen/validate.py @@ -419,7 +419,7 @@ def _check_get_pages( """ sys.path.insert(0, str(Path(__file__).resolve().parent)) from model import releaserecord - from model.guides import INSTALL_SH + from model.guides import install_sh from model.registry import list_registered_platforms, list_release_pack_platforms if not (platforms_dir / "_registry.yml").is_file(): @@ -444,7 +444,7 @@ def _check_get_pages( packs = [a for a in assets if "_BIOS_Pack" in a] if packs: issues.append(f"{rel}: links a pack for a setup without one: {packs[0]}") - if f"{INSTALL_SH} | sh" not in (site / rel).read_text(encoding="utf-8"): + if f"{install_sh()} | sh" not in (site / rel).read_text(encoding="utf-8"): issues.append(f"{rel}: gives no install command") return issues diff --git a/scripts/sitegen/whichpack.py b/scripts/sitegen/whichpack.py index f0fd44d52..12ca29683 100644 --- a/scripts/sitegen/whichpack.py +++ b/scripts/sitegen/whichpack.py @@ -7,13 +7,13 @@ from core.sizes import size_text from core.ziptools import build_zip_contents_index from model import siteinputs from model.guides import ( - ALSO_RUNS, - DEVICE_GROUPS, - GROUP_ANCHORS, - GUIDES, + also_runs, + device_groups, + group_anchors, + platform_guides, Guide, PACKAGE_COMMAND, - TERMINALS, + terminals, install_command, ) from model.platforms import load_platform_config @@ -106,7 +106,7 @@ def _folder_row(key: str, display: dict[str, str], registry: dict, record: dict, """One setup's row: where it runs, its BIOS folder and its ZIP. A setup whose ZIP holds its own top folder says where to unzip it, and the BIOS folder itself when it has no ZIP to unzip.""" - guide = GUIDES[key] + guide = platform_guides()[key] pack = releaserecord.pack_for(key, record) zipped = bool(pack and pack.get("assets")) folder = (f"Unzip into `{own_root[key]}`" if key in own_root and zipped @@ -124,23 +124,23 @@ def _folder_tables(registry: dict, record: dict, display: dict[str, str]) -> lis header = ["| Setup | Runs on | BIOS folder | ZIP |", "|-------|---------|-------------|-----|"] lines: list[str] = [] alone: list[str] = [] - for group, (label, _description) in DEVICE_GROUPS.items(): + for group, (label, _description) in device_groups().items(): members = group_keys(registry, group, display) - if len(members) == 1 and not ALSO_RUNS.get(group): + if len(members) == 1 and not also_runs().get(group): alone += members continue if not members: continue - lines += [f'**{label}**', "", *header] + lines += [f'**{label}**', "", *header] lines += [_folder_row(key, display, registry, record, own_root) for key in members] lines += [ f"| {setup} | {runs_on} | {folder}, same as " f"[{display[uses]}](platforms/{uses}.md) | {_pack_cell(uses, record)} |" - for setup, _summary, uses, runs_on, folder in ALSO_RUNS.get(group, ()) + for setup, _summary, uses, runs_on, folder in also_runs().get(group, ()) ] lines.append("") if alone: - anchors = "".join(f'' + anchors = "".join(f'' for key in alone) lines += [f"{anchors}**Other setups**", "", *header, *(_folder_row(key, display, registry, record, own_root) for key in alone), ""] @@ -261,7 +261,7 @@ def generate_which_pack() -> str: *trust_box(""), "**Check the folder later.** Add `--check`. It changes nothing.", "", - *terminal_tabs(all_tabs, dict.fromkeys(TERMINALS, "--check"), steps=False), + *terminal_tabs(all_tabs, dict.fromkeys(terminals(), "--check"), steps=False), *markup.details("note", "Fill an SD card from a computer", [ "Name the setup and the BIOS folder on the card. For RetroArch on a " "Nintendo Switch:", diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index e65c70042..56ca741aa 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -60,11 +60,11 @@ class ReadmeRegressions(unittest.TestCase): def test_advertised_bootstrap_urls_are_the_shipped_ones(self): from sitegen import bootstrap as sitebootstrap - from model.guides import INSTALL_BASE + from model.guides import install_base quick_install = self._quick_install() for name in sitebootstrap.SOURCES: - url = f"{INSTALL_BASE}/{name}" + url = f"{install_base()}/{name}" self.assertIn(f"{url} |", quick_install, f"{name} bootstrap URL missing") # The site serves each bootstrap with install.py read from the # commit it was built from, the raw form from main. @@ -891,11 +891,11 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase): return text[text.index("INSTALLATION"):text.index("TROUBLESHOOTING")] def test_retroarch_offers_the_windows_installer(self): - from model.guides import INSTALL_PS1, INSTALL_SH + from model.guides import install_ps1, install_sh guide = self._guide("retroarch") - self.assertIn(f"{INSTALL_SH} | sh", guide) - self.assertIn(f"{INSTALL_PS1} | iex", guide) + self.assertIn(f"{install_sh()} | sh", guide) + self.assertIn(f"{install_ps1()} | iex", guide) def test_emudeck_keys_match_the_registry_and_the_flag(self): import re @@ -918,10 +918,10 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase): def test_retropie_never_sends_a_pc_to_the_linux_partition(self): guide = self._guide("retropie") - from model.guides import INSTALL_SH + from model.guides import install_sh self.assertNotIn("Put the SD card in your PC", guide) - self.assertIn(f"{INSTALL_SH} | sh", guide) + self.assertIn(f"{install_sh()} | sh", guide) class AutoFetchReadsListsAndPlacesWithoutClobbering(unittest.TestCase): diff --git a/tests/test_doc_pages.py b/tests/test_doc_pages.py index 63612af3c..4ef4b2314 100644 --- a/tests/test_doc_pages.py +++ b/tests/test_doc_pages.py @@ -928,9 +928,9 @@ class RetroArchWindowsSystemFolder(unittest.TestCase): source = inspect.getsource(install) self.assertIn('ra_dir or exe_dir / "system"', source) self.assertTrue(str(install._os_default_dests("windows")["retroarch"]).replace("\\", "/").endswith("/system")) - from model.guides import GUIDES + from model.guides import platform_guides - guide = GUIDES["retroarch"] + guide = platform_guides()["retroarch"] section = "\n".join([*(path for _label, path in guide.folders), *guide.notes]) self.assertNotIn("%APPDATA%\\RetroArch\\system", section) self.assertIn("`system\\` next to `retroarch.exe`", section) @@ -941,11 +941,11 @@ class RetroArchWindowsSystemFolder(unittest.TestCase): (platform_darwin.m), Application Support only for a portable or Steam build, and install.py looks there in that order.""" import install - from model.guides import GUIDES + from model.guides import platform_guides source = inspect.getsource(install._macos_retroarch_base) self.assertIn('Path.home() / "Documents" / "RetroArch"', source) - folders = dict(GUIDES["retroarch"].folders) + folders = dict(platform_guides()["retroarch"].folders) self.assertEqual(folders["macOS"], "`~/Documents/RetroArch/system/`") @@ -1645,9 +1645,9 @@ def unserved_one_liners(page: str, text: str) -> list[str]: address of the repository stays as the fallback of the One line section, and must name a bootstrap the repository holds.""" from sitegen import bootstrap as sitebootstrap - from model.guides import INSTALL_BASE + from model.guides import install_base - served = {f"{INSTALL_BASE}/{name}" for name in sitebootstrap.SOURCES} + served = {f"{install_base()}/{name}" for name in sitebootstrap.SOURCES} fallback = _section(text, "One line") if page == "installer.md" else "" stale = [] for line in text.splitlines(): diff --git a/tests/test_pack_readme.py b/tests/test_pack_readme.py index 4283ec376..6c4b0c717 100644 --- a/tests/test_pack_readme.py +++ b/tests/test_pack_readme.py @@ -116,15 +116,15 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase): def test_the_commands_are_written_once(self): """The address comes from install_base in platforms/_guides.yml, the one the site's commands use.""" - from packs import readme as packreadme - from model import guides - from model.guides import INSTALL_BASE + from model.guides import install_ps1, install_sh source = (REPO_ROOT / "scripts" / "packs" / "readme.py").read_text(encoding="utf-8") self.assertNotIn("raw.githubusercontent.com", source) self.assertNotIn("abdess.github.io", source) - self.assertEqual(packreadme.INSTALL_SH, f"{INSTALL_BASE}/{guides.SH_NAME}") - self.assertEqual(packreadme.INSTALL_PS1, f"{INSTALL_BASE}/{guides.PS1_NAME}") + text = build_readme("retroarch", "RetroArch", "system", 1, 1, + detect=[{"os": "linux"}, {"os": "windows"}]) + self.assertIn(install_sh(), text) + self.assertIn(install_ps1(), text) class GuidesInstallFromTheZipInHand(unittest.TestCase): diff --git a/tests/test_release_packs.py b/tests/test_release_packs.py index 5743b4fdc..dd9fa7cc6 100644 --- a/tests/test_release_packs.py +++ b/tests/test_release_packs.py @@ -270,7 +270,7 @@ class EverySurfaceSaysWhy(unittest.TestCase): with contextlib.chdir(REPO_ROOT): block = guidepage.pack_buttons("knulli") guide = guidepage._guide_download( - "knulli", "KNULLI", guides.GUIDES["knulli"], None, "## Download") + "knulli", "KNULLI", guides.platform_guides()["knulli"], None, "## Download") self.assertIn(line, block) self.assertIn(guidepage.NO_ZIP_FAQ, block) self.assertIn(line, "\n".join(guide)) diff --git a/tests/test_site_bootstrap.py b/tests/test_site_bootstrap.py index b7d3f59e4..25e45c44c 100644 --- a/tests/test_site_bootstrap.py +++ b/tests/test_site_bootstrap.py @@ -24,7 +24,7 @@ from unittest import mock import install from sitegen import bootstrap as sitebootstrap from model import guides -from model.guides import INSTALL_BASE, INSTALL_PS1, INSTALL_SH, install_command +from model.guides import install_base, install_ps1, install_sh, install_command REPO_ROOT = Path(__file__).resolve().parents[1] @@ -153,29 +153,29 @@ class DocumentedCommands(unittest.TestCase): config = (WEBSITE / "astro.config.mjs").read_text(encoding="utf-8") site = re.search(r"const SITE = '([^']+)'", config).group(1) base = re.search(r"const BASE = '([^']+)'", config).group(1) - self.assertEqual(f"{INSTALL_BASE}/", site + base) - self.assertEqual(INSTALL_SH, f"{site}{base}{guides.SH_NAME}") - self.assertEqual(INSTALL_PS1, f"{site}{base}{guides.PS1_NAME}") - self.assertEqual(install.BOOTSTRAP_URL, INSTALL_SH) - self.assertEqual(f"{install.BOOTSTRAP_URL}.ps1", INSTALL_PS1) + self.assertEqual(f"{install_base()}/", site + base) + self.assertEqual(install_sh(), f"{site}{base}{guides.SH_NAME}") + self.assertEqual(install_ps1(), f"{site}{base}{guides.PS1_NAME}") + self.assertEqual(install.BOOTSTRAP_URL, install_sh()) + self.assertEqual(f"{install.BOOTSTRAP_URL}.ps1", install_ps1()) def test_the_installer_hints_give_the_short_command(self): with mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "sh"}): - self.assertEqual(install.Invocation().launcher(), f"curl -fsSL {INSTALL_SH} | sh -s --") + self.assertEqual(install.Invocation().launcher(), f"curl -fsSL {install_sh()} | sh -s --") with mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "ps1"}): self.assertEqual(install.Invocation().launcher(), - f"&([scriptblock]::Create((irm {INSTALL_PS1})))") + f"&([scriptblock]::Create((irm {install_ps1()})))") def test_every_page_a_user_copies_from_gives_the_short_command(self): sources = { "wiki/installer.md": [install_command("sh"), install_command("powershell")], "wiki/first-install.md": [install_command("sh"), install_command("powershell")], - "wiki/faq.md": [f"curl -fsSL {INSTALL_SH} | sh -s -- --dry-run"], + "wiki/faq.md": [f"curl -fsSL {install_sh()} | sh -s -- --dry-run"], "wiki/troubleshooting.md": [install_command("sh", "--check")], "wiki/tools.md": [install_command("sh"), install_command("powershell")], - "website/src/components/FilePicker.astro": [f"'curl -fsSL {INSTALL_SH} | sh -s --'"], - "scripts/download.sh": [f"curl -fsSL {INSTALL_SH} | sh -s -- --platform "], - "scripts/release/packinfo.py": [f"curl -fsSL {INSTALL_SH} | sh -s -- --platform "], + "website/src/components/FilePicker.astro": [f"'curl -fsSL {install_sh()} | sh -s --'"], + "scripts/download.sh": [f"curl -fsSL {install_sh()} | sh -s -- --platform "], + "scripts/release/packinfo.py": [f"curl -fsSL {install_sh()} | sh -s -- --platform "], } for rel, commands in sources.items(): text = (REPO_ROOT / rel).read_text(encoding="utf-8") @@ -202,7 +202,7 @@ class DocumentedCommands(unittest.TestCase): def test_no_command_drops_the_scheme(self): """A first request in clear text lets anyone on the way serve another script, which the installer's pin cannot catch: the pin is in it.""" - bare = INSTALL_BASE.removeprefix("https://") + bare = install_base().removeprefix("https://") for page in sorted((REPO_ROOT / "wiki").glob("*.md")): text = page.read_text(encoding="utf-8") with self.subTest(page=page.name): @@ -258,11 +258,11 @@ class GeneratedSurfaces(unittest.TestCase): from sitegen import consolecards tail = " | sh -s -- --check" - self.assertEqual(consolecards.install_box_weight([f"curl -fsSL {INSTALL_SH}{tail}"]), + self.assertEqual(consolecards.install_box_weight([f"curl -fsSL {install_sh()}{tail}"]), len("curl -fsSL ") + 66 + len(tail) + 1) - line = f"&([scriptblock]::Create((irm {INSTALL_PS1}))) --check" + line = f"&([scriptblock]::Create((irm {install_ps1()}))) --check" self.assertEqual(consolecards.install_box_weight([line]), - len(line) - len(INSTALL_PS1) + 67 + 1) + len(line) - len(install_ps1()) + 67 + 1) def test_the_readme_shows_the_short_form(self): readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8") @@ -274,7 +274,7 @@ class GeneratedSurfaces(unittest.TestCase): @unittest.skipUnless(DOCS.is_dir(), "site not generated") def test_the_site_shows_the_short_form(self): pages = {path: path.read_text(encoding="utf-8") for path in DOCS.rglob("*.md*")} - self.assertTrue(any(INSTALL_SH in text for text in pages.values())) + self.assertTrue(any(install_sh() in text for text in pages.values())) long_form = sorted(str(path.relative_to(DOCS)) for path, text in pages.items() if OLD_SH in text or OLD_PS1 in text) self.assertEqual(long_form, ["wiki/installer.md"]) diff --git a/tests/test_site_content_data.py b/tests/test_site_content_data.py index b7b66786b..a1a5c400e 100644 --- a/tests/test_site_content_data.py +++ b/tests/test_site_content_data.py @@ -13,6 +13,8 @@ import tests import ast import re import shutil +import subprocess +import sys import tempfile import unittest from pathlib import Path @@ -21,9 +23,9 @@ import yaml from sitegen import decorate from sitegen import nav as sitegen_nav -from model import guides +from model import guides, siteinputs from core.cli import SourceUnreadable -from model.guides import GUIDES, GuideError, load_guides +from model.guides import platform_guides, GuideError, load_guides REPO_ROOT = Path(__file__).resolve().parent.parent @@ -51,7 +53,7 @@ class GuidesLiveInYaml(unittest.TestCase): def test_every_registered_platform_has_a_guide_in_the_file(self): written = yaml.safe_load(_guides_text())["guides"] self.assertEqual(sorted(written), sorted(_registry())) - self.assertEqual(sorted(GUIDES), sorted(_registry())) + self.assertEqual(sorted(platform_guides()), sorted(_registry())) def test_a_platform_without_a_guide_is_named(self): data = yaml.safe_load(_guides_text()) @@ -88,7 +90,7 @@ class GuidesLiveInYaml(unittest.TestCase): registry = _registry() written = yaml.safe_load(_guides_text())["guides"]["batocera"]["folders"][0] self.assertNotIn("path", written) - self.assertEqual(GUIDES["batocera"].folders[0], + self.assertEqual(platform_guides()["batocera"].folders[0], (written["where"], f"`{registry['batocera']['extract_to']}`")) def test_a_folder_row_without_path_needs_an_extract_folder(self): @@ -110,6 +112,41 @@ class GuidesLiveInYaml(unittest.TestCase): self.assertEqual(guides.pack_manual("minui"), "") +class GuidesLoadOnFirstUse(unittest.TestCase): + """The guides were read and checked at import, from the repository's + platforms folder: a pack build died on a registry entry with no guide + before parsing its options, and a site run on another collection took + the repository's guides.""" + + def test_importing_the_pack_builder_reads_no_guide(self): + script = ("import sys\n" + "opened = []\n" + "sys.addaudithook(lambda event, args: opened.append(str(args[0]))" + " if event == 'open' else None)\n" + "import packs.platformpack, sitegen.build\n" + "print([path for path in opened if path.endswith(('_guides.yml', '_registry.yml'))])\n") + result = subprocess.run([sys.executable, "-c", script], cwd=REPO_ROOT / "scripts", + capture_output=True, text=True, check=True) + self.assertEqual(result.stdout.strip(), "[]") + + def test_the_guides_follow_the_platforms_folder_of_the_run(self): + with tempfile.TemporaryDirectory() as tmp: + folder = Path(tmp) + for name in ("_registry.yml", "_guides.yml"): + (folder / name).write_text( + (REPO_ROOT / "platforms" / name).read_text(encoding="utf-8"), encoding="utf-8") + data = yaml.safe_load(_guides_text()) + data["install_base"] = "https://example.org/x" + (folder / "_guides.yml").write_text(yaml.safe_dump(data), encoding="utf-8") + before = siteinputs.current() + siteinputs.use(siteinputs.SiteInputs(platforms=folder)) + try: + self.assertEqual(guides.install_sh(), f"https://example.org/x/{guides.SH_NAME}") + finally: + siteinputs.use(before) + self.assertNotEqual(guides.install_base(), "https://example.org/x") + + # A table of prose keyed by platform: what the guides file replaced. _PLATFORM_BRANCH = re.compile(r"""(?:==|!=)\s*["']([a-z0-9-]+)["']|["']([a-z0-9-]+)["']\s*(?:==|!=)""") # The modules that write the site and the pack README. diff --git a/tests/test_site_emulators.py b/tests/test_site_emulators.py index cc12d77cf..7b53cf648 100644 --- a/tests/test_site_emulators.py +++ b/tests/test_site_emulators.py @@ -729,7 +729,7 @@ class InstallBlockWhereItWorks(unittest.TestCase): def test_no_os_tab_outside_the_data_root(self) -> None: if not _generated(): self.skipTest("site pages not generated") - labels = {key: guides.TERMINALS[key][0] for key in guides.TERMINALS} + labels = {key: guides.terminals()[key][0] for key in guides.terminals()} for name, profile in _profiles_with_data_root().items(): allowed = {labels["device"]} for key in profile["data_root"]: diff --git a/tests/test_site_entry.py b/tests/test_site_entry.py index 8d81ecbad..da3ab26b9 100644 --- a/tests/test_site_entry.py +++ b/tests/test_site_entry.py @@ -95,7 +95,7 @@ class TrustItemsSayWhereItWrites(unittest.TestCase): for entry in json.loads(path.read_text(encoding="utf-8")).get("files", [])) ] self.assertTrue(saves, "no manifest files an entry under root: save") - text = " ".join(guides.TRUST_ITEMS).lower() + text = " ".join(guides.trust_items()).lower() self.assertNotIn("only in your bios folder", text) self.assertIn("save folder", text) self.assertIn("--restore", text) @@ -103,7 +103,7 @@ class TrustItemsSayWhereItWrites(unittest.TestCase): def test_home_shows_the_same_items(self): # A term's first use on the page carries its gloss. home = re.sub(r"]*>", "", _page("index.md")) - for item in guides.TRUST_ITEMS: + for item in guides.trust_items(): self.assertIn(f"- {item}", home) self.assertNotIn("only in your BIOS folder", home) @@ -156,7 +156,7 @@ class SetupTiles(unittest.TestCase): for name in ("index.md", "which-pack.md"): text = _page(name) with self.subTest(page=name): - extra = sum(len(tiles) for tiles in guides.GROUP_TILES.values()) + extra = sum(len(tiles) for tiles in guides.group_tiles().values()) self.assertEqual(text.count('class="rb-card rb-tile"'), len(REGISTRY) + extra) for key in REGISTRY: self.assertIn(f'href="/retrobios/platforms/{key}/"', text) @@ -177,7 +177,7 @@ class SetupTiles(unittest.TestCase): home = _page("index.md") display = {k: load_platform_config(k, str(REPO_ROOT / "platforms")).get("platform", k) for k in REGISTRY} - for group, (label, _description) in guides.DEVICE_GROUPS.items(): + for group, (label, _description) in guides.device_groups().items(): members = [k for k in REGISTRY if REGISTRY[k].get("device_group") == group] if len(members) == 1: with self.subTest(group=group): @@ -185,9 +185,9 @@ class SetupTiles(unittest.TestCase): self.assertIn(f">{display[members[0]]}", home) def test_hardware_is_named_and_cited(self): - self.assertIn("Raspberry Pi", guides.GUIDES["batocera"].summary) - self.assertIn("Raspberry Pi", guides.DEVICE_GROUPS["gaming-os"][0]) - self.assertIn("Anbernic", guides.DEVICE_GROUPS["handheld"][0]) + self.assertIn("Raspberry Pi", guides.platform_guides()["batocera"].summary) + self.assertIn("Raspberry Pi", guides.device_groups()["gaming-os"][0]) + self.assertIn("Anbernic", guides.device_groups()["handheld"][0]) lines = GUIDES_YAML.splitlines() for number, line in enumerate(lines): if re.match(r" (runs_on|terminal):", line): @@ -233,7 +233,7 @@ class GuideRoutes(unittest.TestCase): text = _page("platforms/batocera.md") self.assertLess(text.index("## From a computer"), text.index("## On the device")) self.assertIn("{ #install }", "\n".join(guidepage._guide_install( - "batocera", guides.GUIDES["batocera"], "## On the device { #install }"))) + "batocera", guides.platform_guides()["batocera"], "## On the device { #install }"))) self.assertIn("Unzip them all into the network folder above", text) def test_a_computer_app_keeps_the_command_first(self): @@ -241,8 +241,8 @@ class GuideRoutes(unittest.TestCase): self.assertLess(text.index("## Install"), text.index("## Download")) def test_each_device_tab_says_how_to_open_its_terminal(self): - shared = guides.TERMINALS["device"][1] - for name, guide in guides.GUIDES.items(): + shared = guides.terminals()["device"][1] + for name, guide in guides.platform_guides().items(): if "device" not in guide.run: continue with self.subTest(platform=name): @@ -265,7 +265,7 @@ class GuideRoutes(unittest.TestCase): class PackManualReadsThePageFolders(unittest.TestCase): def test_every_path_in_a_pack_manual_is_a_folder_of_its_page(self): - for name, guide in guides.GUIDES.items(): + for name, guide in guides.platform_guides().items(): if not guide.pack_manual: continue known = " ".join(path.replace("`", "") for _w, path in guides.folder_list(name)) @@ -326,7 +326,7 @@ class CommandBlocks(unittest.TestCase): self.assertEqual(sorted(set(sh_args)), sorted(set(ps_args))) self.assertEqual(len(set(sh_args)), 2) self.assertIn('```powershell title="PowerShell"', block) - for key, guide in guides.GUIDES.items(): + for key, guide in guides.platform_guides().items(): if "windows" in guide.run: with self.subTest(platform=key): self.assertIn("/i.ps1", _guide_part(_page(f"platforms/{key}.md"))) @@ -360,7 +360,7 @@ class HomeLinksTheOtherTasks(unittest.TestCase): self.assertLess(home.index("/retrobios/wiki/troubleshooting/"), home.index("## Is it needed? { #do-i-need-it }")) -GUIDE = guides.HANDHELD_GUIDE +GUIDE = guides.handheld_guide() def _plain_guide_part(text: str) -> str: @@ -376,7 +376,7 @@ def _display(key: str) -> str: class HandheldWayIn(unittest.TestCase): def test_android_and_linux_tiles_on_home_and_get_your_files(self): - tiles = guides.GROUP_TILES.get("handheld", ()) + tiles = guides.group_tiles().get("handheld", ()) self.assertEqual([tile.name for tile in tiles], ["Android", "Linux handhelds", "iPhone and iPad"]) for name in ("index.md", "which-pack.md"): @@ -432,7 +432,7 @@ class HandheldWayIn(unittest.TestCase): data = {"page": "x", "title": "X", "summary": "S", "uses": "retroarch", "systems": [{"name": "Onion"}]} with self.assertRaises(guides.GuideError): - guides._handheld_guide(data, REGISTRY, guides.GUIDES, "x") + guides._handheld_guide(data, REGISTRY, guides.platform_guides(), "x") def test_devices_are_a_search_field_with_no_text(self): text = _page(GUIDE.path) @@ -450,7 +450,7 @@ class HandheldWayIn(unittest.TestCase): setup = next(tab["Setups"] for tab in nav if "Setups" in tab) groups = {next(iter(item)): next(iter(item.values())) for item in setup if isinstance(item, dict)} - label = guides.DEVICE_GROUPS["handheld"][0] + label = guides.device_groups()["handheld"][0] self.assertIn({GUIDE.title: GUIDE.path}, groups[label]) def test_the_guide_fills_the_card_and_never_its_root(self): @@ -672,7 +672,7 @@ class DownloadLine(unittest.TestCase): self.assertRegex(line, r"\[SHA256SUMS\.txt\]\([^)]+\) and its \[signature\]\([^)]+\)\.$") -HANDHELDS = guides.HANDHELD_GUIDE +HANDHELDS = guides.handheld_guide() OFFLINE_ANCHOR = "#without-a-network-offline-install" @@ -686,7 +686,7 @@ def _with_zip(name: str) -> bool: return bool(pack and pack.get("assets")) -SETUPS = [name for name in guides.GUIDES if name in REGISTRY] +SETUPS = [name for name in guides.platform_guides() if name in REGISTRY] class NoZipNoUnzipText(unittest.TestCase): @@ -742,9 +742,9 @@ class NoZipNoUnzipText(unittest.TestCase): def test_the_network_route_needs_a_share_and_no_zip(self): for name in SETUPS: - share = guidepage._network_share(name, guides.GUIDES[name]) + share = guidepage._network_share(name, guides.platform_guides()[name]) with self.subTest(setup=name): - if _with_zip(name) or guides.GUIDES[name].run != ("device",): + if _with_zip(name) or guides.platform_guides()[name].run != ("device",): self.assertEqual(share, "") if share: self.assertTrue(share.startswith("\\\\")) @@ -818,7 +818,7 @@ class EntryCopy(unittest.TestCase): def test_the_setup_index_lists_the_handheld_tiles(self): text = _plain_page("platforms/index.md") - for tile in guides.GROUP_TILES["handheld"]: + for tile in guides.group_tiles()["handheld"]: target = tile.link.removesuffix(".md").replace(".md#", "/#") with self.subTest(tile=tile.name): self.assertIn(f"**[{tile.name}](/retrobios/{target}", text.replace("/)", ")")) @@ -827,7 +827,7 @@ class EntryCopy(unittest.TestCase): class IphoneAndIpad(unittest.TestCase): def test_a_tile_in_the_handheld_group(self): - tile = next(t for t in guides.GROUP_TILES["handheld"] if t.name == "iPhone and iPad") + tile = next(t for t in guides.group_tiles()["handheld"] if t.name == "iPhone and iPad") self.assertEqual(tile.link, "which-pack.md#iphone-and-ipad") for name in ("index.md", "which-pack.md"): with self.subTest(page=name): @@ -884,18 +884,18 @@ class GetPagesGiveTheSetupsOwnRoutes(unittest.TestCase): def test_a_card_setup_names_the_card(self): for name in SETUPS: - if not guides.GUIDES[name].on_card: + if not guides.platform_guides()[name].on_card: continue with self.subTest(setup=name): for command in COMMAND.findall(_plain_page(f"get/{name}.md")): self.assertIn("--dest ", command) def test_no_tab_for_a_system_the_setup_does_not_run_from(self): - labels = {key: entry[0] for key, entry in guides.TERMINALS.items()} + labels = {key: entry[0] for key, entry in guides.terminals().items()} for name in SETUPS: if _with_zip(name): continue - guide = guides.GUIDES[name] + guide = guides.platform_guides()[name] allowed = {labels[key] for key in guide.run} allowed |= {labels[key] for key in guide.card_run or ("windows", "macos", "linux")} if guidepage._network_share(name, guide): @@ -938,7 +938,7 @@ class CheckNeedsTheFiles(unittest.TestCase): class ARouteWithoutANetwork(unittest.TestCase): def test_every_setup_page_has_the_offline_line_or_the_card_route(self): for name in SETUPS: - guide = guides.GUIDES[name] + guide = guides.platform_guides()[name] text = _guide_part(_plain_page(f"platforms/{name}.md")) with self.subTest(setup=name): if _with_zip(name): @@ -951,7 +951,7 @@ class ARouteWithoutANetwork(unittest.TestCase): def test_every_device_setup_with_no_zip_links_the_card_answer(self): for name in SETUPS: - guide = guides.GUIDES[name] + guide = guides.platform_guides()[name] if _with_zip(name) or guide.run != ("device",): continue extract_to = REGISTRY[name]["extract_to"] @@ -968,7 +968,7 @@ class ARouteWithoutANetwork(unittest.TestCase): self.assertLess(text.index("## From a computer"), text.index("## On the device")) def test_retropie_card_is_read_from_linux_only(self): - self.assertEqual(guides.GUIDES["retropie"].card_run, ("linux",)) + self.assertEqual(guides.platform_guides()["retropie"].card_run, ("linux",)) text = _plain_page("platforms/retropie.md") card = text.split("No network?", 1)[1].split("## On the device", 1)[0] # One system, so no tab bar: its label leads the command. @@ -981,7 +981,7 @@ class ARouteWithoutANetwork(unittest.TestCase): folder neither can open.""" for name in ("lakka", "retropie"): with self.subTest(setup=name): - self.assertEqual(guides.GUIDES[name].card_run, ("linux",)) + self.assertEqual(guides.platform_guides()[name].card_run, ("linux",)) card = _plain_page(f"platforms/{name}.md").split("No network?", 1)[1] card = card.split("## On the device", 1)[0] self.assertEqual(_tab_labels(card), set()) @@ -1039,7 +1039,7 @@ class GetPagesSayWhatTheyHold(unittest.TestCase): class HandheldRowsSayWhere(unittest.TestCase): def test_retrooz_names_its_folder_with_a_pinned_source(self): - system = next(s for s in guides.HANDHELD_GUIDE.systems if s.name == "RetroOZ") + system = next(s for s in guides.handheld_guide().systems if s.name == "RetroOZ") self.assertIn("`/roms/bios`", system.folder) self.assertRegex(system.folder_source, r"/wiki/Home/[0-9a-f]{40}$") row = next(line for line in _plain_page("platforms/linux-handhelds.md").splitlines() @@ -1053,7 +1053,7 @@ class GetIndex(unittest.TestCase): for name in SETUPS: with self.subTest(setup=name): self.assertIn(f"(/retrobios/get/{name}/)", text) - for label, _description in guides.DEVICE_GROUPS.values(): + for label, _description in guides.device_groups().values(): self.assertIn(f"## {label}", text) diff --git a/tests/test_site_funnel.py b/tests/test_site_funnel.py index 547c2a111..1f1e0cafa 100644 --- a/tests/test_site_funnel.py +++ b/tests/test_site_funnel.py @@ -22,7 +22,7 @@ from sitegen import whichpack from tests import sitepages from model.registry import list_registered_platforms, load_platform_registry from model.platforms import load_platform_config -from model.guides import DEVICE_GROUPS, GROUP_ANCHORS, GUIDES +from model.guides import device_groups, group_anchors, platform_guides REPO_ROOT = Path(__file__).resolve().parent.parent @@ -83,11 +83,11 @@ class EveryPlatformOnThePicker(unittest.TestCase): registry = load_platform_registry(str(REPO_ROOT / "platforms")) for key in _registered(): with self.subTest(platform=key): - self.assertIn(registry[key].get("device_group"), DEVICE_GROUPS) - self.assertIn(key, GUIDES) + self.assertIn(registry[key].get("device_group"), device_groups()) + self.assertIn(key, platform_guides()) def test_every_group_has_an_anchor(self): - self.assertEqual(set(GROUP_ANCHORS), set(DEVICE_GROUPS)) + self.assertEqual(set(group_anchors()), set(device_groups())) def test_every_platform_has_a_row(self): page = _which_pack() @@ -130,16 +130,16 @@ class EveryPlatformOnThePicker(unittest.TestCase): groups = {next(iter(item)): next(iter(item.values())) for item in setup if isinstance(item, dict)} for key in coverages: - label = DEVICE_GROUPS[registry[key]["device_group"]][0] + label = device_groups()[registry[key]["device_group"]][0] with self.subTest(platform=key): self.assertIn({coverages[key]["platform"]: f"platforms/{key}.md"}, groups[label]) def test_handheld_systems_that_run_retroarch_are_named(self): """muOS, ArkOS and the rest are detected as RetroArch by the installer and were named on no page a user reads.""" - from model.guides import HANDHELD_GUIDE + from model.guides import handheld_guide - page = guidepage.generate_handheld_guide(HANDHELD_GUIDE) + page = guidepage.generate_handheld_guide(handheld_guide()) self.assertIn("| muOS |", page) self.assertIn("`MUOS/bios` on the card", page) self.assertNotIn("| TrimUI |", page) diff --git a/tests/test_site_handheld.py b/tests/test_site_handheld.py index 7eaf26dde..e6f716bb5 100644 --- a/tests/test_site_handheld.py +++ b/tests/test_site_handheld.py @@ -108,7 +108,7 @@ class WhereEachSystemFindsItsFile(unittest.TestCase): from sitegen import getpages from sitegen import guidepage - guide = guides.HANDHELD_GUIDE + guide = guides.handheld_guide() self.assertEqual(handhelds.GROUP_PAGE, guide.page) with contextlib.chdir(REPO_ROOT): self.assertIn(f"(../get/{handhelds.GROUP_PAGE}.md)", diff --git a/tests/test_site_integration.py b/tests/test_site_integration.py index c97e515fe..7b846d708 100644 --- a/tests/test_site_integration.py +++ b/tests/test_site_integration.py @@ -90,10 +90,10 @@ class PlatformLogos(unittest.TestCase): self.assertTrue(self.registry["minui"]["logo_flip"]) def test_every_logo_copy_has_a_registry_or_tile_logo(self): - from model.guides import GROUP_TILES + from model.guides import group_tiles tiles = {re.sub(r"[^a-z0-9]+", "-", tile.name.lower()).strip("-"): tile.logo - for group in GROUP_TILES.values() for tile in group} + for group in group_tiles().values() for tile in group} sources = json.loads((REPO_ROOT / "docs_assets" / "logos" / "sources.json").read_text()) for entry in sources["images"]: with self.subTest(platform=entry["platform"]): diff --git a/tests/test_site_nav.py b/tests/test_site_nav.py index b85542ca3..5f2abea0e 100644 --- a/tests/test_site_nav.py +++ b/tests/test_site_nav.py @@ -43,7 +43,7 @@ from core import anchors as core_anchors from model.registry import list_registered_platforms, load_platform_registry from model.platforms import load_platform_config -from model.guides import DEVICE_GROUPS +from model.guides import device_groups REPO_ROOT = Path(__file__).resolve().parents[1] @@ -82,7 +82,7 @@ def _index_anchors(markdown: str) -> set[str]: ANCHORS = { - "platforms/index.md": {core_anchors.toc_slug(label) for label, _ in DEVICE_GROUPS.values()}, + "platforms/index.md": {core_anchors.toc_slug(label) for label, _ in device_groups().values()}, "systems/index.md": {"consoles-and-computers"}, "emulators/index.md": _index_anchors(emulatorsindex.generate_emulators_index({ "duckstation": {"emulator": "DuckStation", "systems": ["sony-playstation"]}, @@ -476,9 +476,10 @@ def _moved_platform_pages() -> list[Path]: return [] # A guide page sits beside the setups (platforms/linux-handhelds) without # being a list moved off one of them. - from model.guides import HANDHELD_GUIDE + from model.guides import handheld_guide - guides = {Path(HANDHELD_GUIDE.path).stem} if HANDHELD_GUIDE else set() + handhelds = handheld_guide() + guides = {Path(handhelds.path).stem} if handhelds else set() return [path for path in sorted(folder.glob("*.md*")) if path.stem not in platforms and path.stem != "index" and path.stem not in guides] diff --git a/tests/test_site_page_text.py b/tests/test_site_page_text.py index aa8bb268a..d5d985df2 100644 --- a/tests/test_site_page_text.py +++ b/tests/test_site_page_text.py @@ -25,7 +25,7 @@ from pathlib import Path from sitegen import diagrams from sitegen import entries as siteentries from sitegen import steps as sitesteps -from model.guides import TERMINALS +from model.guides import terminals ROOT = Path(__file__).resolve().parent.parent @@ -166,7 +166,7 @@ class PageReadsOnce: for name, page in self.pages.items(): text = _letters(page.text) for tab, (title, steps) in sitesteps.STEPS.items(): - prose = _letters(TERMINALS[tab][1]) + prose = _letters(terminals()[tab][1]) with self.subTest(page=name, tab=tab): self.assertLessEqual(text.count(prose), 1) self.assertNotIn(_letters(title), text) diff --git a/tests/test_site_steps.py b/tests/test_site_steps.py index ae3787eb4..b636daf52 100644 --- a/tests/test_site_steps.py +++ b/tests/test_site_steps.py @@ -18,7 +18,7 @@ from pathlib import Path from sitegen import diagrams from sitegen import steps as sitesteps -from model.guides import TERMINALS +from model.guides import terminals ROOT = Path(__file__).resolve().parent.parent @@ -49,7 +49,7 @@ class EachDrawingNamesItsSteps(unittest.TestCase): def test_the_drawing_and_the_text_name_the_same_keys(self): for tab, (_title, steps) in sitesteps.STEPS.items(): - text = TERMINALS[tab][1].replace("**", "") + text = terminals()[tab][1].replace("**", "") keys = {step.word for step in steps if step.icon == "keys"} with self.subTest(tab=tab): for word in keys: diff --git a/tests/test_site_wiki.py b/tests/test_site_wiki.py index bb6710410..db3119dca 100644 --- a/tests/test_site_wiki.py +++ b/tests/test_site_wiki.py @@ -46,7 +46,7 @@ from pathlib import Path import yaml from sitegen import diagrams, ogcards, pageprep -from model.guides import INSTALL_SH +from model.guides import install_sh from tests import sitepages from installer_build import port from installer_build.module import installer_module @@ -133,7 +133,7 @@ class InstallCommandsHaveEveryForm(unittest.TestCase): def test_a_windows_path_replaces_the_unix_one(self): page = ( "\n```sh\n" - f"curl -fsSL {INSTALL_SH} \\\n | sh -s -- --platform retroarch --dest /a/b\n```\n" + f"curl -fsSL {install_sh()} \\\n | sh -s -- --platform retroarch --dest /a/b\n```\n" ) text = pageprep.expand_commands(page) windows, rest = text.split('', 1) @@ -1054,7 +1054,7 @@ class OsTabsTakeOptionsPerSystem(unittest.TestCase): """The marker gives any tab its own options, and refuses words it cannot read.""" PAGE = ("\n" - f"```sh\ncurl -fsSL {INSTALL_SH} | sh -s -- --dest /l\n```\n") + f"```sh\ncurl -fsSL {install_sh()} | sh -s -- --dest /l\n```\n") def test_each_named_tab_uses_its_own(self): parts = re.split(r'', pageprep.expand_commands(self.PAGE))