mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 04:48:54 -06:00
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:
1 parent
83cfa6fd0f
commit
c764d9abf1
56 files changed
+839
-804
No files matched your search
@@ -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."""
|
||||
|
||||
Reference in new issue
Block a user