mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 21:38:55 -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
+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")
|
||||
|
||||
Reference in new issue
Block a user