mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-04-13 12:22:33 -05:00
fix: exporters match exact native formats with display names
This commit is contained in:
@@ -30,3 +30,26 @@ class BaseExporter(ABC):
|
||||
def _is_pattern(name: str) -> bool:
|
||||
"""Check if a filename is a placeholder pattern (not a real file)."""
|
||||
return "<" in name or ">" in name or "*" in name
|
||||
|
||||
@staticmethod
|
||||
def _display_name(
|
||||
sys_id: str, scraped_sys: dict | None = None,
|
||||
) -> str:
|
||||
"""Get display name for a system from scraped data or slug."""
|
||||
if scraped_sys:
|
||||
name = scraped_sys.get("name")
|
||||
if name:
|
||||
return name
|
||||
# Fallback: convert slug to display name with acronym handling
|
||||
_UPPER = {
|
||||
"3do", "cps1", "cps2", "cps3", "dos", "gba", "gbc", "msx",
|
||||
"nes", "nds", "ngp", "psp", "psx", "sms", "snes", "tvc",
|
||||
}
|
||||
parts = sys_id.replace("-", " ").split()
|
||||
result = []
|
||||
for p in parts:
|
||||
if p.lower() in _UPPER:
|
||||
result.append(p.upper())
|
||||
else:
|
||||
result.append(p.capitalize())
|
||||
return " ".join(result)
|
||||
|
||||
@@ -11,9 +11,6 @@ from pathlib import Path
|
||||
from .base_exporter import BaseExporter
|
||||
|
||||
|
||||
def _slug_to_display(slug: str) -> str:
|
||||
"""Convert slug to display name: 'atari-5200' -> 'Atari 5200'."""
|
||||
return slug.replace("-", " ").title()
|
||||
|
||||
|
||||
class Exporter(BaseExporter):
|
||||
@@ -31,15 +28,11 @@ class Exporter(BaseExporter):
|
||||
) -> None:
|
||||
# Build native_id and display name maps from scraped data
|
||||
native_map: dict[str, str] = {}
|
||||
display_map: dict[str, str] = {}
|
||||
if scraped_data:
|
||||
for sys_id, sys_data in scraped_data.get("systems", {}).items():
|
||||
nid = sys_data.get("native_id")
|
||||
if nid:
|
||||
native_map[sys_id] = nid
|
||||
dname = sys_data.get("name")
|
||||
if dname:
|
||||
display_map[sys_id] = dname
|
||||
|
||||
lines: list[str] = ["systems = {", ""]
|
||||
|
||||
@@ -51,7 +44,8 @@ class Exporter(BaseExporter):
|
||||
continue
|
||||
|
||||
native_id = native_map.get(sys_id, sys_id)
|
||||
display_name = display_map.get(sys_id, _slug_to_display(sys_id))
|
||||
scraped_sys = scraped_data.get("systems", {}).get(sys_id) if scraped_data else None
|
||||
display_name = self._display_name(sys_id, scraped_sys)
|
||||
|
||||
# Build biosFiles entries as compact single-line dicts
|
||||
bios_parts: list[str] = []
|
||||
|
||||
@@ -15,9 +15,6 @@ from pathlib import Path
|
||||
from .base_exporter import BaseExporter
|
||||
|
||||
|
||||
def _slug_to_display(slug: str) -> str:
|
||||
"""Convert slug to display name."""
|
||||
return slug.replace("-", " ").title()
|
||||
|
||||
|
||||
class Exporter(BaseExporter):
|
||||
@@ -34,15 +31,11 @@ class Exporter(BaseExporter):
|
||||
scraped_data: dict | None = None,
|
||||
) -> None:
|
||||
native_map: dict[str, str] = {}
|
||||
display_map: dict[str, str] = {}
|
||||
if scraped_data:
|
||||
for sys_id, sys_data in scraped_data.get("systems", {}).items():
|
||||
nid = sys_data.get("native_id")
|
||||
if nid:
|
||||
native_map[sys_id] = nid
|
||||
dname = sys_data.get("name")
|
||||
if dname:
|
||||
display_map[sys_id] = dname
|
||||
|
||||
lines: list[str] = [
|
||||
'<?xml version="1.0" encoding="UTF-8"?>',
|
||||
@@ -58,7 +51,8 @@ class Exporter(BaseExporter):
|
||||
continue
|
||||
|
||||
native_id = native_map.get(sys_id, sys_id)
|
||||
display_name = display_map.get(sys_id, _slug_to_display(sys_id))
|
||||
scraped_sys = scraped_data.get("systems", {}).get(sys_id) if scraped_data else None
|
||||
display_name = self._display_name(sys_id, scraped_sys)
|
||||
|
||||
lines.append(f' <system fullname="{display_name}" platform="{native_id}">')
|
||||
|
||||
|
||||
@@ -15,9 +15,6 @@ from pathlib import Path
|
||||
from .base_exporter import BaseExporter
|
||||
|
||||
|
||||
def _slug_to_display(slug: str) -> str:
|
||||
"""Convert slug to display name."""
|
||||
return slug.replace("-", " ").title()
|
||||
|
||||
|
||||
class Exporter(BaseExporter):
|
||||
@@ -34,15 +31,11 @@ class Exporter(BaseExporter):
|
||||
scraped_data: dict | None = None,
|
||||
) -> None:
|
||||
native_map: dict[str, str] = {}
|
||||
display_map: dict[str, str] = {}
|
||||
if scraped_data:
|
||||
for sys_id, sys_data in scraped_data.get("systems", {}).items():
|
||||
nid = sys_data.get("native_id")
|
||||
if nid:
|
||||
native_map[sys_id] = nid
|
||||
dname = sys_data.get("name")
|
||||
if dname:
|
||||
display_map[sys_id] = dname
|
||||
|
||||
output: OrderedDict[str, dict] = OrderedDict()
|
||||
|
||||
@@ -54,7 +47,8 @@ class Exporter(BaseExporter):
|
||||
continue
|
||||
|
||||
native_id = native_map.get(sys_id, sys_id)
|
||||
display_name = display_map.get(sys_id, _slug_to_display(sys_id))
|
||||
scraped_sys = scraped_data.get("systems", {}).get(sys_id) if scraped_data else None
|
||||
display_name = self._display_name(sys_id, scraped_sys)
|
||||
bios_files: list[OrderedDict] = []
|
||||
|
||||
for fe in files:
|
||||
|
||||
@@ -46,16 +46,28 @@ class Exporter(BaseExporter):
|
||||
if nid:
|
||||
native_map[sys_id] = nid
|
||||
|
||||
# Match exact header format of libretro-database/dat/System.dat
|
||||
version = ""
|
||||
if scraped_data:
|
||||
version = scraped_data.get("dat_version", scraped_data.get("version", ""))
|
||||
lines: list[str] = [
|
||||
"clrmamepro (",
|
||||
'\tname "System"',
|
||||
'\tdescription "System"',
|
||||
'\tcomment "System, firmware, and BIOS files used by libretro cores."',
|
||||
]
|
||||
if version:
|
||||
lines.append(f"\tversion {version}")
|
||||
lines.extend([
|
||||
'\tauthor "libretro"',
|
||||
'\thomepage "https://github.com/libretro/libretro-database/blob/master/dat/System.dat"',
|
||||
'\turl "https://raw.githubusercontent.com/libretro/libretro-database/master/dat/System.dat"',
|
||||
")",
|
||||
"",
|
||||
"game (",
|
||||
'\tname "System"',
|
||||
]
|
||||
'\tcomment "System"',
|
||||
])
|
||||
|
||||
systems = truth_data.get("systems", {})
|
||||
for sys_id in sorted(systems):
|
||||
|
||||
Reference in New Issue
Block a user