mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: name the recipe package romrecipes
This commit is contained in:
1 parent
05a6af5e97
commit
3bfd72ba7f
22 files changed
+53
-53
No files matched your search
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
File renamed without changes.
@@ -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 ------------------------------------------------------------------
|
||||
@@ -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-"
|
||||
|
||||
@@ -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(
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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:
|
||||
File renamed without changes.
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
+2
-2
@@ -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",),
|
||||
|
||||
+17
-17
@@ -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), [])
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
+1
-1
@@ -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 |
|
||||
|
||||
Reference in new issue
Block a user