refactor: split the leaf modules libraries use

model.region holds the region vocabulary, resolve.regions the selection
that needs the cores a platform runs. The libraries behind identity.py,
retired_files.py and torrentzip.py move to resolve.identity,
model.retired and core.torrentzip, with their long docstrings; the
commands stay where they are run from. The source_ref parts that cite a
config or feature file move from scraper.shell_launchers to
resolve.launcherrefs, so resolve no longer imports the scraper package.
This commit is contained in:
Abdessamad Derraz committed 2026-11-18 11:39:47 +01:00
1 parent 83cfa6fd0f
commit c764d9abf1
56 files changed
+839 -804

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ from collections.abc import Callable
from typing import Any
from .configgen_launchers import Launcher, Source
from .shell_launchers import (
from scraper.shell_launchers import (
LauncherPatternMissing,
Script,
config_placement,
+1 -1
View File
@@ -15,7 +15,7 @@ import re
from collections.abc import Callable
from .configgen_launchers import Launcher
from .shell_launchers import (
from scraper.shell_launchers import (
LauncherPatternMissing,
RepoTree,
Script,
+1 -1
View File
@@ -26,7 +26,7 @@ from .base_scraper import (
requirement_entry,
)
from .emudeck_launchers import emulator_of_script, extract_launchers
from .shell_launchers import RepoTree
from scraper.shell_launchers import RepoTree
PLATFORM_NAME = "emudeck"
+1 -1
View File
@@ -19,7 +19,7 @@ from dataclasses import dataclass, field
from .configgen_launchers import Launcher
from .rocknix_launchers import fixed_paths
from .shell_launchers import (
from scraper.shell_launchers import (
LauncherPatternMissing,
Link,
config_placement,
+1 -1
View File
@@ -51,7 +51,7 @@ from .es_emulators import (
json_systems,
system_cores,
)
from .shell_launchers import RepoTree
from scraper.shell_launchers import RepoTree
PLATFORM_NAME = "emuelec"
+1 -1
View File
@@ -41,7 +41,7 @@ if (_SCRIPTS_DIR := str(Path(__file__).resolve().parents[1])) not in sys.path:
from core.artifacts import copy_stream_atomic, write_if_changed, write_text_atomic
from model.safeparse import parse_untrusted_xml
from region import REGIONS, WORLD
from model.region import REGIONS, WORLD
from region_audit import NOINTRO
from .base_scraper import github_headers
+1 -1
View File
@@ -53,7 +53,7 @@ from .configgen_launchers import (
_assigned_name,
end_line,
)
from .shell_launchers import LauncherPatternMissing, Script, source_ref
from scraper.shell_launchers import LauncherPatternMissing, Script, source_ref
CONFIGGEN = "package/system/knulli-configgen/configgen/configgen"
GENERATORS = f"{CONFIGGEN}/generators"
+1 -1
View File
@@ -14,7 +14,7 @@ import bisect
import re
from collections.abc import Callable, Iterator
from .shell_launchers import is_feature_ref, split_ref
from resolve.launcherrefs import is_feature_ref, split_ref
GENERATORS = "emulatorLauncher/Generators"
FEATURES = ".emulationstation/es_features.cfg"
+2 -2
View File
@@ -18,8 +18,8 @@ from dataclasses import dataclass
from typing import TypeVar
from .configgen_launchers import Launcher
from .shell_launchers import config_placement, evidence_fields
from .shell_launchers import (
from scraper.shell_launchers import config_placement, evidence_fields
from scraper.shell_launchers import (
LauncherPatternMissing,
Link,
RepoTree,
+1 -1
View File
@@ -25,7 +25,7 @@ from .base_scraper import (
requirement_entry,
)
from .rocknix_launchers import extract_launchers
from .shell_launchers import RepoTree
from scraper.shell_launchers import RepoTree
PLATFORM_NAME = "rocknix"
-42
View File
@@ -59,48 +59,6 @@ def source_ref(parts: Iterable[tuple[str, Iterable[int]]]) -> str:
)
# The files a platform ships as configuration: an emulator reads them, the
# platform's code never runs them. Batocera's .yml lists and an EmuELEC .opt
# only offer the values a menu option takes.
_CONFIG_FILE = re.compile(
r"\.(?:ini|cfg|conf|rc|rc_\w+|opt|bml|toml|uae|template|yml|yaml)$", re.IGNORECASE
)
_FEATURE_FILE = re.compile(r"(?:^|/)es_features[^/]*$|\.opt$", re.IGNORECASE)
def split_ref(ref: str) -> list[str]:
"""The parts of a source_ref, each "path:lines", a bare line span
continuing the path before it."""
parts: list[str] = []
for part in (p.strip() for p in ref.split(", ")):
if not part:
continue
if re.fullmatch(r"\d+(?:-\d+)?", part) and parts:
parts[-1] += f", {part}"
else:
parts.append(part)
return parts
def ref_path(part: str) -> str:
return part.rsplit(":", 1)[0] if re.search(r":\d", part) else part
def config_ref(ref: str) -> list[str]:
"""The parts of a source_ref that cite a config, option or feature file.
Such a part proves what the file says, never that an emulator reads it:
melonDS.ini keys are written on ROCKNIX for a build that reads them only
when another key is set.
"""
return [part for part in split_ref(ref) if _CONFIG_FILE.search(ref_path(part))]
def is_feature_ref(part: str) -> bool:
"""Whether a source_ref part cites a file that lists a menu option's values."""
return bool(_FEATURE_FILE.search(ref_path(part)))
@dataclass
class Word:
"""A shell word: as written, and with quotes removed."""