Mod: throw InvalidModError when config.toml doesn't exist
This commit is contained in:
parent
dce9e5fcdc
commit
049acf68be
1 changed files with 9 additions and 6 deletions
15
src/mod.py
15
src/mod.py
|
|
@ -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})"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue