mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 14:28:54 -06:00
fix: resolve coreinfo --compare-db like the packs
This commit is contained in:
1 parent
888799e24c
commit
eec854cc0b
3 files changed
+92
-8
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""Which core-info firmware the collection holds, by the resolver's rule."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .base_scraper import BiosRequirement
|
||||
|
||||
|
||||
def is_held(req: BiosRequirement, db: dict) -> bool:
|
||||
"""Whether the collection holds *req*: its md5 first, its name only
|
||||
when the .info notes declare none."""
|
||||
basename = req.destination.rsplit("/", 1)[-1] or req.name
|
||||
entry = {"name": basename, "md5": req.md5, "destination": req.destination}
|
||||
local, status = resolve_local_file(entry, db, dest_hint=req.destination)
|
||||
return local is not None and status not in ("not_found", "hash_mismatch")
|
||||
|
||||
|
||||
def split_by_holding(
|
||||
reqs: list[BiosRequirement], db: dict,
|
||||
) -> tuple[list[BiosRequirement], list[BiosRequirement]]:
|
||||
"""The requirements the collection holds, then those it lacks."""
|
||||
found: list[BiosRequirement] = []
|
||||
missing: list[BiosRequirement] = []
|
||||
for req in reqs:
|
||||
(found if is_held(req, db) else missing).append(req)
|
||||
return found, missing
|
||||
@@ -34,6 +34,7 @@ from .base_scraper import (
|
||||
_print_dry_run,
|
||||
github_tree,
|
||||
)
|
||||
from .coreinfo_coverage import split_by_holding
|
||||
|
||||
PLATFORM_NAME = "libretro_coreinfo"
|
||||
|
||||
@@ -314,16 +315,10 @@ def main() -> None:
|
||||
if args.compare_db:
|
||||
db = load_database(args.compare_db)
|
||||
|
||||
found = 0
|
||||
missing = []
|
||||
for r in reqs:
|
||||
if r.name in db["indexes"]["by_name"] or r.md5 and r.md5 in db["indexes"]["by_md5"]:
|
||||
found += 1
|
||||
else:
|
||||
missing.append(r)
|
||||
found, missing = split_by_holding(reqs, db)
|
||||
|
||||
print(f"Core-info: {len(reqs)} unique firmware paths")
|
||||
print(f"Found in DB: {found}")
|
||||
print(f"Found in DB: {len(found)}")
|
||||
print(f"Missing: {len(missing)}")
|
||||
if missing:
|
||||
print("\nMissing files:")
|
||||
|
||||
Reference in new issue
Block a user