From 88ea3d58ad20284e7b93cf37525954505a3a7a9a Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 24 Nov 2026 03:46:21 +0100 Subject: [PATCH] refactor: one naming style per package --- .github/workflows/deploy-site.yml | 2 +- docs_assets/images-needed.md | 2 +- .../{crypto_verify.py => cryptoverify.py} | 0 scripts/freshness/catalogs.py | 2 +- scripts/freshness/profiles.py | 4 +- scripts/model/profiles.py | 2 +- scripts/profiling/bump.py | 12 +-- scripts/profiling/run.py | 2 +- scripts/profiling/sourcepaths.py | 6 +- scripts/profiling/triage.py | 2 +- .../{version_basis.py => versionbasis.py} | 0 scripts/profiling/versioncheck.py | 14 ++-- scripts/profiling/versions.py | 2 +- scripts/resolve/validation.py | 4 +- scripts/scraper/arcade_parent_importer.py | 2 +- scripts/scraper/{datfetch.py => dat_fetch.py} | 0 scripts/scraper/mame_hash_scraper.py | 2 +- scripts/scraper/romset_dat_importer.py | 2 +- scripts/{sitediagrams.py => site_diagrams.py} | 0 scripts/{sitesources.py => site_sources.py} | 0 tests/sources.py | 6 +- tests/test_check_freshness.py | 8 +- tests/test_crypto_aes.py | 8 +- tests/test_crypto_unique_data.py | 58 +++++++------- tests/test_crypto_verify.py | 36 ++++----- tests/test_profile_sync.py | 20 ++--- tests/test_romset_recipes.py | 32 ++++---- tests/test_scraper_contract.py | 2 +- tests/test_site_integration.py | 2 +- tests/test_system_selection.py | 6 +- tests/test_version_basis.py | 78 +++++++++---------- tests/test_workflow_paths.py | 2 +- website/src/styles/retrobios.css | 6 +- wiki/architecture.md | 2 +- wiki/tools.md | 10 +-- 35 files changed, 168 insertions(+), 168 deletions(-) rename scripts/core/{crypto_verify.py => cryptoverify.py} (100%) rename scripts/profiling/{version_basis.py => versionbasis.py} (100%) rename scripts/scraper/{datfetch.py => dat_fetch.py} (100%) rename scripts/{sitediagrams.py => site_diagrams.py} (100%) rename scripts/{sitesources.py => site_sources.py} (100%) diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index 28beb3135..24b289a37 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -17,7 +17,7 @@ on: - "scripts/core/anchors.py" - "scripts/core/artifacts.py" - "scripts/core/cli.py" - - "scripts/core/crypto_verify.py" + - "scripts/core/cryptoverify.py" - "scripts/core/gitclone.py" - "scripts/core/github.py" - "scripts/core/hashing.py" diff --git a/docs_assets/images-needed.md b/docs_assets/images-needed.md index 4bc29a921..c7bbf25df 100644 --- a/docs_assets/images-needed.md +++ b/docs_assets/images-needed.md @@ -3,7 +3,7 @@ These pictures show a real screen, so they are captured on a real install and never drawn as a mock-up. Each entry says what the capture must show, where it goes, and the alt text it carries. Folder layouts that follow from data are -drawn by `scripts/sitediagrams.py` instead (the MinUI card tree is +drawn by `scripts/site_diagrams.py` instead (the MinUI card tree is ``). Captures: PNG or WebP, 1200 px wide at most, cropped tight, under 150 KB, diff --git a/scripts/core/crypto_verify.py b/scripts/core/cryptoverify.py similarity index 100% rename from scripts/core/crypto_verify.py rename to scripts/core/cryptoverify.py diff --git a/scripts/freshness/catalogs.py b/scripts/freshness/catalogs.py index b38c0284e..0f361b8d3 100644 --- a/scripts/freshness/catalogs.py +++ b/scripts/freshness/catalogs.py @@ -12,7 +12,7 @@ from pathlib import Path from core import upstream from core.paths import REPO_ROOT from scripts.scraper import game_dat_importer -from scripts.scraper.datfetch import is_tracked_dat, label_version +from scripts.scraper.dat_fetch import is_tracked_dat, label_version from scripts.scraper.redump_dat_scraper import fetch_snapshot from freshness.findings import ( FBNEO_RECIPES, MAME_RECIPES, NO_INTRO_GAMES, OK, REDUMP_GAMES, SKIPPED, STALE, UNKNOWN, diff --git a/scripts/freshness/profiles.py b/scripts/freshness/profiles.py index 289cade18..011f0444e 100644 --- a/scripts/freshness/profiles.py +++ b/scripts/freshness/profiles.py @@ -14,7 +14,7 @@ def check_source_paths(profiles: dict) -> Finding: """The site links a cited path only where source-paths.json records it in the tree the profile pins. A recorded tree no profile pins any more, or a pinned tree the record lacks, means a pin moved or a profile was - added and `sitesources.py --fetch` was not run after it. Every tree a run + added and `site_sources.py --fetch` was not run after it. Every tree a run tries is recorded, read or not, so a lacking one was never tried.""" from sitegen import sources as sitegen_sources @@ -34,7 +34,7 @@ def check_source_paths(profiles: dict) -> Finding: "source-paths.json", STALE if problems else OK, local=f"{len(recorded)} trees", - detail=(", ".join(problems) + ": run python scripts/sitesources.py --fetch") if problems + detail=(", ".join(problems) + ": run python scripts/site_sources.py --fetch") if problems else "every pinned tree is recorded, and only those", ) diff --git a/scripts/model/profiles.py b/scripts/model/profiles.py index 648e37b19..8a0a6b9a5 100644 --- a/scripts/model/profiles.py +++ b/scripts/model/profiles.py @@ -220,7 +220,7 @@ def load_emulator_profiles( emu_path = Path(emulators_dir) if not emu_path.is_dir(): # Read as "no emulator", a mistyped --emulators-dir built a pack - # without any core file marked OK, and sitesources wrote {} over + # without any core file marked OK, and site_sources wrote {} over # source-paths.json, both exiting 0. raise InputMissing(f"no emulator profile directory at {emulators_dir}") for f in source_yaml_paths(emu_path): diff --git a/scripts/profiling/bump.py b/scripts/profiling/bump.py index ead899ad1..d98c87ba1 100644 --- a/scripts/profiling/bump.py +++ b/scripts/profiling/bump.py @@ -15,7 +15,7 @@ from core import upstream from model.platforms import load_platform_config from model.profiles import load_emulator_profiles from model.registry import list_registered_platforms -from profiling import version_basis +from profiling import versionbasis from profiling.anchoring import REVIEW_STATUSES from profiling.rebase import pending_recale, pin_blockers from profiling.reports import ProfileReport, SkipKind @@ -37,7 +37,7 @@ def apply_readings(document: dict, readings: list) -> tuple[object, dict | None] if isinstance(version, dict): version = dict(version) for reading in readings: - if reading.status not in (version_basis.MATCH, version_basis.DRIFT): + if reading.status not in (versionbasis.MATCH, versionbasis.DRIFT): continue if reading.mode: if not isinstance(version, dict): @@ -190,7 +190,7 @@ def bump_commit( new_text = _set_pin( new_text, document, "upstream_commit", report.upstream_head, "source_commit" ) - readings = version_basis.check(expected, cache_dir, offline, recompute=True) + readings = versionbasis.check(expected, cache_dir, offline, recompute=True) refused = version_refusal(readings) if refused: return Bump(False, f"{refused}, its pin is not advanced") @@ -207,11 +207,11 @@ def bump_commit( def version_refusal(readings: list) -> str | None: """Why the version at a new pin cannot be stated, or None.""" for reading in readings: - if reading.status == version_basis.NO_BASIS: + if reading.status == versionbasis.NO_BASIS: return "no version_basis says where its version is read" - if reading.status == version_basis.UNREADABLE: + if reading.status == versionbasis.UNREADABLE: return f"core_version cannot be read at the new pin: {reading.where}" - if reading.status == version_basis.UNCHECKED: + if reading.status == versionbasis.UNCHECKED: return f"core_version is {reading.where}, not read from the code at a pin" return None diff --git a/scripts/profiling/run.py b/scripts/profiling/run.py index adeff6061..f8ed33862 100644 --- a/scripts/profiling/run.py +++ b/scripts/profiling/run.py @@ -29,7 +29,7 @@ from profiling.sourcepaths import record_write from profiling.triage import ( PROGRESS_SECONDS, Progress, print_interrupted, print_triage, score_reports, scored_to_dict, ) -from profiling.version_basis import VersionTag, version_tags +from profiling.versionbasis import VersionTag, version_tags from profiling.versions import ( VersionReport, check_version, diff --git a/scripts/profiling/sourcepaths.py b/scripts/profiling/sourcepaths.py index 6d500a9ba..7ad405991 100644 --- a/scripts/profiling/sourcepaths.py +++ b/scripts/profiling/sourcepaths.py @@ -33,7 +33,7 @@ def refresh_source_paths(args: argparse.Namespace, written: set[str]) -> None: """Rebuild the site's record of cited source paths after a write. Each bump left website/src/data/source-paths.json behind its pins, and - the site's freshness test stayed red until someone ran sitesources.py + the site's freshness test stayed red until someone ran site_sources.py --fetch by hand. A run that writes nothing, or makes no request, leaves it alone. The record describes the repository's profiles: a pass over another tree prints the command for it instead of reducing the record @@ -44,7 +44,7 @@ def refresh_source_paths(args: argparse.Namespace, written: set[str]) -> None: if Path(args.emulators_dir).resolve() != (REPO_ROOT / EMULATORS_DIR).resolve(): print( f"source paths not refreshed: {args.emulators_dir} is not the repository's " - f"{EMULATORS_DIR}/: run python scripts/sitesources.py --fetch " + f"{EMULATORS_DIR}/: run python scripts/site_sources.py --fetch " f"--emulators-dir {args.emulators_dir} --cache-dir {args.cache_dir} " "--output to record them", file=sys.stderr, @@ -66,7 +66,7 @@ def refresh_source_paths(args: argparse.Namespace, written: set[str]) -> None: except ArtifactLockBusy as exc: # The profiles are written: only the record waits for the other run. print( - f"source paths not refreshed ({exc}): run python scripts/sitesources.py " + f"source paths not refreshed ({exc}): run python scripts/site_sources.py " "--fetch once it finishes", file=sys.stderr, ) diff --git a/scripts/profiling/triage.py b/scripts/profiling/triage.py index c4f188d01..b2f0fdd06 100644 --- a/scripts/profiling/triage.py +++ b/scripts/profiling/triage.py @@ -10,7 +10,7 @@ from dataclasses import dataclass, field from core import upstream from profiling.reports import ProfileReport, report_to_dict, triage_state -from profiling.version_basis import version_repo, version_tags +from profiling.versionbasis import version_repo, version_tags from profiling.versions import VersionReport, check_version diff --git a/scripts/profiling/version_basis.py b/scripts/profiling/versionbasis.py similarity index 100% rename from scripts/profiling/version_basis.py rename to scripts/profiling/versionbasis.py diff --git a/scripts/profiling/versioncheck.py b/scripts/profiling/versioncheck.py index e4e7f2771..c9f212d0e 100644 --- a/scripts/profiling/versioncheck.py +++ b/scripts/profiling/versioncheck.py @@ -9,19 +9,19 @@ from collections import Counter from dataclasses import asdict from pathlib import Path -from profiling import version_basis +from profiling import versionbasis from profiling.bump import write_version from profiling.worktree import refuse_dirty_tree from profiling.yamledit import YamlWriteError -def format_reading(name: str, reading: version_basis.Reading) -> str: +def format_reading(name: str, reading: versionbasis.Reading) -> str: """One reading as a line: its status, the version said, and where it was read.""" mode = f"[{reading.mode}] " if reading.mode else "" kind = f"{reading.kind} " if reading.kind else "" - if reading.status == version_basis.DRIFT: + if reading.status == versionbasis.DRIFT: said = f"declared {reading.declared}, code {reading.read}" - elif reading.status == version_basis.MATCH: + elif reading.status == versionbasis.MATCH: said = str(reading.read) else: said = f"declared {reading.declared}" @@ -36,13 +36,13 @@ def run_versions(args: argparse.Namespace, profiles: dict, selected: dict) -> No rows = [] failed = False for name, profile in selected.items(): - readings = version_basis.check( + readings = versionbasis.check( profile, args.cache_dir, args.offline, profiles, recompute=args.set_version ) for reading in readings: counts[reading.status] += 1 rows.append({"profile": name, **asdict(reading)}) - if not args.as_json and (not args.changed_only or reading.status != version_basis.MATCH): + if not args.as_json and (not args.changed_only or reading.status != versionbasis.MATCH): print(format_reading(name, reading)) if args.set_version: path = Path(args.emulators_dir) / f"{name}.yml" @@ -54,7 +54,7 @@ def run_versions(args: argparse.Namespace, profiles: dict, selected: dict) -> No except YamlWriteError as exc: print(f"{name}: write refused: {exc}", file=sys.stderr) failed = True - elif any(r.status in version_basis.FAILING for r in readings): + elif any(r.status in versionbasis.FAILING for r in readings): failed = True if args.as_json: print(json.dumps(rows, indent=2)) diff --git a/scripts/profiling/versions.py b/scripts/profiling/versions.py index ef5e12b0c..aa9ad8df0 100644 --- a/scripts/profiling/versions.py +++ b/scripts/profiling/versions.py @@ -6,7 +6,7 @@ import re from dataclasses import dataclass from core import upstream -from profiling.version_basis import VersionTag, declared +from profiling.versionbasis import VersionTag, declared @dataclass(frozen=True) diff --git a/scripts/resolve/validation.py b/scripts/resolve/validation.py index 439566f57..2c0beff10 100644 --- a/scripts/resolve/validation.py +++ b/scripts/resolve/validation.py @@ -199,7 +199,7 @@ def _rule_failure( if check not in skip and not content_fits({"validation": [check], check: spec}, local_path): return _CONTENT_REASONS[check] if rule["crypto"] - skip: - from core.crypto_verify import check_crypto_validation + from core.cryptoverify import check_crypto_validation return check_crypto_validation(local_path, filename, bios_dir) return None @@ -527,7 +527,7 @@ def check_file_validation( # Signature/crypto checks (3DS RSA, AES) if entry["crypto_only"]: - from core.crypto_verify import check_crypto_validation + from core.cryptoverify import check_crypto_validation crypto_reason = check_crypto_validation(local_path, filename, bios_dir) if crypto_reason: diff --git a/scripts/scraper/arcade_parent_importer.py b/scripts/scraper/arcade_parent_importer.py index 063f03be4..ed4d963bc 100644 --- a/scripts/scraper/arcade_parent_importer.py +++ b/scripts/scraper/arcade_parent_importer.py @@ -61,7 +61,7 @@ from .fbneo_parser import zip_name from .clex import DriverSourceError, blank_comments, call_args, call_span from .listxml import Opener, attrs, iter_elements, open_listxml, rom_members from model.mamerelease import mame_tag -from .datfetch import MAME_LISTXML_URL, api_json, cached_pack, fetch_pack +from .dat_fetch import MAME_LISTXML_URL, api_json, cached_pack, fetch_pack SCHEMA_VERSION = 1 DEFAULT_OUTPUT = Path("games") / "arcade" diff --git a/scripts/scraper/datfetch.py b/scripts/scraper/dat_fetch.py similarity index 100% rename from scripts/scraper/datfetch.py rename to scripts/scraper/dat_fetch.py diff --git a/scripts/scraper/mame_hash_scraper.py b/scripts/scraper/mame_hash_scraper.py index 93950000e..3fc77aae8 100644 --- a/scripts/scraper/mame_hash_scraper.py +++ b/scripts/scraper/mame_hash_scraper.py @@ -58,7 +58,7 @@ from .mame_devices import ( ) from .listxml import open_listxml from model.mamerelease import mame_tag, mame_version -from .datfetch import fetch_pack +from .dat_fetch import fetch_pack from .sparse_clone import fresh_cache, remove_clone, sparse_clone from .mame_parser import parse_mame_source_tree from core.paths import EMULATORS_DIR, PLATFORMS_DIR, REPO_ROOT diff --git a/scripts/scraper/romset_dat_importer.py b/scripts/scraper/romset_dat_importer.py index 02f0401e2..e309b2f1b 100644 --- a/scripts/scraper/romset_dat_importer.py +++ b/scripts/scraper/romset_dat_importer.py @@ -50,7 +50,7 @@ from model.database import load_database from model.dumpcatalog import build_snapshot, load_provenance_snapshots, write_snapshot from resolve.localfile import variant_base_name from .base_scraper import BlobMismatchError, fetch_github_latest_version -from .datfetch import fetch_pack, mame_label +from .dat_fetch import fetch_pack, mame_label from .listxml import ( Opener, iter_dat_documents, diff --git a/scripts/sitediagrams.py b/scripts/site_diagrams.py similarity index 100% rename from scripts/sitediagrams.py rename to scripts/site_diagrams.py diff --git a/scripts/sitesources.py b/scripts/site_sources.py similarity index 100% rename from scripts/sitesources.py rename to scripts/site_sources.py diff --git a/tests/sources.py b/tests/sources.py index 683f827bd..ec1c0949b 100644 --- a/tests/sources.py +++ b/tests/sources.py @@ -87,8 +87,8 @@ COMMANDS = { "sitegen/extraction.py", "sitegen/releasepacks.py", "sitegen/archivecounts.py", "packs/crossref.py", ), - "sitediagrams.py": ("sitegen/diagrams.py",), - "sitesources.py": ("sitegen/sources.py",), + "site_diagrams.py": ("sitegen/diagrams.py",), + "site_sources.py": ("sitegen/sources.py",), "site_markdown.py": ("sitegen/pagemarkdown.py",), "validate_site.py": ("sitegen/validate.py",), "site_insights.py": ("sitegen/insights.py",), @@ -175,7 +175,7 @@ COMMANDS = { "profile_sync.py": ( "profiling/citations.py", "profiling/anchoring.py", "profiling/repos.py", "profiling/resolver.py", "profiling/reports.py", "profiling/versions.py", - "profiling/version_basis.py", "profiling/detection.py", "profiling/triage.py", + "profiling/versionbasis.py", "profiling/detection.py", "profiling/triage.py", "profiling/yamledit.py", "profiling/proseedit.py", "profiling/rebase.py", "profiling/bump.py", "profiling/realign.py", "profiling/run.py", "profiling/worktree.py", "profiling/quota.py", "profiling/sourcepaths.py", "profiling/realignpass.py", diff --git a/tests/test_check_freshness.py b/tests/test_check_freshness.py index aee4e10fc..466b79843 100644 --- a/tests/test_check_freshness.py +++ b/tests/test_check_freshness.py @@ -71,7 +71,7 @@ from model.romfolders import load_sources, sources_dir from model.safeparse import yaml_load from model.targets import platform_overrides from profiling.reports import ProfileReport, SkipKind, report_to_dict -from scripts.scraper import datfetch, game_dat_importer +from scripts.scraper import dat_fetch, game_dat_importer from tests.sources import SCRIPTS REPO_ROOT = Path(__file__).resolve().parents[1] @@ -648,11 +648,11 @@ class CatalogParsingTests(unittest.TestCase): self.assertEqual(mame_versions(recipes), ["mame0250", "mame0289"]) def test_versions_and_blobs_follow_the_importer_rules(self): - recipes = {"dats": {datfetch.mame_label("mame0289lx"): "mame0289lx"}} + recipes = {"dats": {dat_fetch.mame_label("mame0289lx"): "mame0289lx"}} self.assertEqual(mame_versions(recipes), ["mame0289"]) # The check asks the importer which DATs it reads, never a copy of the rule. - self.assertIs(freshness.catalogs.is_tracked_dat, datfetch.is_tracked_dat) - self.assertIs(freshness.catalogs.label_version, datfetch.label_version) + self.assertIs(freshness.catalogs.is_tracked_dat, dat_fetch.is_tracked_dat) + self.assertIs(freshness.catalogs.label_version, dat_fetch.label_version) def _rows(*reports: ProfileReport) -> list[dict]: diff --git a/tests/test_crypto_aes.py b/tests/test_crypto_aes.py index 4e6ea15a6..e9a6eb268 100644 --- a/tests/test_crypto_aes.py +++ b/tests/test_crypto_aes.py @@ -13,7 +13,7 @@ import ast import unittest from pathlib import Path -from core import crypto_verify +from core import cryptoverify REPO_ROOT = Path(__file__).resolve().parents[1] @@ -24,7 +24,7 @@ class StdlibAes(unittest.TestCase): def test_fips_197_vector(self): key = bytes.fromhex("000102030405060708090a0b0c0d0e0f") cipher = bytes.fromhex("69c4e0d86a7b0430d8cdb78070b4c55a") - plain = crypto_verify._decrypt_block(cipher, crypto_verify._expand_key(key)) + plain = cryptoverify._decrypt_block(cipher, cryptoverify._expand_key(key)) self.assertEqual(plain.hex(), "00112233445566778899aabbccddeeff") def test_cbc_chains_blocks(self): @@ -35,12 +35,12 @@ class StdlibAes(unittest.TestCase): "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b2" ) self.assertEqual( - crypto_verify._aes_128_cbc_decrypt(cipher, key, iv).hex(), + cryptoverify._aes_128_cbc_decrypt(cipher, key, iv).hex(), "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51", ) def test_no_third_party_import(self): - tree = ast.parse((REPO_ROOT / "scripts" / "core" / "crypto_verify.py").read_text()) + tree = ast.parse((REPO_ROOT / "scripts" / "core" / "cryptoverify.py").read_text()) modules = { (node.module if isinstance(node, ast.ImportFrom) else alias.name).split(".")[0] for node in ast.walk(tree) diff --git a/tests/test_crypto_unique_data.py b/tests/test_crypto_unique_data.py index d9795ea76..0194e6ddb 100644 --- a/tests/test_crypto_unique_data.py +++ b/tests/test_crypto_unique_data.py @@ -26,7 +26,7 @@ import tempfile import unittest from pathlib import Path -from core import crypto_verify +from core import cryptoverify from core import sect233r1 as ec # A 2048-bit RSA key, the size the 3DS signatures use, from two fixed primes @@ -108,26 +108,26 @@ class SecureInfoA(_Fixture): return self._write("SecureInfo_A", _rsa_sign(sign or body) + body) def test_a_correctly_signed_file_verifies(self): - ok, reason = crypto_verify.verify_secure_info_a(self._file(), _keys()) + ok, reason = cryptoverify.verify_secure_info_a(self._file(), _keys()) self.assertTrue(ok, reason) self.assertEqual(reason, "signature valid") def test_wrong_size_is_refused_before_anything_else(self): path = self._write("SecureInfo_A", b"\x00" * 100) - ok, reason = crypto_verify.verify_secure_info_a(path, _keys()) + ok, reason = cryptoverify.verify_secure_info_a(path, _keys()) self.assertFalse(ok) self.assertIn("size mismatch", reason) def test_an_all_zero_serial_is_refused(self): body = bytes([1]) + b"\x00" + b"\x00" * 15 - ok, reason = crypto_verify.verify_secure_info_a(self._file(body), _keys()) + ok, reason = cryptoverify.verify_secure_info_a(self._file(body), _keys()) self.assertFalse(ok) self.assertIn("serial_number is all zeros", reason) def test_missing_keys_are_reported_rather_than_guessed(self): keys = _keys() keys["RSA"].pop("secureInfoMod") - ok, reason = crypto_verify.verify_secure_info_a(self._file(), keys) + ok, reason = cryptoverify.verify_secure_info_a(self._file(), keys) self.assertFalse(ok) self.assertIn("missing RSA keys", reason) @@ -135,7 +135,7 @@ class SecureInfoA(_Fixture): body = _secure_info_body() tampered = body[:2] + b"X" + body[3:] path = self._write("SecureInfo_A", _rsa_sign(body) + tampered) - ok, reason = crypto_verify.verify_secure_info_a(path, _keys()) + ok, reason = cryptoverify.verify_secure_info_a(path, _keys()) self.assertFalse(ok) self.assertEqual(reason, "signature invalid") @@ -144,7 +144,7 @@ class SecureInfoA(_Fixture): signed = _secure_info_body(region=2) shipped = _secure_info_body(region=5) path = self._write("SecureInfo_A", _rsa_sign(signed) + shipped) - ok, reason = crypto_verify.verify_secure_info_a(path, _keys()) + ok, reason = cryptoverify.verify_secure_info_a(path, _keys()) self.assertFalse(ok) self.assertIn("region changed from 2 to 5", reason) @@ -155,17 +155,17 @@ class LocalFriendCodeSeedB(_Fixture): return self._write("LocalFriendCodeSeed_B", _rsa_sign(sign or body) + body) def test_a_correctly_signed_file_verifies(self): - ok, reason = crypto_verify.verify_local_friend_code_seed_b(self._file(), _keys()) + ok, reason = cryptoverify.verify_local_friend_code_seed_b(self._file(), _keys()) self.assertTrue(ok, reason) def test_wrong_size_is_refused(self): path = self._write("LocalFriendCodeSeed_B", b"\x00" * 0x111) - ok, reason = crypto_verify.verify_local_friend_code_seed_b(path, _keys()) + ok, reason = cryptoverify.verify_local_friend_code_seed_b(path, _keys()) self.assertFalse(ok) self.assertIn("size mismatch", reason) def test_a_zero_friend_code_seed_is_refused(self): - ok, reason = crypto_verify.verify_local_friend_code_seed_b( + ok, reason = cryptoverify.verify_local_friend_code_seed_b( self._file(_lfcs_body(seed=0)), _keys() ) self.assertFalse(ok) @@ -176,14 +176,14 @@ class LocalFriendCodeSeedB(_Fixture): path = self._write( "LocalFriendCodeSeed_B", _rsa_sign(body) + _lfcs_body(seed=0xDEAD) ) - ok, reason = crypto_verify.verify_local_friend_code_seed_b(path, _keys()) + ok, reason = cryptoverify.verify_local_friend_code_seed_b(path, _keys()) self.assertFalse(ok) self.assertEqual(reason, "signature invalid") def test_missing_keys_are_reported(self): keys = _keys() keys["RSA"].pop("lfcsExp") - ok, reason = crypto_verify.verify_local_friend_code_seed_b(self._file(), keys) + ok, reason = cryptoverify.verify_local_friend_code_seed_b(self._file(), keys) self.assertFalse(ok) self.assertIn("missing RSA keys", reason) @@ -198,27 +198,27 @@ class MovableSed(_Fixture): return self._write("movable.sed", bytes(data)) def test_the_short_variant_verifies(self): - ok, reason = crypto_verify.verify_movable_sed(self._file(), _keys()) + ok, reason = cryptoverify.verify_movable_sed(self._file(), _keys()) self.assertTrue(ok, reason) self.assertIn("magic valid", reason) def test_the_long_variant_verifies(self): - ok, reason = crypto_verify.verify_movable_sed(self._file(size=0x140), _keys()) + ok, reason = cryptoverify.verify_movable_sed(self._file(size=0x140), _keys()) self.assertTrue(ok, reason) def test_a_wrong_magic_is_refused(self): - ok, reason = crypto_verify.verify_movable_sed(self._file(magic=b"SEXD"), _keys()) + ok, reason = cryptoverify.verify_movable_sed(self._file(magic=b"SEXD"), _keys()) self.assertFalse(ok) self.assertIn("invalid magic", reason) def test_an_unexpected_size_is_refused(self): path = self._write("movable.sed", b"\x00" * 0x130) - ok, reason = crypto_verify.verify_movable_sed(path, _keys()) + ok, reason = cryptoverify.verify_movable_sed(path, _keys()) self.assertFalse(ok) self.assertIn("size mismatch", reason) def test_a_tampered_embedded_seed_fails_while_the_magic_still_passes(self): - ok, reason = crypto_verify.verify_movable_sed(self._file(seed=0xBADF00D), _keys()) + ok, reason = cryptoverify.verify_movable_sed(self._file(seed=0xBADF00D), _keys()) self.assertFalse(ok) self.assertEqual(reason, "magic valid, LFCS signature invalid") @@ -271,7 +271,7 @@ def _root_public() -> bytes: class Otp(_Fixture): def test_a_decrypted_otp_passes_every_stage(self): path = self._write("otp.bin", _otp_plaintext()) - ok, reason = crypto_verify.verify_otp( + ok, reason = cryptoverify.verify_otp( path, _keys(ECC={"rootPublicXY": _root_public()}) ) self.assertTrue(ok, reason) @@ -279,13 +279,13 @@ class Otp(_Fixture): def test_without_a_root_key_the_ecc_stage_is_skipped_not_faked(self): path = self._write("otp.bin", _otp_plaintext()) - ok, reason = crypto_verify.verify_otp(path, _keys()) + ok, reason = cryptoverify.verify_otp(path, _keys()) self.assertTrue(ok) self.assertIn("ECC skipped", reason) def test_wrong_size_is_refused(self): path = self._write("otp.bin", b"\x00" * 0xFF) - ok, reason = crypto_verify.verify_otp(path, _keys()) + ok, reason = cryptoverify.verify_otp(path, _keys()) self.assertFalse(ok) self.assertIn("size mismatch", reason) @@ -293,13 +293,13 @@ class Otp(_Fixture): data = bytearray(_otp_plaintext()) data[0x30] ^= 0xFF path = self._write("otp.bin", bytes(data)) - ok, reason = crypto_verify.verify_otp(path, _keys()) + ok, reason = cryptoverify.verify_otp(path, _keys()) self.assertFalse(ok) self.assertIn("SHA-256 hash mismatch", reason) def test_an_unsigned_certificate_is_refused(self): path = self._write("otp.bin", _otp_plaintext(sign=False)) - ok, reason = crypto_verify.verify_otp( + ok, reason = cryptoverify.verify_otp( path, _keys(ECC={"rootPublicXY": _root_public()}) ) self.assertFalse(ok) @@ -311,7 +311,7 @@ class Otp(_Fixture): struct.pack_into(" str | None: - return crypto_verify.check_crypto_validation(str(self.file), "otp.bin", str(self.bios)) + return cryptoverify.check_crypto_validation(str(self.file), "otp.bin", str(self.bios)) def test_the_same_file_is_verified_once(self): self.assertEqual([self.check() for _ in range(7)], ["first byte is not 1"] * 7) diff --git a/tests/test_profile_sync.py b/tests/test_profile_sync.py index 2dfa9c230..732e7934a 100644 --- a/tests/test_profile_sync.py +++ b/tests/test_profile_sync.py @@ -76,7 +76,7 @@ from profiling.rebase import Recale, rebase_refs from profiling.repos import select_repo from model.sourceref import RefPart, parse_source_ref, split_source_ref from core import upstream -from profiling import version_basis +from profiling import versionbasis from core.upstream import CompareResult, FileChange @@ -84,11 +84,11 @@ def _version_read_as_written(profile, cache_dir, offline, profiles=None, recompu """bump_commit reads core_version again at the new pin. These fixtures have no forge behind them, so the version reads as written here: tests/test_version_basis.py holds the reading and the refusals.""" - stated = version_basis.declared(profile, "") - return [version_basis.Reading("", "file", stated, stated, "fixture", version_basis.MATCH)] + stated = versionbasis.declared(profile, "") + return [versionbasis.Reading("", "file", stated, stated, "fixture", versionbasis.MATCH)] -_VERSION_AS_WRITTEN = mock.patch.object(version_basis, "check", _version_read_as_written) +_VERSION_AS_WRITTEN = mock.patch.object(versionbasis, "check", _version_read_as_written) def setUpModule(): @@ -3722,7 +3722,7 @@ class TestCheckVersion(unittest.TestCase): upstream.tag_commit = upstream.resolve_tag_commit def _check(self, declared, tag=None): - named = version_basis.VersionTag("", declared, tag or declared, 0, self.repo, "source") + named = versionbasis.VersionTag("", declared, tag or declared, 0, self.repo, "source") return check_version(named, self.dir, False) def tearDown(self): @@ -5270,7 +5270,7 @@ class TestRateLimitEndsOneProfile(unittest.TestCase): class AWriteRefreshesTheSourcePaths(unittest.TestCase): """Each bump left website/src/data/source-paths.json behind its pins and - the site's freshness test red until someone ran sitesources by hand.""" + the site's freshness test red until someone ran site_sources by hand.""" def _args(self, **kw): base = { @@ -5334,7 +5334,7 @@ class AWriteRefreshesTheSourcePaths(unittest.TestCase): contextlib.redirect_stderr(io.StringIO()) as err: profiling_sourcepaths.refresh_source_paths(self._args(emulators_dir=tmp), {"p"}) self.assertFalse(refreshed.called) - self.assertIn(f"sitesources.py --fetch --emulators-dir {tmp}", err.getvalue()) + self.assertIn(f"site_sources.py --fetch --emulators-dir {tmp}", err.getvalue()) def test_the_run_cache_and_the_record_path_are_passed(self): from unittest import mock @@ -5351,7 +5351,7 @@ class AWriteRefreshesTheSourcePaths(unittest.TestCase): def test_the_record_waits_for_a_run_holding_the_repository(self): """profile_sync rewrote source-paths.json without the repository - hold sitesources takes, in the middle of a pipeline run.""" + hold site_sources takes, in the middle of a pipeline run.""" from unittest import mock from core.artifacts import ArtifactLockBusy @@ -5367,7 +5367,7 @@ class AWriteRefreshesTheSourcePaths(unittest.TestCase): profiling_sourcepaths.refresh_source_paths(self._args(), {"x"}) lock.assert_called_once_with(str(sources.SOURCE_PATHS)) self.assertFalse(built.called) - self.assertIn("sitesources.py --fetch", err.getvalue()) + self.assertIn("site_sources.py --fetch", err.getvalue()) class EveryWriterIsRecorded(unittest.TestCase): @@ -5411,7 +5411,7 @@ class EveryWriterIsRecorded(unittest.TestCase): class AnUnreadTreeKeepsItsRecord(unittest.TestCase): - """sitesources --fetch, rate-limited by GitLab, dropped about twenty + """site_sources --fetch, rate-limited by GitLab, dropped about twenty trees it never read from source-paths.json.""" def test_unread_trees_carry_over(self): diff --git a/tests/test_romset_recipes.py b/tests/test_romset_recipes.py index d19bbe06b..4e62e2e42 100644 --- a/tests/test_romset_recipes.py +++ b/tests/test_romset_recipes.py @@ -912,10 +912,10 @@ class FbneoFetchReadsOneRevision(unittest.TestCase): CDN caches, and --fetch read the tip whatever was named.""" def setUp(self): - from scripts.scraper import datfetch + from scripts.scraper import dat_fetch from scripts.scraper import romset_dat_importer as importer - self.datfetch = datfetch + self.dat_fetch = dat_fetch self.importer = importer self._tmp = tempfile.TemporaryDirectory() self.dir = Path(self._tmp.name) @@ -947,46 +947,46 @@ class FbneoFetchReadsOneRevision(unittest.TestCase): from scripts.scraper import base_scraper - with mock.patch.object(self.datfetch, "api_json", self._api), \ - mock.patch.object(self.datfetch, "fetch_branch_head", self._head), \ + with mock.patch.object(self.dat_fetch, "api_json", self._api), \ + mock.patch.object(self.dat_fetch, "fetch_branch_head", self._head), \ mock.patch.object(base_scraper, "download", self._download): yield def test_bytes_that_are_not_the_listed_blob_are_refused(self): self.served = FBNEO_DAT.replace(b"1.0.0.03", b"1.0.0.02") - with self._patched(), self.assertRaises(self.datfetch.BlobMismatchError): - self.datfetch.fetch_pack("fbneo", "latest", self.dir) + with self._patched(), self.assertRaises(self.dat_fetch.BlobMismatchError): + self.dat_fetch.fetch_pack("fbneo", "latest", self.dir) self.assertFalse((self.dir / "fbneo-dats" / "c0ffee" / "Demo.dat").exists()) def test_the_named_revision_is_the_one_listed(self): with self._patched(): - target, blobs = self.datfetch.fetch_pack("fbneo", "v1.0.0.02", self.dir) + target, blobs = self.dat_fetch.fetch_pack("fbneo", "v1.0.0.02", self.dir) self.assertEqual( self.calls, ["libretro/FBNeo@v1.0.0.02", - f"{self.datfetch.FBNEO_API}/contents/dats?ref=c0ffee"], + f"{self.dat_fetch.FBNEO_API}/contents/dats?ref=c0ffee"], ) self.assertEqual(list(blobs), ["Demo.dat"]) def test_the_cache_is_keyed_by_the_commit(self): with self._patched(): - target, blobs = self.datfetch.fetch_pack("fbneo", "v1.0.0.02", self.dir) + target, blobs = self.dat_fetch.fetch_pack("fbneo", "v1.0.0.02", self.dir) self.assertEqual(target, self.dir / "fbneo-dats" / "c0ffee") - self.assertEqual(self.datfetch.cached_pack("fbneo", "c0ffee", self.dir), (target, blobs)) + self.assertEqual(self.dat_fetch.cached_pack("fbneo", "c0ffee", self.dir), (target, blobs)) def test_another_commit_is_not_cached(self): with self._patched(): - self.datfetch.fetch_pack("fbneo", "latest", self.dir) - with self.assertRaises(self.datfetch.NotCached): - self.datfetch.cached_pack("fbneo", "da14132b", self.dir) + self.dat_fetch.fetch_pack("fbneo", "latest", self.dir) + with self.assertRaises(self.dat_fetch.NotCached): + self.dat_fetch.cached_pack("fbneo", "da14132b", self.dir) def test_an_uncached_listxml_is_named(self): - with self.assertRaises(self.datfetch.NotCached): - self.datfetch.cached_pack("mame", "mame0289", self.dir) + with self.assertRaises(self.dat_fetch.NotCached): + self.dat_fetch.cached_pack("mame", "mame0289", self.dir) def test_latest_reads_the_default_branch(self): with self._patched(): - self.datfetch.fetch_pack("fbneo", "latest", self.dir) + self.dat_fetch.fetch_pack("fbneo", "latest", self.dir) self.assertEqual(self.calls[0], "libretro/FBNeo@None") def test_a_revision_import_is_labelled_and_leaves_the_tip_blobs(self): diff --git a/tests/test_scraper_contract.py b/tests/test_scraper_contract.py index 9fd2e5606..2c93bcb46 100644 --- a/tests/test_scraper_contract.py +++ b/tests/test_scraper_contract.py @@ -985,7 +985,7 @@ class EveryGitHubApiCallerSendsTheToken(unittest.TestCase): for path in [*scripts.rglob("*.py"), *scripts.rglob("*.sh")] if "api.github.com" in (source := path.read_text(encoding="utf-8")) # arcade_parent_importer names API URLs and sends them through - # datfetch.api_json, which holds the token, and the + # dat_fetch.api_json, which holds the token, and the # scrapers through base_scraper.github_json, the rest through # core.upstream.fetch_body or forge_headers. and ("Request(" in source or "urlopen(" in source or path.suffix == ".sh") diff --git a/tests/test_site_integration.py b/tests/test_site_integration.py index 73b19c474..7ed4c18cf 100644 --- a/tests/test_site_integration.py +++ b/tests/test_site_integration.py @@ -145,7 +145,7 @@ class SourcePathsFreshness(unittest.TestCase): moved = dict(profile, source_commit="f" * 40, upstream_commit="e" * 40) finding = check_source_paths({"geolith": moved}) self.assertEqual(finding.status, STALE) - self.assertIn("sitesources.py --fetch", finding.detail) + self.assertIn("site_sources.py --fetch", finding.detail) def test_a_pinned_tree_never_read_is_stale(self): """fbneo moved to two new pins while fbneo_cps12 kept the old ones: diff --git a/tests/test_system_selection.py b/tests/test_system_selection.py index 750b3c4be..7014a1428 100644 --- a/tests/test_system_selection.py +++ b/tests/test_system_selection.py @@ -294,7 +294,7 @@ def _command(path: Path) -> list[str]: class AMissingProfileDirIsRefused(unittest.TestCase): """A mistyped --emulators-dir read as "no emulator": generate_pack built a pack without its core files marked OK, verify --strict passed, and - sitesources wrote {} over source-paths.json, every one exiting 0.""" + site_sources wrote {} over source-paths.json, every one exiting 0.""" EXTRA = { "arcade_parent_importer": ["--all", "--offline"], @@ -306,7 +306,7 @@ class AMissingProfileDirIsRefused(unittest.TestCase): "mame_ref_audit": ["mame"], "profile_sync": ["--all", "--triage"], "romset_dat_importer": ["--source", "mame", "--pack", "{dat}", "--output", "{out}/r.json"], - "sitesources": ["--cache-dir", "{cache}", "--output", "{out}/source-paths.json"], + "site_sources": ["--cache-dir", "{cache}", "--output", "{out}/source-paths.json"], "validate_pr": ["bios/Sony/PlayStation/scph5501.bin"], "verify": ["--platform", "retroarch", "--strict"], } @@ -341,7 +341,7 @@ class AMissingProfileDirIsRefused(unittest.TestCase): ] self.assertEqual(written, []) # Read as empty, generate_site rewrote published-parts.json and the - # FAQ, and sitesources source-paths.json. The copy compares the + # FAQ, and site_sources source-paths.json. The copy compares the # files themselves: a name `git diff` already listed hid a rewrite. after = snapshot(checkout) self.assertEqual(sorted(k for k in before.keys() | after.keys() diff --git a/tests/test_version_basis.py b/tests/test_version_basis.py index 15ddc4d97..988897aee 100644 --- a/tests/test_version_basis.py +++ b/tests/test_version_basis.py @@ -27,7 +27,7 @@ import profile_sync from profiling import resolver from profiling import yamledit from core import upstream -from profiling import version_basis +from profiling import versionbasis from model.profilerepos import pin_field from model.profiles import load_emulator_profiles from profiling.reports import ProfileReport, SkipKind @@ -68,13 +68,13 @@ class ReadsTheRecordedSourceOffline(unittest.TestCase): def _check(self, name: str, profiles: dict | None = None) -> list: profiles = profiles or self.profiles - return version_basis.check(profiles[name], str(self.cache), True, profiles) + return versionbasis.check(profiles[name], str(self.cache), True, profiles) def test_every_kind_reads_its_version(self): for name in self.profiles: with self.subTest(profile=name): readings = self._check(name) - self.assertEqual([r.status for r in readings], [version_basis.MATCH], + self.assertEqual([r.status for r in readings], [versionbasis.MATCH], readings) def test_a_file_basis_names_the_line_it_read(self): @@ -94,26 +94,26 @@ class ReadsTheRecordedSourceOffline(unittest.TestCase): profiles = copy.deepcopy(self.profiles) profiles[name]["core_version"] = stale (reading,) = self._check(name, profiles) - self.assertEqual(reading.status, version_basis.DRIFT) + self.assertEqual(reading.status, versionbasis.DRIFT) def test_a_tag_distance_the_forge_contradicts_is_drift(self): profiles = copy.deepcopy(self.profiles) profiles["dolphin"]["version_basis"]["distance"] = 400 (reading,) = self._check("dolphin", profiles) - self.assertEqual(reading.status, version_basis.DRIFT) + self.assertEqual(reading.status, versionbasis.DRIFT) self.assertEqual(dict(reading.updates)["distance"], 437) def test_a_pattern_that_no_longer_matches_is_unreadable(self): profiles = copy.deepcopy(self.profiles) profiles["snes9x"]["version_basis"]["pattern"] = "#define\\s+NOPE\\s+(\\S+)" (reading,) = self._check("snes9x", profiles) - self.assertEqual(reading.status, version_basis.UNREADABLE) + self.assertEqual(reading.status, versionbasis.UNREADABLE) def test_a_profile_without_basis_is_reported(self): profiles = copy.deepcopy(self.profiles) del profiles["snes9x"]["version_basis"] (reading,) = self._check("snes9x", profiles) - self.assertEqual(reading.status, version_basis.NO_BASIS) + self.assertEqual(reading.status, versionbasis.NO_BASIS) def test_the_command_fails_on_drift_and_passes_clean(self): emulators = Path(self.tmp.name) / "emulators" @@ -155,20 +155,20 @@ class EveryProfileSaysWhereItsVersionIsRead(unittest.TestCase): def test_every_profile_has_a_basis(self): missing = sorted(name for name, p in self.profiles.items() - if not version_basis.bases(p)) + if not versionbasis.bases(p)) self.assertEqual(missing, [], "profiles without version_basis") def test_no_placeholder_is_a_version(self): named = sorted( name for name, p in self.profiles.items() - for mode in (version_basis.bases(p) or {"": {}}) - if version_basis.is_placeholder(version_basis.declared(p, mode)) + for mode in (versionbasis.bases(p) or {"": {}}) + if versionbasis.is_placeholder(versionbasis.declared(p, mode)) ) self.assertEqual(named, []) def test_keyed_bases_follow_the_keyed_version(self): for name, profile in self.profiles.items(): - found = version_basis.bases(profile) + found = versionbasis.bases(profile) if not found or "" in found: continue with self.subTest(profile=name): @@ -177,45 +177,45 @@ class EveryProfileSaysWhereItsVersionIsRead(unittest.TestCase): def test_none_states_no_version(self): for name, profile in self.profiles.items(): - for mode, basis in version_basis.bases(profile).items(): + for mode, basis in versionbasis.bases(profile).items(): if basis.get("kind") == "none": with self.subTest(profile=name, mode=mode): - self.assertIsNone(version_basis.declared(profile, mode)) + self.assertIsNone(versionbasis.declared(profile, mode)) def test_a_tag_version_is_the_describe_form_of_its_pin(self): for name, profile in self.profiles.items(): - for mode, basis in version_basis.bases(profile).items(): + for mode, basis in versionbasis.bases(profile).items(): if basis.get("kind") != "tag" or basis.get("url"): continue field = pin_field(str(basis.get("repo") or "source")) + "_commit" - pin = version_basis._by_mode(profile, field, mode) + pin = versionbasis._by_mode(profile, field, mode) if not pin: continue with self.subTest(profile=name, mode=mode): self.assertEqual( - version_basis.declared(profile, mode), - version_basis.describe_form(basis["tag"], basis["distance"], pin), + versionbasis.declared(profile, mode), + versionbasis.describe_form(basis["tag"], basis["distance"], pin), ) def test_an_alias_carries_the_version_of_its_profile(self): for name, profile in self.profiles.items(): - for mode, basis in version_basis.bases(profile).items(): + for mode, basis in versionbasis.bases(profile).items(): if basis.get("kind") != "alias": continue with self.subTest(profile=name): - (reading,) = [r for r in version_basis.check( + (reading,) = [r for r in versionbasis.check( profile, "", True, self.profiles) if r.mode == mode] - self.assertEqual(reading.status, version_basis.MATCH, reading) + self.assertEqual(reading.status, versionbasis.MATCH, reading) def test_a_package_named_after_its_version_states_it(self): for name, profile in self.profiles.items(): - for mode, basis in version_basis.bases(profile).items(): + for mode, basis in versionbasis.bases(profile).items(): if basis.get("kind") != "package" or not basis.get("pattern"): continue with self.subTest(profile=name): - (reading,) = [r for r in version_basis.check(profile, "", True) + (reading,) = [r for r in versionbasis.check(profile, "", True) if r.mode == mode] - self.assertEqual(reading.status, version_basis.MATCH, reading) + self.assertEqual(reading.status, versionbasis.MATCH, reading) SAMPLE = """emulator: Sample @@ -240,13 +240,13 @@ class TheBasisPinIsTheComparisonPin(unittest.TestCase): "profiled_date": "2026-01-01"} basis = {"kind": "file", "repo": "source"} with mock.patch.object(upstream, "resolve_commit_at", return_value="a" * 40) as at: - repo, pin = version_basis._repo_and_pin(profile, basis, "", "cache", True) + repo, pin = versionbasis._repo_and_pin(profile, basis, "", "cache", True) self.assertEqual((repo.slug, pin), ("o/r", "a" * 40)) self.assertEqual(at.call_args.args[1:], ("2026-01-01", "cache", True, "port")) def test_a_mirror_is_pinned_by_the_source_commit(self): profile = {"source_mirror": "https://github.com/o/m", "source_commit": "b" * 40} - repo, pin = version_basis._repo_and_pin( + repo, pin = versionbasis._repo_and_pin( profile, {"kind": "file", "repo": "source_mirror"}, "", "cache", True) self.assertEqual((repo.slug, pin), ("o/m", "b" * 40)) @@ -262,18 +262,18 @@ class TheVersionRepositoryIsTheBasisRepository(unittest.TestCase): } def test_a_basis_naming_the_upstream_is_read_there(self): - repo, field = version_basis.version_repo(self.PROFILE) + repo, field = versionbasis.version_repo(self.PROFILE) self.assertEqual((repo.slug, field), ("o/up", "upstream")) def test_a_profile_without_basis_is_read_where_it_was_profiled(self): profile = {k: v for k, v in self.PROFILE.items() if k != "version_basis"} - repo, field = version_basis.version_repo(profile) + repo, field = versionbasis.version_repo(profile) self.assertEqual((repo.slug, field), ("o/port", "source")) def test_a_basis_url_is_its_own_repository(self): profile = dict(self.PROFILE, version_basis={ "kind": "package", "url": "https://github.com/o/pkg/releases"}) - repo, field = version_basis.version_repo(profile) + repo, field = versionbasis.version_repo(profile) self.assertEqual((repo.slug, field), ("o/pkg", "url")) def test_the_check_reads_the_tags_and_the_pin_of_that_repository(self): @@ -339,17 +339,17 @@ class TheTagCoreVersionNames(unittest.TestCase): return report, asked def test_a_tag_basis_names_its_tag(self): - [named] = version_basis.version_tags(self.DESCRIBED) + [named] = versionbasis.version_tags(self.DESCRIBED) self.assertEqual((named.declared, named.tag, named.distance), ("2.9.2-77-gfc4ab0b", "2.9.2", 77)) def test_a_mode_keyed_version_names_one_tag_per_build(self): profile = {"source": "https://github.com/o/n", "core_version": {"standalone": "v1.1", "libretro": "v0.9"}} - self.assertEqual([(n.mode, n.tag) for n in version_basis.version_tags(profile)], + self.assertEqual([(n.mode, n.tag) for n in versionbasis.version_tags(profile)], [("standalone", "v1.1"), ("libretro", "v0.9")]) same = dict(profile, core_version={"standalone": "0.14.1", "libretro": "0.14.1"}) - self.assertEqual([n.tag for n in version_basis.version_tags(same)], ["0.14.1"]) + self.assertEqual([n.tag for n in versionbasis.version_tags(same)], ["0.14.1"]) def test_a_release_after_the_described_pin_is_named(self): report, asked = self._attach(self.DESCRIBED, {"2.9.2": "tag292", "2.10.0": "rel210"}) @@ -388,16 +388,16 @@ class AnAdvanceReadsTheVersionAgain(unittest.TestCase): self.tmp.cleanup() def _reading(self, status: str, value: str | None): - return version_basis.Reading("", "file", "1.0", value, "o/n@bbbbbbb:version.h:3", status) + return versionbasis.Reading("", "file", "1.0", value, "o/n@bbbbbbb:version.h:3", status) def test_the_version_moves_with_the_pin(self): seen = [] def check(profile, cache_dir, offline, profiles=None, recompute=False): seen.append((profile["source_commit"], recompute)) - return [self._reading(version_basis.DRIFT, "2.0")] + return [self._reading(versionbasis.DRIFT, "2.0")] - with mock.patch.object(version_basis, "check", check): + with mock.patch.object(versionbasis, "check", check): self.assertTrue(bump_commit(self.path, self.report).moved) written = yaml.safe_load(self.path.read_text(encoding="utf-8")) self.assertEqual(written["source_commit"], "bbbbbbb") @@ -406,8 +406,8 @@ class AnAdvanceReadsTheVersionAgain(unittest.TestCase): self.assertEqual(seen, [("bbbbbbb", True)]) def test_an_unreadable_version_holds_the_pin(self): - with mock.patch.object(version_basis, "check", - return_value=[self._reading(version_basis.UNREADABLE, None)]): + with mock.patch.object(versionbasis, "check", + return_value=[self._reading(versionbasis.UNREADABLE, None)]): self.assertFalse(bump_commit(self.path, self.report).moved) self.assertEqual(self.path.read_text(encoding="utf-8"), SAMPLE) @@ -418,9 +418,9 @@ class AnAdvanceReadsTheVersionAgain(unittest.TestCase): self.assertEqual(self.path.read_text(encoding="utf-8"), before) def test_a_package_version_is_advanced_by_hand(self): - reading = version_basis.Reading("", "package", "1.0", None, "read from x.apk", - version_basis.UNCHECKED) - with mock.patch.object(version_basis, "check", return_value=[reading]): + reading = versionbasis.Reading("", "package", "1.0", None, "read from x.apk", + versionbasis.UNCHECKED) + with mock.patch.object(versionbasis, "check", return_value=[reading]): self.assertFalse(bump_commit(self.path, self.report).moved) diff --git a/tests/test_workflow_paths.py b/tests/test_workflow_paths.py index 2d9139797..917f8020a 100644 --- a/tests/test_workflow_paths.py +++ b/tests/test_workflow_paths.py @@ -123,7 +123,7 @@ class DeploySiteTriggers(unittest.TestCase): self.assertNotIn("tests/**", patterns) def test_the_site_reads_the_ref_grammar_not_the_checker(self): - """sitesources imported two parsing functions from profile_sync, so + """site_sources imported two parsing functions from profile_sync, so every change to the comparison tool rebuilt an unchanged site.""" read = closure(["generate_site.py"]) self.assertNotIn("scripts/profile_sync.py", read) diff --git a/website/src/styles/retrobios.css b/website/src/styles/retrobios.css index 8a7608de2..9bc4c342e 100644 --- a/website/src/styles/retrobios.css +++ b/website/src/styles/retrobios.css @@ -13,7 +13,7 @@ .rb-terminal wraps a code block that shows terminal output .rb-cmd wraps a command that must wrap instead of scrolling code.rb-path a folder path shown as a chip - .rb-figure a generated diagram (scripts/sitediagrams.py) + .rb-figure a generated diagram (scripts/site_diagrams.py) .rb-bar inline coverage bar, width from --v .rb-details-* collapsible block, neutral unless caution or danger dl.rb-facts the facts of a file card, label and value side by side @@ -772,8 +772,8 @@ body:has(table.rb-entries) { --sl-content-width: var(--rb-grid-width); } /* Terminal output: what the screen shows, not something to type */ .sl-markdown-content .rb-terminal .expressive-code pre { background: var(--rb-terminal-bg); color: var(--rb-terminal-fg); } -/* Diagrams written by scripts/sitediagrams.py follow the theme: each is an - image per theme (its colours written in the file, sitediagrams.THEMES), +/* Diagrams written by scripts/site_diagrams.py follow the theme: each is an + image per theme (its colours written in the file, sitegen.diagrams.THEMES), and the one of the other theme is not shown, so not fetched either. Starlight's dark theme is the one without data-theme='light'. */ .sl-markdown-content .rb-figure { margin: 1.2rem 0 1.6rem; } diff --git a/wiki/architecture.md b/wiki/architecture.md index a0dda0dce..801445fb8 100644 --- a/wiki/architecture.md +++ b/wiki/architecture.md @@ -423,7 +423,7 @@ resolution. - `safe_extract_zip()` prevents zip-slip path traversal attacks - a pack copies each ZIP of the collection byte for byte, so every member hashes to the SHA1 the install list publishes -- `core/crypto_verify.py` and `core/sect233r1.py` verify 3DS RSA-2048 signatures and AES-128-CBC integrity +- `core/cryptoverify.py` and `core/sect233r1.py` verify 3DS RSA-2048 signatures and AES-128-CBC integrity - ZIP inner ROM verification via `checkInsideZip()` replicates Batocera's behavior - `md5_composite()` replicates Recalbox's composite ZIP hash diff --git a/wiki/tools.md b/wiki/tools.md index 867949bc2..abeac7712 100644 --- a/wiki/tools.md +++ b/wiki/tools.md @@ -585,7 +585,7 @@ is added, and commit it with the profiles. Every tree a run tries is recorded, read or not, so `check_freshness.py` reports a pinned tree the record lacks: ```bash -python scripts/sitesources.py --fetch +python scripts/site_sources.py --fetch ``` A forge can also go for good. A 451, a 410 or a host that stops resolving @@ -752,7 +752,7 @@ its core lists at that release and never moves it, so a newer release is The `profiles` area always checks `website/src/data/source-paths.json` against the profiles, offline: a recorded tree that no profile pins any more -is `STALE` until `sitesources.py --fetch` runs again. It also reads each +is `STALE` until `site_sources.py --fetch` runs again. It also reads each `pin_build` reference of a held pin: where the platform YAML was scraped at the reference's own revision the row is `OK` without network, otherwise the build file is fetched at the platform's new revision (or at the branch head @@ -1406,7 +1406,7 @@ before a release (wiki/release-process.md). Its lines stay in | `find_pinned_revision.py` | Walk the upstream commits that touched a file and return the revision whose bytes match a platform's pinned md5 (`--write` saves them) | | `generate_readme.py` | Generate README.md and CONTRIBUTING.md from database | | `generate_site.py` | Generate the site (this documentation) into the Starlight project in `website/` | -| `sitesources.py` | Record which cited source paths each pinned upstream tree holds, for the site's source links (`--fetch` reads a tree no cache holds) | +| `site_sources.py` | Record which cited source paths each pinned upstream tree holds, for the site's source links (`--fetch` reads a tree no cache holds) | | `site_markdown.py` | Write each built page as Markdown beside its HTML (`/index.md`, named in every page's head) and `llms-full.txt`, the guides and every setup's page in one file, for the assistants that read the site. The Astro build runs it once the pages are written | | `site_insights.py` | What readers look for and do not find, from totals only, each section with its period: Google searches by page against the period of the same length before (anchors merged into their page), ranked by the clicks lost against the site's own click rate at each position, searches clicked less than half that rate, searched file names the collection does not hold, site searches that found nothing, broken addresses, "Did this page help?" answers, GitHub traffic (14 days) and release downloads since the previous run (`--days`, `--skip gsc,goatcounter,github`, `--output`, `--downloads-snapshot`, default `.cache/insights/downloads.json`). Reads Search Console, GoatCounter and GitHub with credentials kept outside the repository. A source it cannot read (rate limit, missing credential) is named at the top of the report instead of ending the run, which then exits 1. [What the site counts](privacy.md) | | `make_demo.py` | Record the installer demos of the README and the site into `docs_assets/demo/`. An ArkOS card with six games is built under `tmp/demo/` in a mount namespace of the user, this checkout is served on loopback, and VHS runs one tape per variant: `default` (`install.tape`, the one-line command in a terminal, the card at `/media/EASYROMS`, needs `unshare`) and `handheld` (`install-handheld.tape`, the full-screen interface at 640x480 on an ArkOS root made with `bwrap`, as its Tools menu starts it, driven by the keys gptokeyb sends for the buttons). `--variant NAME` records one (repeatable), every variant by default, the others kept. Each needs `vhs`, `ttyd` and `ffmpeg`. The default gets the README's GIF, each gets a WebM, an MP4 and a poster, held to their size targets, and an entry in `demo.json` with what it shows and its alt text. No Windows variant: under pwsh on Linux the installer's summary gives `--dest /mnt/e/bios` back. Never run by the build | @@ -1415,7 +1415,7 @@ before a release (wiki/release-process.md). Its lines stay in | `romset_recipes.py` | Identify which emulator version an arcade archive matches, rebuild a pinned archive from ROMs already held, record a recipe for every archive the collection holds and build any of them from the members it holds (see [Archive recipes](#archive-recipes)) | | `scraper/romset_dat_importer.py` | Fetch and import per-set recipes from MAME `-listxml` or FBNeo DATs into `recipes/`. `--fetch` alone takes the newest MAME release, and FBNeo DATs are refreshed by git blob sha. `--fetch ` reads FBNeo at that tag, branch or commit | | `core/torrentzip.py` | Build TorrentZip archives for MAME/FBNeo ROM sets (archive bytes depend only on contents, with stock zlib), streaming one member at a time | -| `core/crypto_verify.py` | 3DS RSA signature and AES crypto verification | +| `core/cryptoverify.py` | 3DS RSA signature and AES crypto verification | | `core/sect233r1.py` | Pure Python ECDSA verification on sect233r1 curve (3DS OTP cert) | | `check_buildbot_system.py` | Detect stale data directories by comparing with buildbot | | `check_freshness.py` | One report on every upstream the repository transcribes (see above) | @@ -1728,7 +1728,7 @@ the GitHub and text fetches, and the shared CLI), `dat_parser.py` (clrmamepro DA `logiqx_parser.py` (Logiqx XML DAT parser, used by the dump catalogs), `mame_parser.py` (MAME C source BIOS root set parser), `fbneo_parser.py` (FBNeo C source BIOS set parser), -`datfetch.py` (upstream MAME `-listxml` and FBNeo DATs, cached under `.cache/dats/`), +`dat_fetch.py` (upstream MAME `-listxml` and FBNeo DATs, cached under `.cache/dats/`), `_hash_merge.py` (text-based YAML patching that preserves formatting). Adding a scraper: inherit `BaseScraper`, implement `fetch_requirements()` and