mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 10:03:49 -06:00
fix: suggest the database beside a mistyped --db
--db databse.json, with database.json in the same folder, was told to run generate_db --force --output databse.json: a rescan of the whole collection into a second file under the typo. load_database now names the closest .json in that folder first, and gives the rebuild command only when none is close.
This commit is contained in:
1 parent
de8f20f409
commit
8b55ab45a5
2 files changed
+26
No files matched your search
@@ -73,6 +73,18 @@ def load_database(db_path: str) -> dict:
|
||||
with open(db_path) as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
# A mistyped --db beside the real database was told to rescan the
|
||||
# whole collection into a second file under the typo.
|
||||
import difflib # noqa: PLC0415
|
||||
|
||||
typed = Path(db_path)
|
||||
close = difflib.get_close_matches(
|
||||
typed.name, [p.name for p in typed.parent.glob("*.json")], n=1, cutoff=0.8
|
||||
)
|
||||
if close:
|
||||
raise DatabaseUnreadable(
|
||||
f"{db_path} not found. Did you mean {typed.with_name(close[0])}?"
|
||||
) from None
|
||||
raise DatabaseUnreadable(
|
||||
f"{db_path} not found. Build it with: python scripts/generate_db.py "
|
||||
f"--force --bios-dir bios --output {db_path}"
|
||||
|
||||
Reference in new issue
Block a user