From 830ebc83f86ac7ac1f08ed5619a3b38e65d26e04 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 16 Sep 2023 09:36:14 -0400 Subject: Set correct path for loading config on windows --- src/config.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') 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() -- cgit