Clean up AudacityManager

This commit is contained in:
Keith Edmunds 2023-12-09 14:05:29 +00:00
parent 0082f76b56
commit 33fdc40f66

View File

@ -37,20 +37,19 @@ class AudacityManager:
self.to_pipe: str = "/tmp/audacity_script_pipe.to." + str(os.getuid()) 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.from_pipe: str = "/tmp/audacity_script_pipe.from." + str(os.getuid())
self.eol: str = "\n" 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""" """Open passed file in Audacity"""
self.path = path self.path = path
response = self._do_command(f'Import2: Filename="{self.path}"') return self._do_command(f'Import2: Filename="{self.path}"')
return response
def export_file(self): def export_file(self) -> str:
"""Export current file""" """Export current file"""
if not self.path: if not self.path:
return return "Error: no path selected"
sa_response = self._do_command("SelectAll:") sa_response = self._do_command("SelectAll:")
if sa_response == "\nBatchCommand finished: OK\n": if sa_response == "\nBatchCommand finished: OK\n":
@ -59,7 +58,7 @@ class AudacityManager:
) )
return exp_response return exp_response
else: else:
print("SelectAll response: " + sa_response) return "SelectAll response: " + sa_response
def _send_command(self, command: str) -> None: def _send_command(self, command: str) -> None:
"""Send a single command.""" """Send a single command."""
@ -91,7 +90,7 @@ class AudacityManager:
def ask_yes_no( 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: ) -> bool:
"""Ask question; return True for yes, False for no""" """Ask question; return True for yes, False for no"""