mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
core: cli (run_cli, input errors, name hints), github (token), paths. model: sources, database, composition, registry, platforms, declarations, targets, systems, profiles, cliargs. resolve: content, ownership, datadirs, archives, localfile, directories, layout, contentlayout, standalone, grouping, cores. Definitions move verbatim; common.py and its re-exports are gone and every importer, patch target and code-in-string names the new home. A test that stubbed common.load_platform_config stubs each module that reads the loader by its own name.
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""Code reads platform entries by the keys the platform YAMLs write.
|
|
|
|
expand_platform_declared_names skipped archive members through
|
|
`fe.get("zippedFile")`, the upstream Batocera spelling. The YAMLs write
|
|
`zipped_file`, so a member's md5 was taken for a loose file and its name
|
|
counted as declared: 76 Batocera entries added names such as boot0.rom.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tests
|
|
|
|
import re
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
# Where the camelCase key is the upstream format itself: scrapers read it,
|
|
# the Batocera exporter writes it back.
|
|
UPSTREAM_FORMAT = {"scraper", "exporter"}
|
|
|
|
|
|
class ZippedFileKey(unittest.TestCase):
|
|
def test_no_entry_is_read_by_the_upstream_spelling(self):
|
|
pattern = re.compile(r"""\.get\(\s*["']zippedFile["']|\[\s*["']zippedFile["']\s*\]""")
|
|
for path in sorted((REPO_ROOT / "scripts").rglob("*.py")):
|
|
if UPSTREAM_FORMAT & set(path.relative_to(REPO_ROOT / "scripts").parts[:-1]):
|
|
continue
|
|
with self.subTest(module=str(path.relative_to(REPO_ROOT))):
|
|
self.assertIsNone(pattern.search(path.read_text(encoding="utf-8")))
|
|
|
|
def test_member_md5_declares_no_loose_name(self):
|
|
from model.declarations import expand_platform_declared_names
|
|
|
|
config = {"systems": {"s": {"files": [
|
|
{"name": "casloopy.zip", "md5": "m1", "zipped_file": "hd6437021.lsi302"},
|
|
]}}}
|
|
db = {"files": {"x": {"name": "boot0.rom"}}, "indexes": {"by_md5": {"m1": "x"}}}
|
|
self.assertEqual(expand_platform_declared_names(config, db), {"casloopy.zip"})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|