mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-05-04 12:41:50 +02:00
Run black dangerzone
to fix up style
This commit is contained in:
parent
ba516476de
commit
8eefbefa1a
6 changed files with 20 additions and 29 deletions
|
@ -32,7 +32,9 @@ def exec_container(args, stdout_callback: Callable[[str], None]) -> int:
|
||||||
return p.returncode
|
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
|
success = False
|
||||||
|
|
||||||
if ocr_lang:
|
if ocr_lang:
|
||||||
|
@ -117,6 +119,7 @@ def convert(input_filename, output_filename, ocr_lang, stdout_callback: Callable
|
||||||
|
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
|
||||||
# From global_common:
|
# From global_common:
|
||||||
|
|
||||||
# def validate_convert_to_pixel_output(self, common, output):
|
# def validate_convert_to_pixel_output(self, common, output):
|
||||||
|
|
|
@ -47,7 +47,7 @@ def gui_main(filename):
|
||||||
|
|
||||||
# Initialize colorama
|
# Initialize colorama
|
||||||
colorama.init(autoreset=True)
|
colorama.init(autoreset=True)
|
||||||
|
|
||||||
# Common objects
|
# Common objects
|
||||||
gui_common = GuiCommon(app)
|
gui_common = GuiCommon(app)
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,7 @@ class GuiCommon(object):
|
||||||
|
|
||||||
elif platform.system() == "Linux":
|
elif platform.system() == "Linux":
|
||||||
# Get the PDF reader command
|
# Get the PDF reader command
|
||||||
args = shlex.split(
|
args = shlex.split(self.pdf_viewers[self.settings.get("open_app")])
|
||||||
self.pdf_viewers[self.settings.get("open_app")]
|
|
||||||
)
|
|
||||||
# %f, %F, %u, and %U are filenames or URLS -- so replace with the file to open
|
# %f, %F, %u, and %U are filenames or URLS -- so replace with the file to open
|
||||||
for i in range(len(args)):
|
for i in range(len(args)):
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -33,9 +33,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
# Header
|
# Header
|
||||||
logo = QtWidgets.QLabel()
|
logo = QtWidgets.QLabel()
|
||||||
logo.setPixmap(
|
logo.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(
|
QtGui.QPixmap.fromImage(QtGui.QImage(dzutil.get_resource_path("icon.png")))
|
||||||
QtGui.QImage(dzutil.get_resource_path("icon.png"))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
header_label = QtWidgets.QLabel("dangerzone")
|
header_label = QtWidgets.QLabel("dangerzone")
|
||||||
header_label.setFont(self.gui_common.fixed_font)
|
header_label.setFont(self.gui_common.fixed_font)
|
||||||
|
@ -52,9 +50,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.waiting_widget.finished.connect(self.waiting_finished)
|
self.waiting_widget.finished.connect(self.waiting_finished)
|
||||||
|
|
||||||
# Content widget, contains all the window content except waiting widget
|
# Content widget, contains all the window content except waiting widget
|
||||||
self.content_widget = ContentWidget(
|
self.content_widget = ContentWidget(self.gui_common, self.common)
|
||||||
self.gui_common, self.common
|
|
||||||
)
|
|
||||||
self.content_widget.close_window.connect(self.close)
|
self.content_widget.close_window.connect(self.close)
|
||||||
|
|
||||||
# Only use the waiting widget if container runtime isn't available
|
# 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)
|
self.doc_selection_widget.document_selected.connect(self.document_selected)
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
self.settings_widget = SettingsWidget(
|
self.settings_widget = SettingsWidget(self.gui_common, self.common)
|
||||||
self.gui_common, self.common
|
|
||||||
)
|
|
||||||
self.doc_selection_widget.document_selected.connect(
|
self.doc_selection_widget.document_selected.connect(
|
||||||
self.settings_widget.document_selected
|
self.settings_widget.document_selected
|
||||||
)
|
)
|
||||||
|
@ -222,9 +216,7 @@ class ContentWidget(QtWidgets.QWidget):
|
||||||
self.settings_widget.hide()
|
self.settings_widget.hide()
|
||||||
|
|
||||||
# Convert
|
# Convert
|
||||||
self.convert_widget = ConvertWidget(
|
self.convert_widget = ConvertWidget(self.gui_common, self.common)
|
||||||
self.gui_common, self.common
|
|
||||||
)
|
|
||||||
self.convert_widget.close_window.connect(self._close_window)
|
self.convert_widget.close_window.connect(self._close_window)
|
||||||
self.doc_selection_widget.document_selected.connect(
|
self.doc_selection_widget.document_selected.connect(
|
||||||
self.convert_widget.document_selected
|
self.convert_widget.document_selected
|
||||||
|
@ -399,9 +391,7 @@ class SettingsWidget(QtWidgets.QWidget):
|
||||||
else:
|
else:
|
||||||
self.ocr_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.ocr_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
|
|
||||||
index = self.ocr_combobox.findText(
|
index = self.ocr_combobox.findText(self.gui_common.settings.get("ocr_language"))
|
||||||
self.gui_common.settings.get("ocr_language")
|
|
||||||
)
|
|
||||||
if index != -1:
|
if index != -1:
|
||||||
self.ocr_combobox.setCurrentIndex(index)
|
self.ocr_combobox.setCurrentIndex(index)
|
||||||
|
|
||||||
|
@ -551,9 +541,7 @@ class ConvertWidget(QtWidgets.QWidget):
|
||||||
# Label
|
# Label
|
||||||
self.error_image = QtWidgets.QLabel()
|
self.error_image = QtWidgets.QLabel()
|
||||||
self.error_image.setPixmap(
|
self.error_image.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(
|
QtGui.QPixmap.fromImage(QtGui.QImage(dzutil.get_resource_path("error.png")))
|
||||||
QtGui.QImage(dzutil.get_resource_path("error.png"))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self.error_image.hide()
|
self.error_image.hide()
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@ import dangerzone.util as dzutil
|
||||||
|
|
||||||
|
|
||||||
class SysTray(QtWidgets.QSystemTrayIcon):
|
class SysTray(QtWidgets.QSystemTrayIcon):
|
||||||
def __init__(
|
def __init__(self, gui_common: GuiCommon, app: Application):
|
||||||
self, gui_common: GuiCommon, app: Application
|
|
||||||
):
|
|
||||||
super(SysTray, self).__init__()
|
super(SysTray, self).__init__()
|
||||||
self.gui_common = gui_common
|
self.gui_common = gui_common
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
|
@ -40,9 +40,13 @@ def get_resource_path(filename: str | os.PathLike[str]) -> str:
|
||||||
# Look for ./share relative to python file
|
# Look for ./share relative to python file
|
||||||
prefix = _dev_root_path().joinpath("share") # e.g., /home/user/dangerzone/share
|
prefix = _dev_root_path().joinpath("share") # e.g., /home/user/dangerzone/share
|
||||||
elif SYSTEM == "Darwin":
|
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
|
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":
|
elif SYSTEM == "Linux":
|
||||||
prefix = pathlib.Path(sys.prefix).joinpath("share", "dangerzone")
|
prefix = pathlib.Path(sys.prefix).joinpath("share", "dangerzone")
|
||||||
elif SYSTEM == "Windows":
|
elif SYSTEM == "Windows":
|
||||||
|
@ -243,7 +247,7 @@ OCR_LANGUAGES = {
|
||||||
"Vietnamese": "vie",
|
"Vietnamese": "vie",
|
||||||
"Welsh": "cym",
|
"Welsh": "cym",
|
||||||
"Yiddish": "yid",
|
"Yiddish": "yid",
|
||||||
"Yoruba": "yor"
|
"Yoruba": "yor",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue