diff options
author | Louie S <louie@example.com> | 2023-09-16 09:36:14 -0400 |
---|---|---|
committer | Louie S <louie@example.com> | 2023-09-16 09:36:14 -0400 |
commit | 830ebc83f86ac7ac1f08ed5619a3b38e65d26e04 (patch) | |
tree | 4b6be8e01d6f18af95ff94dc9daab725b5b711c9 /src | |
parent | 0ce1224da8c2007de9bdf7898341142897e0c64f (diff) |
Set correct path for loading config on windows
Diffstat (limited to 'src')
-rw-r--r-- | src/config.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/config.py b/src/config.py index 2c80716..468718a 100644 --- a/src/config.py +++ b/src/config.py @@ -11,17 +11,25 @@ import src.globals as Globals class Config(): def __init__(self): - self.config_path = os.path.join( - os.path.expanduser("~"), - ".config", - "assignment-list-pyqt5", - "config") + self.config_path = self.getConfigPath() if not os.path.exists(self.config_path): self.createConfig() self.loadConfig() + def getConfigPath(self): + if sys.platform.startswith("win32"): + return os.path.join(os.path.expandvars("$APPDATA"), + "assignment-list-pyqt5", + "config") + else: + return os.path.join( + os.path.expanduser("~"), + ".config", + "assignment-list-pyqt5", + "config") + def loadConfig(self): self.config = configparser.ConfigParser() |