mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 02:27:52 -06:00
refactor: reuse the shared helpers left copied
Copies of helpers the first pass created, replaced by the helper: - source_yaml_file for our YAML sources (generate_db read them in the locale's encoding, a syntax error named no file); - data_dir_registry_at in registry_bundles, platform_registry_at (new, beside load_platform_registry) in the manifest; - DATA_DIRS_FILE for the registry path five modules spelled; - load_optional_database, sha1_at, VERSIONS_FILE, installer_module; - DerivedView where a cache was keyed by id() of a dict; - count_text and series where a plural or a list was written by hand.
This commit is contained in:
1 parent
32a4ca1fa1
commit
036a6ebf29
35 files changed
+141
-170
No files matched your search
@@ -29,13 +29,12 @@ def load_data_dir_registry(platforms_dir: str | Path = PLATFORMS_DIR, required:
|
||||
return data_dir_registry_at(os.path.join(platforms_dir, "_data_dirs.yml"), required)
|
||||
|
||||
|
||||
def load_platform_registry(platforms_dir: str | Path = PLATFORMS_DIR, required: bool = False) -> dict:
|
||||
"""Return the `platforms:` mapping from _registry.yml.
|
||||
def platform_registry_at(registry_path: str | os.PathLike[str], required: bool = False) -> dict:
|
||||
"""The `platforms:` mapping of a platform registry file.
|
||||
|
||||
An absent file is an empty registry, or with ``required`` an input the
|
||||
command cannot run without.
|
||||
"""
|
||||
registry_path = os.path.join(platforms_dir, "_registry.yml")
|
||||
if not os.path.exists(registry_path):
|
||||
if required:
|
||||
raise InputMissing(f"{registry_path} not found")
|
||||
@@ -43,6 +42,11 @@ def load_platform_registry(platforms_dir: str | Path = PLATFORMS_DIR, required:
|
||||
return (source_yaml_file(registry_path) or {}).get("platforms") or {}
|
||||
|
||||
|
||||
def load_platform_registry(platforms_dir: str | Path = PLATFORMS_DIR, required: bool = False) -> dict:
|
||||
"""Return the `platforms:` mapping from _registry.yml."""
|
||||
return platform_registry_at(os.path.join(platforms_dir, "_registry.yml"), required)
|
||||
|
||||
|
||||
def list_registered_platforms(platforms_dir: str = PLATFORMS_DIR) -> list[str]:
|
||||
"""List platforms registered in _registry.yml.
|
||||
|
||||
|
||||
Reference in new issue
Block a user