From 33fdc40f66981894022236e9d7c92eff2136a9ee Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 9 Dec 2023 14:05:29 +0000 Subject: [PATCH] Clean up AudacityManager --- app/helpers.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/helpers.py b/app/helpers.py index 038343a..78bfe86 100644 --- a/app/helpers.py +++ b/app/helpers.py @@ -37,20 +37,19 @@ class AudacityManager: self.to_pipe: str = "/tmp/audacity_script_pipe.to." + str(os.getuid()) self.from_pipe: str = "/tmp/audacity_script_pipe.from." + str(os.getuid()) self.eol: str = "\n" - self.path = None + self.path = "" - def open_file(self, path): + def open_file(self, path: str) -> str: """Open passed file in Audacity""" self.path = path - response = self._do_command(f'Import2: Filename="{self.path}"') - return response + return self._do_command(f'Import2: Filename="{self.path}"') - def export_file(self): + def export_file(self) -> str: """Export current file""" if not self.path: - return + return "Error: no path selected" sa_response = self._do_command("SelectAll:") if sa_response == "\nBatchCommand finished: OK\n": @@ -59,7 +58,7 @@ class AudacityManager: ) return exp_response else: - print("SelectAll response: " + sa_response) + return "SelectAll response: " + sa_response def _send_command(self, command: str) -> None: """Send a single command.""" @@ -91,7 +90,7 @@ class AudacityManager: def ask_yes_no( - title: str, question: str, default_yes: bool = False, parent: QMainWindow = None + title: str, question: str, default_yes: bool = False, parent: Optional[QMainWindow] = None ) -> bool: """Ask question; return True for yes, False for no"""