refactor: one copy of each duplicated helper

This commit is contained in:
Abdessamad Derraz committed 2026-11-18 22:16:55 +01:00
1 parent 2c8a9cfad8
commit 238f70c7a7
11 files changed
+49 -79

No files matched your search

+6 -13
View File
@@ -21,6 +21,7 @@ from model.declarations import OUTER_ROOTS
from model.platforms import load_platform_config
from model.registry import list_registered_platforms, load_data_dir_registry
from model.systems import _norm_system_id
from packs.gaps import _gap_destination
from resolve.archives import archive_entry
from resolve.content import content_fits, name_match_size_ok
from resolve.directories import directory_members, expand_directory_entries
@@ -720,18 +721,6 @@ def profile_breakdown(data: dict) -> str:
return ", ".join(parts)
def _effective_path(f: dict, fname: str, is_standalone: bool, save_root: bool) -> str:
# The destination the running build reads, as find_undeclared_files
# takes it: Batocera's standalone Cemu reads keys.txt at
# standalone_path, and the libretro Cemu/keys.txt reported here
# settled the declaration on a slot the platform never fills.
if is_standalone:
return f.get("standalone_path") or f.get("path") or fname
if save_root:
return f.get("path") or fname
return system_dir_path(f, f.get("path") or fname)
@dataclass
class _ProfileComparison:
"""One profile's entries against the platforms' declarations."""
@@ -768,7 +757,11 @@ class _ProfileComparison:
fname = f.get("name", "")
platform = self.platform
save_root = read_from_save_dir(f, is_standalone)
effective_path = _effective_path(f, fname, is_standalone, save_root)
# The destination the running build reads, as find_undeclared_files
# takes it: Batocera's standalone Cemu reads keys.txt at
# standalone_path, and the libretro Cemu/keys.txt reported here
# settled the declaration on a slot the platform never fills.
effective_path = _gap_destination(f, fname, is_standalone, save_root)
slot = slot_key(f, is_standalone)
seen_key = slot
if len(self.layouts) > 1:
+1 -9
View File
@@ -24,12 +24,12 @@ from core.artifacts import file_lock as _file_lock, set_plain_mode
from core.cli import InputMissing
from core.github import github_token
from model.safeparse import yaml_load
from model.registry import VERSIONS_FILE, _load_versions
log = logging.getLogger(__name__)
DEFAULT_REGISTRY = "platforms/_data_dirs.yml"
VERSIONS_FILE = "data/.versions.json"
USER_AGENT = "retrobios/1.0"
REQUEST_TIMEOUT = 30
DOWNLOAD_TIMEOUT = 300
@@ -125,14 +125,6 @@ def hold_data_dirs(stack: contextlib.ExitStack, registry: dict) -> None:
stack.enter_context(cache_lock(cache, shared=True))
def _load_versions(versions_path: str = VERSIONS_FILE) -> dict[str, dict]:
path = Path(versions_path)
if not path.exists():
return {}
with open(path) as f:
return json.load(f)
def _save_versions(
versions: dict[str, dict], versions_path: str = VERSIONS_FILE
) -> None: