mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-27 20:08:51 -06:00
refactor: break the launchers and layout cycle
resolve.layout imported resolve.launchers inside functions, and launchers imported the outer roots back from layout inside functions: the cycle common.py and launchers.py had. The outer roots and outer_layout read only the platform config, so they move to model.declarations beside declared_root, and launchers imports them at the top.
This commit is contained in:
1 parent
c764d9abf1
commit
bcb99cf761
10 files changed
+68
-73
No files matched your search
@@ -23,6 +23,7 @@ on:
|
||||
- "scripts/core/paths.py"
|
||||
- "scripts/core/romdir.py"
|
||||
- "scripts/core/sect233r1.py"
|
||||
- "scripts/core/torrentzip.py"
|
||||
- "scripts/core/ziptools.py"
|
||||
- "scripts/cross_reference.py"
|
||||
- "scripts/dedup.py"
|
||||
@@ -34,6 +35,7 @@ on:
|
||||
- "scripts/indexnow.py"
|
||||
- "scripts/manifestselect.py"
|
||||
- "scripts/measurement_records.py"
|
||||
- "scripts/model/__init__.py"
|
||||
- "scripts/model/alternatives.py"
|
||||
- "scripts/model/cliargs.py"
|
||||
- "scripts/model/composition.py"
|
||||
@@ -43,7 +45,9 @@ on:
|
||||
- "scripts/model/largefiles.py"
|
||||
- "scripts/model/platforms.py"
|
||||
- "scripts/model/profiles.py"
|
||||
- "scripts/model/region.py"
|
||||
- "scripts/model/registry.py"
|
||||
- "scripts/model/retired.py"
|
||||
- "scripts/model/safeparse.py"
|
||||
- "scripts/model/sources.py"
|
||||
- "scripts/model/systems.py"
|
||||
@@ -56,7 +60,6 @@ on:
|
||||
- "scripts/pr_checks.py"
|
||||
- "scripts/provenance_report.py"
|
||||
- "scripts/refresh_data_dirs.py"
|
||||
- "scripts/region.py"
|
||||
- "scripts/release_record.py"
|
||||
- "scripts/resolve/__init__.py"
|
||||
- "scripts/resolve/archives.py"
|
||||
@@ -68,22 +71,20 @@ on:
|
||||
- "scripts/resolve/directories.py"
|
||||
- "scripts/resolve/gamedata.py"
|
||||
- "scripts/resolve/grouping.py"
|
||||
- "scripts/resolve/launcherrefs.py"
|
||||
- "scripts/resolve/launchers.py"
|
||||
- "scripts/resolve/layout.py"
|
||||
- "scripts/resolve/localfile.py"
|
||||
- "scripts/resolve/nativemode.py"
|
||||
- "scripts/resolve/ownership.py"
|
||||
- "scripts/resolve/reconcile.py"
|
||||
- "scripts/resolve/regions.py"
|
||||
- "scripts/resolve/slot.py"
|
||||
- "scripts/resolve/standalone.py"
|
||||
- "scripts/resolve/truth.py"
|
||||
- "scripts/resolve/validation.py"
|
||||
- "scripts/restore_large_files.py"
|
||||
- "scripts/retired_files.py"
|
||||
- "scripts/romset_recipes.py"
|
||||
- "scripts/scraper/base_scraper.py"
|
||||
- "scripts/scraper/configgen_launchers.py"
|
||||
- "scripts/scraper/shell_launchers.py"
|
||||
- "scripts/site_markdown.py"
|
||||
- "scripts/siteagents.py"
|
||||
- "scripts/sitebootstrap.py"
|
||||
@@ -105,7 +106,6 @@ on:
|
||||
- "scripts/slots.py"
|
||||
- "scripts/sourceref.py"
|
||||
- "scripts/split_pack.py"
|
||||
- "scripts/torrentzip.py"
|
||||
- "scripts/upstream.py"
|
||||
- "scripts/validate_pr.py"
|
||||
- "scripts/validate_schemas.py"
|
||||
|
||||
@@ -27,7 +27,8 @@ from typing import TYPE_CHECKING, TypedDict
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from model.alternatives import set_keys, set_requirements, settle_sets
|
||||
from resolve.layout import OUTER_ROOTS, system_dir_path
|
||||
from model.declarations import OUTER_ROOTS
|
||||
from resolve.layout import system_dir_path
|
||||
from model.cliargs import platform_arg, list_emulator_profiles, require_platform
|
||||
from model.profiles import ProfileSelectionError, load_emulator_profiles, select_emulator_profiles
|
||||
from resolve.ownership import _foreign_tree, _owner_tokens
|
||||
|
||||
@@ -40,7 +40,8 @@ from typing import TYPE_CHECKING, TypedDict
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from model.alternatives import core_file_spares, settle_sets, slot_set_keys
|
||||
from resolve.cores import resolve_platform_cores as _platform_cores
|
||||
from resolve.layout import ROMS_ROOT, OUTER_ROOTS, outer_layout, core_system_dirs
|
||||
from model.declarations import ROMS_ROOT, OUTER_ROOTS, outer_layout
|
||||
from resolve.layout import core_system_dirs
|
||||
from resolve.contentlayout import TARGET_KEY, _core_key, content_folder_boards
|
||||
from model.profiles import (
|
||||
installed_data_refs,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from collections import Counter
|
||||
|
||||
from core.paths import sanitize_pack_path
|
||||
@@ -143,3 +144,54 @@ def merged_platform_declarations(
|
||||
def expand_platform_declared_names(config: dict, db: dict) -> set[str]:
|
||||
"""The names a platform declares, enriched as `platform_declarations`."""
|
||||
return set(platform_declarations(config, db))
|
||||
|
||||
|
||||
# The entry root of a file read below the platform's roms directory, and of
|
||||
# one read in an emulator's folder outside the BIOS tree that the registry
|
||||
# describes. Each is located by the registry entry <root>_directory.
|
||||
ROMS_ROOT = "roms"
|
||||
EMULATORS_ROOT = "emulators"
|
||||
CONFIGS_ROOT = "configs"
|
||||
OUTER_ROOTS = (ROMS_ROOT, EMULATORS_ROOT, CONFIGS_ROOT)
|
||||
|
||||
|
||||
def outer_layout(config: dict, root: str) -> dict | None:
|
||||
"""Where a platform keeps the folder an outer root names, or None.
|
||||
|
||||
roms: the roms root its rom folders file records (``path``, the OS's
|
||||
spelling, and ``from_bios``, relative to the BIOS folder), with the
|
||||
BIOS folder's own name, base_destination, that a run's folder must
|
||||
carry before ``from_bios`` is followed from it. emulators: the
|
||||
registry's ``emulators_directory``, the folders a launcher searches
|
||||
for an emulator by key, which no rom folders file describes.
|
||||
"""
|
||||
if root == ROMS_ROOT:
|
||||
found = config.get("_roms_root") or {}
|
||||
base = str(config.get("base_destination") or "")
|
||||
path, relation = found.get("path"), found.get("from_bios")
|
||||
if not (path and relation) or "<" in str(path):
|
||||
return None
|
||||
if base:
|
||||
return {"path": str(path), "from_bios": str(relation), "bios_folder": base}
|
||||
# A list whose dests start above the BIOS folder (AmberELEC's
|
||||
# bios/...) installs into the folder holding it: a roms root there
|
||||
# or below is part of the install tree, written as a plain dest.
|
||||
declared = declared_root(config)
|
||||
if not declared:
|
||||
return None
|
||||
inside = os.path.normpath(f"{declared}/{relation}")
|
||||
if inside == ".." or inside.startswith("../"):
|
||||
return None
|
||||
return {"path": str(path), "install_prefix": "" if inside == "." else inside}
|
||||
if root == EMULATORS_ROOT:
|
||||
return config.get("emulators_directory") or None
|
||||
if root == CONFIGS_ROOT:
|
||||
# The frontend's configs folder, as its path code builds it
|
||||
# (configs_root, Batocera's batoceraPaths CONFIGS).
|
||||
found = config.get("configs_root") or {}
|
||||
base = str(config.get("base_destination") or "")
|
||||
if not (found.get("path") and found.get("from_bios") and base):
|
||||
return None
|
||||
return {"path": str(found["path"]), "from_bios": str(found["from_bios"]),
|
||||
"bios_folder": base}
|
||||
return None
|
||||
@@ -22,7 +22,7 @@ from resolve.cores import resolve_platform_cores
|
||||
from resolve.layout import core_system_dirs, system_dir_path
|
||||
from resolve.standalone import platform_layouts
|
||||
from resolve.standalone import standalone_set as platform_standalone_set
|
||||
from resolve.layout import OUTER_ROOTS, outer_layout
|
||||
from model.declarations import OUTER_ROOTS, outer_layout
|
||||
from core.paths import sanitize_pack_path
|
||||
from resolve.content import declares_shape, shape_fits, size_fits
|
||||
from resolve.validation import deliverable, read_from_save_dir, read_from_system_dir
|
||||
|
||||
@@ -13,12 +13,11 @@ from resolve.layout import (
|
||||
CONTENT_SYSTEM_TAG,
|
||||
CONTENT_TAG_PREFIXES,
|
||||
OUTSIDE_BIOS_FOLDER,
|
||||
ROMS_ROOT,
|
||||
ROM_SEARCH_PREFIX,
|
||||
_placed_entry,
|
||||
outer_layout,
|
||||
standalone_layout_path,
|
||||
)
|
||||
from model.declarations import ROMS_ROOT, outer_layout
|
||||
from core.paths import REPO_ROOT
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import re
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from dataclasses import dataclass
|
||||
|
||||
from model.declarations import declared_root
|
||||
from model.declarations import CONFIGS_ROOT, ROMS_ROOT, declared_root, outer_layout
|
||||
from resolve.content import name_match_size_ok
|
||||
from resolve.localfile import resolve_local_file
|
||||
from core.paths import sanitize_pack_path
|
||||
@@ -898,8 +898,6 @@ def _roms_place(config: dict, path: str | None) -> Place | None:
|
||||
platform installs above its BIOS folder (AmberELEC), else the roms tree."""
|
||||
if path is None:
|
||||
return None
|
||||
from resolve.layout import ROMS_ROOT, outer_layout
|
||||
|
||||
layout = outer_layout(config, ROMS_ROOT) or {}
|
||||
if "install_prefix" in layout:
|
||||
prefix = layout["install_prefix"]
|
||||
@@ -914,8 +912,6 @@ def folder_in_configs(directory: str, config: dict) -> str | None:
|
||||
(``configs_root.path``): Batocera's /userdata/system/configs, where its
|
||||
generators start shadPS4 from configs/shadps4.
|
||||
"""
|
||||
from resolve.layout import CONFIGS_ROOT
|
||||
|
||||
return folder_in_root(directory, config, CONFIGS_ROOT)
|
||||
|
||||
|
||||
@@ -926,8 +922,6 @@ def folder_in_roms(directory: str, config: dict) -> str | None:
|
||||
(``roms_root.path``): ROCKNIX's /storage/roms, which holds its BIOS
|
||||
folder and the folders its launchers run programs from.
|
||||
"""
|
||||
from resolve.layout import ROMS_ROOT, outer_layout
|
||||
|
||||
spelled = directory.strip().rstrip("/")
|
||||
for variable in ROMS_ROOT_VARIABLES:
|
||||
if outer_layout(config, ROMS_ROOT) and (
|
||||
@@ -940,8 +934,6 @@ def folder_in_roms(directory: str, config: dict) -> str | None:
|
||||
|
||||
def folder_in_root(directory: str, config: dict, root: str) -> str | None:
|
||||
"""A directory relative to an outer root's path, None outside it."""
|
||||
from resolve.layout import outer_layout
|
||||
|
||||
roms = str((outer_layout(config, root) or {}).get("path") or "").rstrip("/")
|
||||
directory = directory.strip().rstrip("/")
|
||||
if not roms or not directory.startswith(roms + "/"):
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from collections.abc import Iterable, Mapping
|
||||
|
||||
from model.declarations import declared_root
|
||||
|
||||
|
||||
def runs_standalone(
|
||||
@@ -188,55 +186,6 @@ def _executed(standalone_cores: Iterable[str]) -> list:
|
||||
# Why a standalone entry has no destination on a platform that relocates its
|
||||
# layout: the manifest's omission reason, named as the installer words it.
|
||||
OUTSIDE_BIOS_FOLDER = "outside_bios_folder"
|
||||
# The entry root of a file read below the platform's roms directory, and of
|
||||
# one read in an emulator's folder outside the BIOS tree that the registry
|
||||
# describes. Each is located by the registry entry <root>_directory.
|
||||
ROMS_ROOT = "roms"
|
||||
EMULATORS_ROOT = "emulators"
|
||||
CONFIGS_ROOT = "configs"
|
||||
OUTER_ROOTS = (ROMS_ROOT, EMULATORS_ROOT, CONFIGS_ROOT)
|
||||
|
||||
|
||||
def outer_layout(config: dict, root: str) -> dict | None:
|
||||
"""Where a platform keeps the folder an outer root names, or None.
|
||||
|
||||
roms: the roms root its rom folders file records (``path``, the OS's
|
||||
spelling, and ``from_bios``, relative to the BIOS folder), with the
|
||||
BIOS folder's own name, base_destination, that a run's folder must
|
||||
carry before ``from_bios`` is followed from it. emulators: the
|
||||
registry's ``emulators_directory``, the folders a launcher searches
|
||||
for an emulator by key, which no rom folders file describes.
|
||||
"""
|
||||
if root == ROMS_ROOT:
|
||||
found = config.get("_roms_root") or {}
|
||||
base = str(config.get("base_destination") or "")
|
||||
path, relation = found.get("path"), found.get("from_bios")
|
||||
if not (path and relation) or "<" in str(path):
|
||||
return None
|
||||
if base:
|
||||
return {"path": str(path), "from_bios": str(relation), "bios_folder": base}
|
||||
# A list whose dests start above the BIOS folder (AmberELEC's
|
||||
# bios/...) installs into the folder holding it: a roms root there
|
||||
# or below is part of the install tree, written as a plain dest.
|
||||
declared = declared_root(config)
|
||||
if not declared:
|
||||
return None
|
||||
inside = os.path.normpath(f"{declared}/{relation}")
|
||||
if inside == ".." or inside.startswith("../"):
|
||||
return None
|
||||
return {"path": str(path), "install_prefix": "" if inside == "." else inside}
|
||||
if root == EMULATORS_ROOT:
|
||||
return config.get("emulators_directory") or None
|
||||
if root == CONFIGS_ROOT:
|
||||
# The frontend's configs folder, as its path code builds it
|
||||
# (configs_root, Batocera's batoceraPaths CONFIGS).
|
||||
found = config.get("configs_root") or {}
|
||||
base = str(config.get("base_destination") or "")
|
||||
if not (found.get("path") and found.get("from_bios") and base):
|
||||
return None
|
||||
return {"path": str(found["path"]), "from_bios": str(found["from_bios"]),
|
||||
"bios_folder": base}
|
||||
return None
|
||||
|
||||
|
||||
def standalone_layout_path(entry: dict, profile: dict) -> str | None:
|
||||
|
||||
@@ -11,7 +11,7 @@ import os
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
|
||||
from resolve.layout import OUTER_ROOTS
|
||||
from model.declarations import OUTER_ROOTS
|
||||
from model.systems import _norm_system_id
|
||||
from model.registry import load_data_dir_registry
|
||||
from resolve.standalone import platform_layouts, standalone_set as platform_standalone_set
|
||||
|
||||
+2
-1
@@ -54,7 +54,8 @@ from model.targets import (
|
||||
list_available_targets,
|
||||
build_target_cores_cache,
|
||||
)
|
||||
from resolve.layout import OUTER_ROOTS, runs_standalone, system_dir_path
|
||||
from model.declarations import OUTER_ROOTS
|
||||
from resolve.layout import runs_standalone, system_dir_path
|
||||
from resolve.ownership import _foreign_tree, _owner_tokens
|
||||
from model.cliargs import (
|
||||
platform_arg,
|
||||
|
||||
Reference in new issue
Block a user