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 | 9e18638dbd378db5737c9ddd9ef5c16a7e8ca4c7 (patch) | |
tree | d36fb80a262c1efc7aee15a0f1a1a9a092dcaade /src/config.py | |
parent | 830ebc83f86ac7ac1f08ed5619a3b38e65d26e04 (diff) |
Set default paths for db based on os
Diffstat (limited to 'src/config.py')
-rw-r--r-- | src/config.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/config.py b/src/config.py index 468718a..0fa034e 100644 --- a/src/config.py +++ b/src/config.py @@ -19,10 +19,12 @@ class Config(): self.loadConfig() def getConfigPath(self): + # Windows config path is "$LOCALAPPDATA/assignment-list-pyqt5/config" if sys.platform.startswith("win32"): - return os.path.join(os.path.expandvars("$APPDATA"), + return os.path.join(os.path.expandvars("$LOCALAPPDATA"), "assignment-list-pyqt5", "config") + # Unix config path is "$HOME/.config/assignment-list-pyqt5/config" else: return os.path.join( os.path.expanduser("~"), @@ -44,15 +46,26 @@ class Config(): def createConfig(self): self.config = configparser.ConfigParser() - self.config["paths"] = { - "db_path": os.path.join( - os.path.expanduser("~"), - ".local", - "share", - "assignment-list-pyqt5", - "data.db" - ) - } + if sys.platform.startswith("win32"): + self.config["paths"] = { + # Windows default DB path is "$APPDATA/assignment-list-pyqt5/data.db" + "db_path": os.path.join( + os.path.expandvars("$APPDATA"), + "assignment-list-pyqt5", + "data.db" + ) + } + else: + self.config["paths"] = { + # Unix default DB path is "$HOME/.local/share/assignment-list-pyqt5/data.db" + "db_path": os.path.join( + os.path.expanduser("~"), + ".local", + "share", + "assignment-list-pyqt5", + "data.db" + ) + } self.updateConfig() |