From 3bfd72ba7fbd029784e0eb047b6313d8b9e33be4 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:20:46 +0100 Subject: [PATCH] refactor: name the recipe package romrecipes --- .github/workflows/deploy-site.yml | 4 +-- scripts/core/torrentzip.py | 2 +- scripts/{recipes => romrecipes}/__init__.py | 0 scripts/{recipes => romrecipes}/build.py | 4 +-- scripts/{recipes => romrecipes}/capture.py | 8 ++--- scripts/{recipes => romrecipes}/identify.py | 6 ++-- scripts/{recipes => romrecipes}/ledger.py | 0 scripts/{recipes => romrecipes}/members.py | 0 scripts/{recipes => romrecipes}/pins.py | 0 scripts/{recipes => romrecipes}/pool.py | 2 +- scripts/{recipes => romrecipes}/romsets.py | 0 scripts/romset_recipes.py | 14 ++++----- scripts/sitegen/build.py | 2 +- scripts/sitegen/readme.py | 2 +- scripts/sitegen/wanted.py | 4 +-- tests/sources.py | 4 +-- tests/test_archive_build.py | 34 ++++++++++----------- tests/test_archive_recipes.py | 2 +- tests/test_doc_surfaces.py | 2 +- tests/test_layers.py | 6 ++-- tests/test_romset_recipes.py | 8 ++--- wiki/tools.md | 2 +- 22 files changed, 53 insertions(+), 53 deletions(-) rename scripts/{recipes => romrecipes}/__init__.py (100%) rename scripts/{recipes => romrecipes}/build.py (98%) rename scripts/{recipes => romrecipes}/capture.py (97%) rename scripts/{recipes => romrecipes}/identify.py (98%) rename scripts/{recipes => romrecipes}/ledger.py (100%) rename scripts/{recipes => romrecipes}/members.py (100%) rename scripts/{recipes => romrecipes}/pins.py (100%) rename scripts/{recipes => romrecipes}/pool.py (99%) rename scripts/{recipes => romrecipes}/romsets.py (100%) diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index 538ffb7dd..318595fc9 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -68,8 +68,6 @@ on: - "scripts/packs/slots.py" - "scripts/packs/verdicts.py" - "scripts/pr_checks.py" - - "scripts/recipes/__init__.py" - - "scripts/recipes/ledger.py" - "scripts/refresh_data_dirs.py" - "scripts/release_record.py" - "scripts/resolve/__init__.py" @@ -97,6 +95,8 @@ on: - "scripts/resolve/truth.py" - "scripts/resolve/validation.py" - "scripts/restore_large_files.py" + - "scripts/romrecipes/__init__.py" + - "scripts/romrecipes/ledger.py" - "scripts/site_markdown.py" - "scripts/sitegen/__init__.py" - "scripts/sitegen/agents.py" diff --git a/scripts/core/torrentzip.py b/scripts/core/torrentzip.py index c92007318..949468f40 100644 --- a/scripts/core/torrentzip.py +++ b/scripts/core/torrentzip.py @@ -7,7 +7,7 @@ member names and their contents. That property makes it possible to rebuild a romset ZIP that matches an upstream-published hash exactly, and to identify which romset revision a -published hash refers to (scripts/recipes/). +published hash refers to (scripts/romrecipes/). Usage: from core.torrentzip import build_torrentzip diff --git a/scripts/recipes/__init__.py b/scripts/romrecipes/__init__.py similarity index 100% rename from scripts/recipes/__init__.py rename to scripts/romrecipes/__init__.py diff --git a/scripts/recipes/build.py b/scripts/romrecipes/build.py similarity index 98% rename from scripts/recipes/build.py rename to scripts/romrecipes/build.py index e2b864736..751e38257 100644 --- a/scripts/recipes/build.py +++ b/scripts/romrecipes/build.py @@ -10,8 +10,8 @@ from pathlib import Path from core.hashing import compute_hashes from core.paths import REPO_ROOT from core.torrentzip import write_torrentzip, zlib_ng_version -from recipes.ledger import is_archive_path -from recipes.members import _member_sha1, _opener +from romrecipes.ledger import is_archive_path +from romrecipes.members import _member_sha1, _opener # --- build ------------------------------------------------------------------ diff --git a/scripts/recipes/capture.py b/scripts/romrecipes/capture.py similarity index 97% rename from scripts/recipes/capture.py rename to scripts/romrecipes/capture.py index abb636782..0c0884444 100644 --- a/scripts/recipes/capture.py +++ b/scripts/romrecipes/capture.py @@ -12,10 +12,10 @@ from typing import BinaryIO from core.hashing import parse_hash_list from core.torrentzip import write_torrentzip, zlib_ng_version -from recipes.ledger import database_archives -from recipes.members import _member_sha1, _opener -from recipes.pins import container_entries -from recipes.romsets import collect_recipes, load_dat_recipes +from romrecipes.ledger import database_archives +from romrecipes.members import _member_sha1, _opener +from romrecipes.pins import container_entries +from romrecipes.romsets import collect_recipes, load_dat_recipes _TORRENTZIP_COMMENT = b"TORRENTZIPPED-" diff --git a/scripts/recipes/identify.py b/scripts/romrecipes/identify.py similarity index 98% rename from scripts/recipes/identify.py rename to scripts/romrecipes/identify.py index f24134495..055556b0d 100644 --- a/scripts/recipes/identify.py +++ b/scripts/romrecipes/identify.py @@ -9,9 +9,9 @@ from collections import defaultdict from pathlib import Path from core.torrentzip import is_torrentzip -from recipes.pins import container_entries -from recipes.pool import AtomPool -from recipes.romsets import Recipe +from romrecipes.pins import container_entries +from romrecipes.pool import AtomPool +from romrecipes.romsets import Recipe def identify_archive( diff --git a/scripts/recipes/ledger.py b/scripts/romrecipes/ledger.py similarity index 100% rename from scripts/recipes/ledger.py rename to scripts/romrecipes/ledger.py diff --git a/scripts/recipes/members.py b/scripts/romrecipes/members.py similarity index 100% rename from scripts/recipes/members.py rename to scripts/romrecipes/members.py diff --git a/scripts/recipes/pins.py b/scripts/romrecipes/pins.py similarity index 100% rename from scripts/recipes/pins.py rename to scripts/romrecipes/pins.py diff --git a/scripts/recipes/pool.py b/scripts/romrecipes/pool.py similarity index 99% rename from scripts/recipes/pool.py rename to scripts/romrecipes/pool.py index 8c68a76e7..e226cdd55 100644 --- a/scripts/recipes/pool.py +++ b/scripts/romrecipes/pool.py @@ -10,7 +10,7 @@ from pathlib import Path from core.paths import REPO_ROOT from core.torrentzip import build_torrentzip -from recipes.romsets import Recipe +from romrecipes.romsets import Recipe class AtomPool: diff --git a/scripts/recipes/romsets.py b/scripts/romrecipes/romsets.py similarity index 100% rename from scripts/recipes/romsets.py rename to scripts/romrecipes/romsets.py diff --git a/scripts/romset_recipes.py b/scripts/romset_recipes.py index 15e7c1c6d..3b59f703e 100644 --- a/scripts/romset_recipes.py +++ b/scripts/romset_recipes.py @@ -22,7 +22,7 @@ An archive whose bytes carry metadata unrelated to its contents cannot be derived from ROMs by anyone, and is reported as such rather than guessed at. Every archive the collection holds also has a recipe of its own in -``recipes/archives.json`` (scripts/recipes/): +``recipes/archives.json`` (scripts/romrecipes/): ``--capture`` Write a record for every archive in database.json: members in order with @@ -54,12 +54,12 @@ from core.cli import require_directory from core.torrentzip import zlib_ng_version from model.database import load_database from model.profiles import load_emulator_profiles -from recipes.build import AtomIndex, build_archive, select -from recipes.capture import ZlibNgError, capture, container_pins, recipe_index -from recipes.identify import identify_report, missing_report, write_reconstructions -from recipes.ledger import ARCHIVES_FILE, load_ledger, write_ledger -from recipes.pool import AtomPool, DIGEST_CACHE -from recipes.romsets import collect_recipes, load_dat_recipes, merge_recipes +from romrecipes.build import AtomIndex, build_archive, select +from romrecipes.capture import ZlibNgError, capture, container_pins, recipe_index +from romrecipes.identify import identify_report, missing_report, write_reconstructions +from romrecipes.ledger import ARCHIVES_FILE, load_ledger, write_ledger +from romrecipes.pool import AtomPool, DIGEST_CACHE +from romrecipes.romsets import collect_recipes, load_dat_recipes, merge_recipes def print_missing(gap: dict) -> None: diff --git a/scripts/sitegen/build.py b/scripts/sitegen/build.py index 1fe6195c1..04a06572d 100644 --- a/scripts/sitegen/build.py +++ b/scripts/sitegen/build.py @@ -11,7 +11,7 @@ from collections.abc import Callable from dataclasses import dataclass from pathlib import Path -from recipes import ledger +from romrecipes import ledger import release_record from model import siteinputs from model.collection import _group_by_manufacturer, _slug diff --git a/scripts/sitegen/readme.py b/scripts/sitegen/readme.py index 59ba623ba..d6bcf4e20 100644 --- a/scripts/sitegen/readme.py +++ b/scripts/sitegen/readme.py @@ -11,7 +11,7 @@ from datetime import datetime, timezone from pathlib import Path from types import ModuleType -from recipes import ledger +from romrecipes import ledger import pr_checks import release_record from core.artifacts import write_if_changed diff --git a/scripts/sitegen/wanted.py b/scripts/sitegen/wanted.py index 66435d7ff..b12a6188f 100644 --- a/scripts/sitegen/wanted.py +++ b/scripts/sitegen/wanted.py @@ -21,7 +21,7 @@ import urllib.parse from collections.abc import Callable, Iterable from pathlib import Path -from recipes import ledger as recipes_ledger +from romrecipes import ledger as romrecipes_ledger from resolve.layout import runs_standalone from model.profiles import unique_emulator_profiles from packs.crossref import _first_hash @@ -523,7 +523,7 @@ def _merge_named(records: dict[tuple, dict]) -> None: def load_ledger(path: Path) -> list[dict]: """The archive records of recipes/archives.json, empty when absent.""" - return list(recipes_ledger.load_ledger(path).values()) + return list(romrecipes_ledger.load_ledger(path).values()) def page(total: int, known: int) -> str: diff --git a/tests/sources.py b/tests/sources.py index cd4e1a99b..729d67de9 100644 --- a/tests/sources.py +++ b/tests/sources.py @@ -73,8 +73,8 @@ COMMANDS = { "site_insights.py": ("sitegen/insights.py",), "generate_readme.py": ("sitegen/readme.py",), "romset_recipes.py": ( - "recipes/romsets.py", "recipes/pool.py", "recipes/pins.py", "recipes/identify.py", - "recipes/ledger.py", "recipes/members.py", "recipes/capture.py", "recipes/build.py", + "romrecipes/romsets.py", "romrecipes/pool.py", "romrecipes/pins.py", "romrecipes/identify.py", + "romrecipes/ledger.py", "romrecipes/members.py", "romrecipes/capture.py", "romrecipes/build.py", ), "provenance_report.py": ("acquire/provenance.py",), "auto_fetch.py": ("acquire/fetch.py",), diff --git a/tests/test_archive_build.py b/tests/test_archive_build.py index 8e9e20abf..b5f789a96 100644 --- a/tests/test_archive_build.py +++ b/tests/test_archive_build.py @@ -18,9 +18,9 @@ import zipfile from pathlib import Path from unittest import mock -from recipes import build as recipes_build -from recipes import capture as recipes_capture -from recipes import ledger +from romrecipes import build as romrecipes_build +from romrecipes import capture as romrecipes_capture +from romrecipes import ledger from core.torrentzip import build_torrentzip ROOT = Path(__file__).resolve().parent.parent @@ -141,7 +141,7 @@ class Fixture(unittest.TestCase): self.temp.cleanup() def capture(self, **kwargs) -> dict[str, dict]: - records, failed = recipes_capture.capture( + records, failed = romrecipes_capture.capture( self.db, kwargs.get("previous", {}), kwargs.get("index", {}), kwargs.get("pins", {}), workers=1, log=lambda _line: None, ) @@ -177,7 +177,7 @@ class Capture(Fixture): self.assertEqual(exact["sources"], ["collection"]) def test_dat_agreement_and_pins_are_recorded(self): - key = recipes_capture.member_key( + key = romrecipes_capture.member_key( [{"name": n, "crc32": c} for n, c in ( ("a.rom", self._crc(ROM_A)), ("b.rom", self._crc(ROM_B)), ("c.rom", self._crc(ROM_C)), @@ -199,8 +199,8 @@ class Capture(Fixture): self.assertEqual(records["bios/set.zip"]["members"][0]["sha1"], "kept") def test_zlib_ng_refuses_to_capture(self): - with mock.patch.object(recipes_capture, "zlib_ng_version", lambda: "2.2.4"), \ - self.assertRaises(recipes_capture.ZlibNgError): + with mock.patch.object(romrecipes_capture, "zlib_ng_version", lambda: "2.2.4"), \ + self.assertRaises(romrecipes_capture.ZlibNgError): self.capture() def test_composite_and_zipped_pins_name_no_container(self): @@ -231,7 +231,7 @@ class Capture(Fixture): f" - name: set.zip\n sha1: {'d' * 40}\n", encoding="utf-8", ) - pins = recipes_capture.container_pins(str(platforms), str(emulators)) + pins = romrecipes_capture.container_pins(str(platforms), str(emulators)) self.assertEqual(pins, {"a" * 32: {"platform:plain"}, "d" * 40: {"profile:core"}}) @staticmethod @@ -250,11 +250,11 @@ class Build(Fixture): os.chdir(self.root) self.ledger = self.capture() os.chdir(self._cwd) - self.atoms = recipes_build.AtomIndex.from_collection(self.ledger, self.db, self.root) + self.atoms = romrecipes_build.AtomIndex.from_collection(self.ledger, self.db, self.root) self.out = self.root / "out" def build(self, path: str): - return recipes_build.build_archive(self.ledger[path], self.atoms, self.out, self.root) + return romrecipes_build.build_archive(self.ledger[path], self.atoms, self.out, self.root) def test_an_exact_recipe_rebuilds_the_bytes(self): result = self.build("bios/set.zip") @@ -281,14 +281,14 @@ class Build(Fixture): record["members"] = record["members"] + [ {"name": "gone.rom", "size": 1, "crc32": "00000000", "sha1": "f" * 40} ] - result = recipes_build.build_archive(record, self.atoms, self.out, self.root) + result = romrecipes_build.build_archive(record, self.atoms, self.out, self.root) self.assertEqual(result.status, "impossible") self.assertEqual([m["name"] for m in result.missing], ["gone.rom"]) self.assertFalse(self.out.exists()) def test_a_mismatch_is_never_promoted(self): record = dict(self.ledger["bios/set.zip"], sha1="0" * 40) - result = recipes_build.build_archive(record, self.atoms, self.out, self.root) + result = romrecipes_build.build_archive(record, self.atoms, self.out, self.root) self.assertEqual(result.status, "failed") self.assertIn("is not the recorded", result.detail) self.assertEqual(list(self.out.rglob("*")), [], "no file, no scratch left") @@ -297,25 +297,25 @@ class Build(Fixture): record = dict(self.ledger["bios/other.zip"]) record["members"] = [dict(m) for m in record["members"]] record["members"][0]["crc32"] = "00000000" - result = recipes_build.build_archive(record, self.atoms, self.out, self.root) + result = romrecipes_build.build_archive(record, self.atoms, self.out, self.root) self.assertEqual(result.status, "failed") self.assertEqual(list(self.out.rglob("*")), []) def test_zlib_ng_never_claims_exact(self): - with mock.patch.object(recipes_build, "zlib_ng_version", lambda: "2.2.4"): + with mock.patch.object(romrecipes_build, "zlib_ng_version", lambda: "2.2.4"): result = self.build("bios/set.zip") self.assertEqual(result.status, "canonical") self.assertIn("zlib-ng 2.2.4", result.detail) def test_an_archive_is_named_by_path_or_by_name(self): self.assertEqual( - [r["path"] for r in recipes_build.select(self.ledger, "set.zip", self.root)], + [r["path"] for r in romrecipes_build.select(self.ledger, "set.zip", self.root)], ["bios/set.zip"], ) self.assertEqual( - len(recipes_build.select(self.ledger, str(self.exact_path), self.root)), 1 + len(romrecipes_build.select(self.ledger, str(self.exact_path), self.root)), 1 ) - self.assertEqual(recipes_build.select(self.ledger, "none.zip", self.root), []) + self.assertEqual(romrecipes_build.select(self.ledger, "none.zip", self.root), []) def test_missing_members_reads_the_committed_data(self): self.assertEqual(ledger.missing_members(self.ledger, self.db), []) diff --git a/tests/test_archive_recipes.py b/tests/test_archive_recipes.py index 0bbe0a1e9..b93f17657 100644 --- a/tests/test_archive_recipes.py +++ b/tests/test_archive_recipes.py @@ -85,7 +85,7 @@ def _hashes(values: object) -> set[str]: def _allowed_members() -> dict[str, set[str]]: from model.profiles import load_emulator_profiles - from recipes.romsets import load_dat_recipes + from romrecipes.romsets import load_dat_recipes allowed: dict[str, set[str]] = defaultdict(set) for archive, per_label in load_dat_recipes(REPO_ROOT / "recipes").items(): diff --git a/tests/test_doc_surfaces.py b/tests/test_doc_surfaces.py index 1a4f562c7..65fcfb56c 100644 --- a/tests/test_doc_surfaces.py +++ b/tests/test_doc_surfaces.py @@ -650,7 +650,7 @@ class ArchiveRecipesAreCountedFromTheRecipes(unittest.TestCase): that file, never typed.""" def setUp(self) -> None: - from recipes import ledger + from romrecipes import ledger records = ledger.load_ledger().values() self.counts = { diff --git a/tests/test_layers.py b/tests/test_layers.py index d2c5855df..52294577e 100644 --- a/tests/test_layers.py +++ b/tests/test_layers.py @@ -20,7 +20,7 @@ from pathlib import Path SCRIPTS = Path(__file__).resolve().parent.parent / "scripts" PACKAGE_LAYERS = {"core": 0, "model": 1, "resolve": 2, "packs": 3, "scraper": 3, "exporter": 3, - "profiling": 3, "sitegen": 3, "recipes": 3, "acquire": 3} + "profiling": 3, "sitegen": 3, "romrecipes": 3, "acquire": 3} LIBRARY_LAYER = 3 COMMAND_LAYER = 4 @@ -31,10 +31,10 @@ SIBLING_IMPORTS: dict[str, frozenset[str]] = { "acquire": frozenset({"packs"}), "packs": frozenset(), "profiling": frozenset(), - "recipes": frozenset(), + "romrecipes": frozenset(), # The site prints the recipe counts and the dump-catalog coverage report # those two packages compute. - "sitegen": frozenset({"acquire", "packs", "recipes"}), + "sitegen": frozenset({"acquire", "packs", "romrecipes"}), } # Top-level modules other modules of scripts/ import: library code that a diff --git a/tests/test_romset_recipes.py b/tests/test_romset_recipes.py index e9790b182..47485161c 100644 --- a/tests/test_romset_recipes.py +++ b/tests/test_romset_recipes.py @@ -13,9 +13,9 @@ import zipfile import zlib from pathlib import Path -from recipes.pool import AtomPool -from recipes.romsets import collect_recipes, load_dat_recipes, merge_recipes -from recipes.identify import ( +from romrecipes.pool import AtomPool +from romrecipes.romsets import collect_recipes, load_dat_recipes, merge_recipes +from romrecipes.identify import ( identify_archive, identify_report, missing_report, @@ -727,7 +727,7 @@ class IdentificationReadsTheDirectoryFirst(unittest.TestCase): def test_a_recipe_with_other_members_is_never_built(self): from core.torrentzip import build_torrentzip - from recipes import identify + from romrecipes import identify rom = b"rom bytes" crc = format(zlib.crc32(rom), "08x") diff --git a/wiki/tools.md b/wiki/tools.md index c2a39c9fd..975c0d1e4 100644 --- a/wiki/tools.md +++ b/wiki/tools.md @@ -1360,7 +1360,7 @@ before a release (wiki/release-process.md). Its lines stay in | `resolve/` | From a declaration to a file: content checks, `resolve_local_file` and its stages, archive members, launcher layouts, the cores a platform runs, validation, slots, truth | | `packs/` | The library behind `verify.py`, `generate_pack.py`, `cross_reference.py`, `slots.py` and `refresh_data_dirs.py`: per-file verdicts, coverage and gaps, core extras, slot arbitration, pack naming and archives, manifests, the pack check, the data directory cache | | `profiling/` | What `profile_sync.py` runs: citations, anchoring, the report and its forms, version checks, detection, triage, and the guarded writes (recale, bump, prose realignment, `version_basis`) | -| `recipes/` | What `romset_recipes.py` runs: romset recipes from profiles and DATs, the ROM pool addressed by crc32, identification and rebuilt pins, and the recipe of every archive held (`recipes/archives.json`: capture, member lookup by sha1, verified build) | +| `romrecipes/` | What `romset_recipes.py` runs: romset recipes from profiles and DATs, the ROM pool addressed by crc32, identification and rebuilt pins, and the recipe of every archive held (`recipes/archives.json`: capture, member lookup by sha1, verified build) | | `acquire/` | What `provenance_report.py`, `auto_fetch.py`, `find_embedded.py` and `find_pinned_revision.py` run: dump-catalog coverage, dumps a held file already contains, the searches by hash, the rolling crc32 window, the walk of a file's upstream history | | `retired_files.py` | The record of files that left the collection, `retired.json`, which `generate_db.py` appends to and the site's lookup reads. `--backfill` rebuilds it from the history of `database.json` since content addresses were published (`--output` names another file) | | `dedup.py` | Deduplicate `bios/` (`--dry-run`, `--bios-dir`): byte-identical copies are deleted and one kept. Identical MAME sets under other names stay one file, named in `_mame_clones.json`. Trees addressed by path are left alone (`NODEDUP_DIRS`), under a folder of that name at any depth: BBK, Bungie, C-Dogs SDL, Ikemen GO, mame, PinMAME, RPG Maker, ScummVM, Softdisk, TheXTech, splitwolf, Theme Hospital, c64-emu, opentyrian, tzdata |