mirror of
https://github.com/rommapp/romm.git
synced 2026-03-03 02:27:00 +00:00
config file is now required
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
import pydash
|
||||
@@ -66,11 +64,7 @@ class ConfigManager:
|
||||
# Tests require custom config path
|
||||
def __init__(self, config_file: str = ROMM_USER_CONFIG_FILE):
|
||||
self.config_file = config_file
|
||||
# If config file doesn't exists, create an empty one
|
||||
if not os.path.exists(config_file):
|
||||
Path(ROMM_USER_CONFIG_PATH).mkdir(parents=True, exist_ok=True)
|
||||
with open(config_file, "w") as file:
|
||||
file.write("")
|
||||
|
||||
try:
|
||||
self.get_config()
|
||||
except ConfigNotReadableException as e:
|
||||
@@ -221,14 +215,8 @@ class ConfigManager:
|
||||
sys.exit(3)
|
||||
|
||||
def get_config(self) -> Config:
|
||||
try:
|
||||
with open(self.config_file) as config_file:
|
||||
self._raw_config = yaml.load(config_file, Loader=SafeLoader) or {}
|
||||
except FileNotFoundError:
|
||||
self._raw_config = {}
|
||||
except PermissionError as exc:
|
||||
self._raw_config = {}
|
||||
raise ConfigNotReadableException from exc
|
||||
with open(self.config_file) as config_file:
|
||||
self._raw_config = yaml.load(config_file, Loader=SafeLoader) or {}
|
||||
|
||||
self._parse_config()
|
||||
self._validate_config()
|
||||
|
||||
@@ -17,7 +17,7 @@ from handler.metadata.igdb_handler import IGDB_API_ENABLED, IGDBRom
|
||||
from handler.metadata.moby_handler import MOBY_API_ENABLED, MobyGamesRom
|
||||
from handler.metadata.sgdb_handler import STEAMGRIDDB_API_ENABLED
|
||||
from handler.metadata.ss_handler import SS_API_ENABLED, SSRom
|
||||
from handler.scan_handler import _get_main_platform_igdb_id
|
||||
from handler.scan_handler import get_main_platform_igdb_id
|
||||
from logger.formatter import BLUE, CYAN
|
||||
from logger.formatter import highlight as hl
|
||||
from logger.logger import log
|
||||
@@ -101,7 +101,7 @@ async def search_rom(
|
||||
elif search_by.lower() == "name":
|
||||
igdb_matched_roms, moby_matched_roms, ss_matched_roms = await asyncio.gather(
|
||||
meta_igdb_handler.get_matched_roms_by_name(
|
||||
search_term, (await _get_main_platform_igdb_id(rom.platform))
|
||||
search_term, get_main_platform_igdb_id(rom.platform)
|
||||
),
|
||||
meta_moby_handler.get_matched_roms_by_name(
|
||||
search_term, rom.platform.moby_id
|
||||
|
||||
@@ -58,7 +58,7 @@ class MetadataSource:
|
||||
SGDB = "sgdb" # SteamGridDB
|
||||
|
||||
|
||||
def _get_main_platform_igdb_id(platform: Platform):
|
||||
def get_main_platform_igdb_id(platform: Platform):
|
||||
cnfg = cm.get_config()
|
||||
|
||||
if platform.fs_slug in cnfg.PLATFORMS_VERSIONS.keys():
|
||||
@@ -387,7 +387,7 @@ async def scan_rom(
|
||||
return await meta_igdb_handler.get_rom_by_id(playmatch_rom["igdb_id"])
|
||||
|
||||
# If no matches found, use the file name to get the IGDB ID
|
||||
main_platform_igdb_id = _get_main_platform_igdb_id(platform)
|
||||
main_platform_igdb_id = get_main_platform_igdb_id(platform)
|
||||
return await meta_igdb_handler.get_rom(
|
||||
rom_attrs["fs_name"], main_platform_igdb_id or platform.igdb_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user