From 0983b13478ea75fc3483ad99ff4ac2af32ff24a3 Mon Sep 17 00:00:00 2001 From: Jordan Taylor Date: Tue, 31 Oct 2023 11:12:23 +0000 Subject: [PATCH] Make paths os agnostic --- app/controller/controller.py | 10 +++++++--- app/main.py | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controller/controller.py b/app/controller/controller.py index 8ac7666..62fd271 100644 --- a/app/controller/controller.py +++ b/app/controller/controller.py @@ -13,6 +13,7 @@ from views.list import DataListItem from PyQt5.QtWidgets import QListWidgetItem +import os from datetime import datetime from PyQt5.QtGui import QCloseEvent from PyQt5.QtCore import Qt, QCoreApplication, QEventLoop, QTimer @@ -330,7 +331,7 @@ def close(self, event: 'QCloseEvent'): msg_box = QMessageBox(self.view) msg_box.setWindowTitle("Closing Application") msg_box.setText( - "Closing the application...\n\n" \ + "Closing the application...\n\n" "Unsaved changes will be lost!" ) msg_box.setStandardButtons(QMessageBox.NoButton) @@ -361,7 +362,7 @@ def save_as(self): filename, _ = QFileDialog.getSaveFileName( self.view, "Save As", - f"{self.model.saves_path}/", # Default location + self.model.saves_path, # Default location "All Files (*);;Text Files (*.txt)", options=options ) @@ -389,7 +390,10 @@ def save(self): # save with a timestamp self.model.save( - f"{self.model.saves_path}/session-{datetime.now()}.pkl") + os.path.join( + self.model.saves_path, f"session-{datetime.now()}.pkl" + ) + ) def load(self): if self.model.state != Mode.BROWSING: diff --git a/app/main.py b/app/main.py index 3176be0..7c6b9db 100644 --- a/app/main.py +++ b/app/main.py @@ -39,8 +39,9 @@ def main(): date = datetime.today().strftime('%Y-%m-%d') path = os.path.expanduser(config['data']['path']) - db_path = f"{path}/db/{date}" - saves_path = f"{path}/saves/{date}" + + db_path = os.path.join(path, 'db', date) + saves_path = os.path.join(path, 'saves', date) os.makedirs(db_path, exist_ok=True) os.makedirs(saves_path, exist_ok=True)