mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-03 06:48:52 -06:00
refactor: one loader for the rom-folder sources
This commit is contained in:
1 parent
17c64914ef
commit
1631ad0f4d
7 files changed
+32
-35
No files matched your search
@@ -24,8 +24,19 @@ from model.profiles import load_emulator_profiles, preferred_profile, upstream_p
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from model.sources import source_yaml_file
|
||||
|
||||
ROMFOLDERS_DIR = Path("platforms") / "romfolders"
|
||||
SOURCES_DIR = ROMFOLDERS_DIR / "_sources"
|
||||
|
||||
def romfolders_dir(platforms_dir: str | Path = PLATFORMS_DIR) -> Path:
|
||||
"""The rom-folder setups of a platforms directory."""
|
||||
return Path(platforms_dir) / "romfolders"
|
||||
|
||||
|
||||
def sources_dir(platforms_dir: str | Path = PLATFORMS_DIR) -> Path:
|
||||
"""The setups' declared sources and pins, beside the setup files."""
|
||||
return romfolders_dir(platforms_dir) / "_sources"
|
||||
|
||||
|
||||
ROMFOLDERS_DIR = romfolders_dir()
|
||||
SOURCES_DIR = sources_dir()
|
||||
|
||||
# "<source key> <path>:<line>[-<line>]", several joined by "; ".
|
||||
_REF_PART = re.compile(r"^(?P<key>[a-z0-9][a-z0-9-]*) (?P<path>\S+?)(?::(?P<lines>\d+(?:-\d+)?(?:,\d+(?:-\d+)?)*))?$")
|
||||
@@ -87,6 +98,11 @@ def setup_paths(directory: Path = ROMFOLDERS_DIR) -> list[Path]:
|
||||
return sorted(p for p in Path(directory).glob("*.yml") if not p.name.startswith("_"))
|
||||
|
||||
|
||||
def load_sources(directory: Path = SOURCES_DIR) -> dict[str, dict]:
|
||||
"""Each setup's declared sources and facts, keyed by its file name."""
|
||||
return {path.stem: source_yaml_file(path) or {} for path in sorted(Path(directory).glob("*.yml"))}
|
||||
|
||||
|
||||
def load_setup(path: Path) -> dict:
|
||||
return source_yaml_file(path)
|
||||
|
||||
|
||||
Reference in new issue
Block a user