mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-03 14:58:51 -06:00
refactor: pass the release record to find_pack
This commit is contained in:
1 parent
6dd9eabcb8
commit
04c2691298
4 files changed
+24
-24
No files matched your search
+5
-2
@@ -27,8 +27,10 @@ import urllib.error
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from core.paths import REPO_ROOT
|
||||
from core.upstream import UpstreamError
|
||||
from core.ziptools import safe_extract_zip
|
||||
from model.releaserecord import RECORD, load_record
|
||||
from release.downloaderror import DownloadError
|
||||
from release.latest import DEFAULT_API, checked_url, get_latest_release
|
||||
from release.packfetch import fetch_checksums, fetch_pack, make_staging
|
||||
@@ -92,14 +94,15 @@ def main() -> None:
|
||||
print(f"Error fetching release info: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
record = load_record(REPO_ROOT / RECORD)
|
||||
if args.info:
|
||||
show_info(args.platform, release)
|
||||
show_info(args.platform, release, record)
|
||||
return
|
||||
|
||||
if not args.dest:
|
||||
parser.error("Destination directory required")
|
||||
|
||||
pack = find_pack(release, args.platform)
|
||||
pack = find_pack(release, args.platform, record)
|
||||
if not pack:
|
||||
exit_without_pack(args.platform, release)
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ from __future__ import annotations
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
from model.releaserecord import PACK_SUFFIX, RECORD, load_record, match_key, pack_label, recorded_pack
|
||||
from model.releaserecord import PACK_SUFFIX, match_key, pack_label, recorded_pack
|
||||
from packs.parts import part_of
|
||||
|
||||
_VOLUME_RE = re.compile(rf"^(?P<base>.+{re.escape(PACK_SUFFIX)})\.(?P<index>\d+)$")
|
||||
@@ -69,16 +68,15 @@ def list_platforms(release: dict) -> list[str]:
|
||||
return sorted(pack.platform for pack in group_packs(release))
|
||||
|
||||
|
||||
def find_pack(release: dict, platform: str) -> Pack | None:
|
||||
def find_pack(release: dict, platform: str, record: dict) -> Pack | None:
|
||||
"""Find the pack for a platform name.
|
||||
|
||||
release.json names the platforms each pack serves, and is read when it
|
||||
records this release. Otherwise the platform is matched against the pack
|
||||
The record (release.json) names the platforms each pack serves, and is
|
||||
read when it records this release. Otherwise the platform is matched against the pack
|
||||
names, the shortest first: RetroArch_v1.22.2 is the full pack, and
|
||||
RetroArch_v1.22.2_AndroidArm64V8A one target's.
|
||||
"""
|
||||
packs = group_packs(release)
|
||||
record = load_record(REPO_ROOT / RECORD)
|
||||
if record.get("tag") and record.get("tag") == release.get("tag_name"):
|
||||
name = recorded_pack(platform, record)
|
||||
return next((pack for pack in packs if pack.name == name), None)
|
||||
|
||||
@@ -25,9 +25,9 @@ def exit_without_pack(platform: str, release: dict) -> NoReturn:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def show_info(platform: str, release: dict) -> None:
|
||||
"""Show pack information for a platform."""
|
||||
pack = find_pack(release, platform)
|
||||
def show_info(platform: str, release: dict, record: dict) -> None:
|
||||
"""Show pack information for a platform, the record naming its pack."""
|
||||
pack = find_pack(release, platform, record)
|
||||
if not pack:
|
||||
exit_without_pack(platform, release)
|
||||
|
||||
|
||||
Reference in new issue
Block a user