mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-12 21:13:49 -06:00
fix: refuse a missing emulator profile directory
This commit is contained in:
1 parent
1c3462e7fd
commit
6445e5d7d6
7 files changed
+91
-21
No files matched your search
+12
-8
@@ -43,7 +43,12 @@ def require_directory(path: str, flag: str = "--bios-dir") -> None:
|
||||
raise SystemExit(f"ERROR: {flag} {path} is not a directory")
|
||||
|
||||
|
||||
class DatabaseUnreadable(FileNotFoundError):
|
||||
class InputMissing(FileNotFoundError):
|
||||
"""An input a command was pointed at does not exist. run_cli prints the
|
||||
message on one line instead of a stack trace."""
|
||||
|
||||
|
||||
class DatabaseUnreadable(InputMissing):
|
||||
"""The database a command was pointed at does not exist or is not JSON."""
|
||||
|
||||
|
||||
@@ -2181,12 +2186,11 @@ def load_emulator_profiles(
|
||||
return {}
|
||||
profiles = {}
|
||||
emu_path = Path(emulators_dir)
|
||||
if not emu_path.exists():
|
||||
print(
|
||||
f"warning: no emulator profile directory at {emulators_dir}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return profiles
|
||||
if not emu_path.is_dir():
|
||||
# Read as "no emulator", a mistyped --emulators-dir built a pack
|
||||
# without any core file marked OK, and sitesources wrote {} over
|
||||
# source-paths.json, both exiting 0.
|
||||
raise InputMissing(f"no emulator profile directory at {emulators_dir}")
|
||||
for f in source_yaml_paths(emu_path):
|
||||
with open(f) as fh:
|
||||
profile = yaml_load(fh) or {}
|
||||
@@ -3571,7 +3575,7 @@ def run_cli(main: Callable[[], int | None]) -> None:
|
||||
try:
|
||||
code = main()
|
||||
sys.stdout.flush()
|
||||
except DatabaseUnreadable as exc:
|
||||
except InputMissing as exc:
|
||||
print(f"ERROR: {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except BrokenPipeError:
|
||||
|
||||
@@ -25,7 +25,7 @@ from pathlib import Path
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
import upstream
|
||||
from common import suggest_names
|
||||
from common import require_directory, suggest_names
|
||||
from profile_sync import collect_citations, ref_role, select_views, split_source_ref
|
||||
from safeparse import yaml_load
|
||||
|
||||
@@ -122,6 +122,7 @@ def main() -> None:
|
||||
args = parser.parse_args()
|
||||
if args.all == bool(args.emulators):
|
||||
parser.error("name profiles or pass --all, not both")
|
||||
require_directory(args.emulators_dir, "--emulators-dir")
|
||||
|
||||
known = sorted(path.stem for path in Path(args.emulators_dir).glob("*.yml"))
|
||||
unknown = [name for name in args.emulators if name not in known]
|
||||
|
||||
@@ -27,6 +27,7 @@ from dataclasses import dataclass
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
import upstream
|
||||
from common import require_directory
|
||||
from safeparse import yaml_load
|
||||
from scraper.mame_parser import _MACHINE_MACROS, strip_comments
|
||||
|
||||
@@ -145,6 +146,7 @@ def main() -> None:
|
||||
help="rewrite the refs the audit can settle",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
require_directory(args.emulators_dir, "--emulators-dir")
|
||||
|
||||
total = 0
|
||||
for name in args.emulators:
|
||||
|
||||
@@ -50,7 +50,7 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
from ..artifacts import write_text_atomic
|
||||
from ..common import load_emulator_profiles
|
||||
from ..common import load_emulator_profiles, run_cli
|
||||
from .romset_dat_importer import (
|
||||
LISTXML_CHUNK,
|
||||
MAME_LISTXML_URL,
|
||||
@@ -1203,4 +1203,4 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
run_cli(main)
|
||||
@@ -45,6 +45,7 @@ from ..common import (
|
||||
list_registered_platforms,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
run_cli,
|
||||
)
|
||||
from ..dumpcatalog import build_snapshot, load_provenance_snapshots, write_snapshot
|
||||
from .logiqx_parser import LogiqxDat, parse_logiqx
|
||||
@@ -665,4 +666,4 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
run_cli(main)
|
||||
Reference in new issue
Block a user