mod: use Path instead of strings
This commit is contained in:
parent
6918e175c4
commit
5cfab64b07
2 changed files with 9 additions and 6 deletions
|
|
@ -1,17 +1,18 @@
|
|||
import tomlkit
|
||||
from pathlib import Path
|
||||
from tomlkit import TOMLDocument
|
||||
|
||||
|
||||
class Mod:
|
||||
__config: TOMLDocument
|
||||
__path: str
|
||||
__path: Path
|
||||
__name: str
|
||||
__description: str
|
||||
__author: str
|
||||
__enabled: bool
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
def path(self) -> Path:
|
||||
return self.__path
|
||||
|
||||
# Mod metadata
|
||||
|
|
@ -44,15 +45,17 @@ class Mod:
|
|||
# Nothing to do
|
||||
return
|
||||
|
||||
with open(self.__path + "config.toml", "w") as config_file:
|
||||
config_toml = Path(self.__path, "config.toml")
|
||||
with config_toml.open("w") as config_file:
|
||||
self.__config["enabled"] = value
|
||||
tomlkit.dump(self.__config, config_file)
|
||||
|
||||
def __init__(self, path: str) -> None:
|
||||
def __init__(self, path: Path) -> None:
|
||||
self.__path = path
|
||||
|
||||
try:
|
||||
with open(path + "config.toml") as config_file:
|
||||
config_toml = Path(self.__path, "config.toml")
|
||||
with config_toml.open() as config_file:
|
||||
self.__config = tomlkit.load(config_file)
|
||||
|
||||
if "enabled" not in self.__config:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue