Mod: read toml with get()
This commit is contained in:
parent
54dedaba5d
commit
0850a23b35
1 changed files with 4 additions and 4 deletions
|
|
@ -19,20 +19,20 @@ class Mod:
|
|||
def name(self) -> str | None:
|
||||
if "name" not in self.__config:
|
||||
return None
|
||||
return self.__config["name"].as_string()
|
||||
return self.__config.get("name", str)
|
||||
|
||||
@property
|
||||
def description(self) -> str | None:
|
||||
if "description" not in self.__config.keys():
|
||||
return None
|
||||
else:
|
||||
return self.__config["description"].as_string()
|
||||
return self.__config.get("description",str)
|
||||
|
||||
@property
|
||||
def author(self) -> str | None:
|
||||
if "author" not in self.__config:
|
||||
return None
|
||||
return self.__config["author"].as_string()
|
||||
return self.__config.get("author",str)
|
||||
|
||||
@property
|
||||
def enabled(self) -> bool:
|
||||
|
|
@ -58,7 +58,7 @@ class Mod:
|
|||
if "enabled" not in self.__config:
|
||||
raise InvalidModError("config.toml does not contain the enabled key")
|
||||
else:
|
||||
self.__enabled = self.__config["enabled"]
|
||||
self.__enabled = self.__config.get("enabled", bool)
|
||||
except FileNotFoundError:
|
||||
raise InvalidModError("config.toml does not exist")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue