mirror of
https://github.com/Abdess/retrobios.git
synced 2026-06-28 05:22:47 +00:00
feat: add --group-by manufacturer for split packs
This commit is contained in:
parent
94a28f5459
commit
3ded72f72b
3 changed files with 65 additions and 0 deletions
|
|
@ -655,6 +655,21 @@ MANUFACTURER_PREFIXES = (
|
|||
)
|
||||
|
||||
|
||||
def derive_manufacturer(system_id: str, system_data: dict) -> str:
|
||||
"""Derive manufacturer name for a system.
|
||||
|
||||
Priority: explicit manufacturer field > system ID prefix > 'Other'.
|
||||
"""
|
||||
mfr = system_data.get("manufacturer", "")
|
||||
if mfr and mfr not in ("Various", "Other"):
|
||||
return mfr.split("|")[0].strip()
|
||||
s = system_id.lower().replace("_", "-")
|
||||
for prefix in MANUFACTURER_PREFIXES:
|
||||
if s.startswith(prefix):
|
||||
return prefix.rstrip("-").title()
|
||||
return "Other"
|
||||
|
||||
|
||||
def _norm_system_id(sid: str) -> str:
|
||||
"""Normalize system ID for cross-platform matching.
|
||||
|
||||
|
|
|
|||
|
|
@ -902,6 +902,20 @@ def _system_display_name(system_id: str) -> str:
|
|||
return "_".join(p.title() for p in parts if p)
|
||||
|
||||
|
||||
def _group_systems_by_manufacturer(
|
||||
systems: dict[str, dict],
|
||||
db: dict,
|
||||
bios_dir: str,
|
||||
) -> dict[str, list[str]]:
|
||||
"""Group system IDs by manufacturer for --split --group-by manufacturer."""
|
||||
from common import derive_manufacturer
|
||||
groups: dict[str, list[str]] = {}
|
||||
for sid, sys_data in systems.items():
|
||||
mfr = derive_manufacturer(sid, sys_data)
|
||||
groups.setdefault(mfr, []).append(sid)
|
||||
return groups
|
||||
|
||||
|
||||
def generate_split_packs(
|
||||
platform_name: str,
|
||||
platforms_dir: str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue