diff --git a/dangerzone/container.py b/dangerzone/container.py index aac9efa..5482cdf 100644 --- a/dangerzone/container.py +++ b/dangerzone/container.py @@ -32,7 +32,9 @@ def exec_container(args, stdout_callback: Callable[[str], None]) -> int: return p.returncode -def convert(input_filename, output_filename, ocr_lang, stdout_callback: Callable[[str], None]): +def convert( + input_filename, output_filename, ocr_lang, stdout_callback: Callable[[str], None] +): success = False if ocr_lang: @@ -117,6 +119,7 @@ def convert(input_filename, output_filename, ocr_lang, stdout_callback: Callable return success + # From global_common: # def validate_convert_to_pixel_output(self, common, output): diff --git a/dangerzone/gui/__init__.py b/dangerzone/gui/__init__.py index f491a7e..608b064 100644 --- a/dangerzone/gui/__init__.py +++ b/dangerzone/gui/__init__.py @@ -47,7 +47,7 @@ def gui_main(filename): # Initialize colorama colorama.init(autoreset=True) - + # Common objects gui_common = GuiCommon(app) diff --git a/dangerzone/gui/gui_common.py b/dangerzone/gui/gui_common.py index baa07d0..7cbff8b 100644 --- a/dangerzone/gui/gui_common.py +++ b/dangerzone/gui/gui_common.py @@ -45,9 +45,7 @@ class GuiCommon(object): elif platform.system() == "Linux": # Get the PDF reader command - args = shlex.split( - self.pdf_viewers[self.settings.get("open_app")] - ) + args = shlex.split(self.pdf_viewers[self.settings.get("open_app")]) # %f, %F, %u, and %U are filenames or URLS -- so replace with the file to open for i in range(len(args)): if ( diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index 0715086..06ac7c6 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -33,9 +33,7 @@ class MainWindow(QtWidgets.QMainWindow): # Header logo = QtWidgets.QLabel() logo.setPixmap( - QtGui.QPixmap.fromImage( - QtGui.QImage(dzutil.get_resource_path("icon.png")) - ) + QtGui.QPixmap.fromImage(QtGui.QImage(dzutil.get_resource_path("icon.png"))) ) header_label = QtWidgets.QLabel("dangerzone") header_label.setFont(self.gui_common.fixed_font) @@ -52,9 +50,7 @@ class MainWindow(QtWidgets.QMainWindow): self.waiting_widget.finished.connect(self.waiting_finished) # Content widget, contains all the window content except waiting widget - self.content_widget = ContentWidget( - self.gui_common, self.common - ) + self.content_widget = ContentWidget(self.gui_common, self.common) self.content_widget.close_window.connect(self.close) # Only use the waiting widget if container runtime isn't available @@ -211,9 +207,7 @@ class ContentWidget(QtWidgets.QWidget): self.doc_selection_widget.document_selected.connect(self.document_selected) # Settings - self.settings_widget = SettingsWidget( - self.gui_common, self.common - ) + self.settings_widget = SettingsWidget(self.gui_common, self.common) self.doc_selection_widget.document_selected.connect( self.settings_widget.document_selected ) @@ -222,9 +216,7 @@ class ContentWidget(QtWidgets.QWidget): self.settings_widget.hide() # Convert - self.convert_widget = ConvertWidget( - self.gui_common, self.common - ) + self.convert_widget = ConvertWidget(self.gui_common, self.common) self.convert_widget.close_window.connect(self._close_window) self.doc_selection_widget.document_selected.connect( self.convert_widget.document_selected @@ -399,9 +391,7 @@ class SettingsWidget(QtWidgets.QWidget): else: self.ocr_checkbox.setCheckState(QtCore.Qt.Unchecked) - index = self.ocr_combobox.findText( - self.gui_common.settings.get("ocr_language") - ) + index = self.ocr_combobox.findText(self.gui_common.settings.get("ocr_language")) if index != -1: self.ocr_combobox.setCurrentIndex(index) @@ -551,9 +541,7 @@ class ConvertWidget(QtWidgets.QWidget): # Label self.error_image = QtWidgets.QLabel() self.error_image.setPixmap( - QtGui.QPixmap.fromImage( - QtGui.QImage(dzutil.get_resource_path("error.png")) - ) + QtGui.QPixmap.fromImage(QtGui.QImage(dzutil.get_resource_path("error.png"))) ) self.error_image.hide() diff --git a/dangerzone/gui/systray.py b/dangerzone/gui/systray.py index ba7915e..52d3c1d 100644 --- a/dangerzone/gui/systray.py +++ b/dangerzone/gui/systray.py @@ -6,9 +6,7 @@ import dangerzone.util as dzutil class SysTray(QtWidgets.QSystemTrayIcon): - def __init__( - self, gui_common: GuiCommon, app: Application - ): + def __init__(self, gui_common: GuiCommon, app: Application): super(SysTray, self).__init__() self.gui_common = gui_common self.app = app diff --git a/dangerzone/util.py b/dangerzone/util.py index 24586db..8cb7f67 100644 --- a/dangerzone/util.py +++ b/dangerzone/util.py @@ -40,9 +40,13 @@ def get_resource_path(filename: str | os.PathLike[str]) -> str: # Look for ./share relative to python file prefix = _dev_root_path().joinpath("share") # e.g., /home/user/dangerzone/share elif SYSTEM == "Darwin": - bin_path = pathlib.Path(sys.executable) # /path/to/Dangerzone.app/Contents/MacOS/dangerzone[-cli] + bin_path = pathlib.Path( + sys.executable + ) # /path/to/Dangerzone.app/Contents/MacOS/dangerzone[-cli] app_path = bin_path.parent.parent # /path/to/Dangerzone.app/Contents - prefix = app_path.joinpath("Resources", "share") # /path/to/Dangerzone.app/Contents/Resources/share + prefix = app_path.joinpath( + "Resources", "share" + ) # /path/to/Dangerzone.app/Contents/Resources/share elif SYSTEM == "Linux": prefix = pathlib.Path(sys.prefix).joinpath("share", "dangerzone") elif SYSTEM == "Windows": @@ -243,7 +247,7 @@ OCR_LANGUAGES = { "Vietnamese": "vie", "Welsh": "cym", "Yiddish": "yid", - "Yoruba": "yor" + "Yoruba": "yor", }