Mod: throw InvalidModError when config.toml doesn't exist

This commit is contained in:
Toast 2025-05-19 22:24:04 +02:00
parent dce9e5fcdc
commit 049acf68be

View file

@ -43,13 +43,16 @@ class Mod:
def __init__(self, path: str) -> None:
self.__path = path
with open(path + "config.toml") as config_file:
self.__config = tomlkit.load(config_file)
try:
with open(path + "config.toml") as config_file:
self.__config = tomlkit.load(config_file)
if "enabled" not in self.__config:
raise InvalidModError("config.toml does not contain the enabled key")
else:
self.__enabled = self.__config["enabled"]
if "enabled" not in self.__config:
raise InvalidModError("config.toml does not contain the enabled key")
else:
self.__enabled = self.__config["enabled"]
except FileNotFoundError:
raise InvalidModError("config.toml does not exist")
def __str__(self) -> str:
return f"Mod({self.__path})"