From 30d267de249378d88b32f232f1929a73d2eeb5ea Mon Sep 17 00:00:00 2001 From: Raymond Li Date: Sun, 20 Aug 2023 00:45:11 +0200 Subject: [PATCH] Formatting --- src/nexus/Freqlog/Freqlog.py | 9 +++++---- src/nexus/GUI.py | 12 ++++++------ src/nexus/__main__.py | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/nexus/Freqlog/Freqlog.py b/src/nexus/Freqlog/Freqlog.py index 4b356ad..3055d4c 100644 --- a/src/nexus/Freqlog/Freqlog.py +++ b/src/nexus/Freqlog/Freqlog.py @@ -148,10 +148,11 @@ def _log_and_reset_word(min_length: int = 1) -> None: def __init__(self, db_path: str = Defaults.DEFAULT_DB_PATH, loggable: bool = True): self.backend: Backend = SQLiteBackend(db_path) self.q: Queue = Queue() - self.listener: kbd.Listener | None = kbd.Listener(on_press=self._on_press, on_release=self._on_release, - name="Keyboard Listener") if loggable else None - self.mouse_listener: mouse.Listener | None = mouse.Listener(on_click=self._on_click, - name="Mouse Listener") if loggable else None + self.listener: kbd.Listener | None = None + self.mouse_listener: mouse.Listener | None = None + if loggable: + self.listener = kbd.Listener(on_press=self._on_press, on_release=self._on_release, name="Keyboard Listener") + self.mouse_listener = mouse.Listener(on_click=self._on_click, name="Mouse Listener") self.new_word_threshold: float = Defaults.DEFAULT_NEW_WORD_THRESHOLD self.chord_char_threshold: int = Defaults.DEFAULT_CHORD_CHAR_THRESHOLD self.allowed_keys_in_chord: set = Defaults.DEFAULT_ALLOWED_KEYS_IN_CHORD diff --git a/src/nexus/GUI.py b/src/nexus/GUI.py index 1ea81ed..c03a119 100644 --- a/src/nexus/GUI.py +++ b/src/nexus/GUI.py @@ -67,7 +67,7 @@ def __init__(self, args: argparse.Namespace): # Translation self.translator = Translator(self.app) - if self.translator.load(QLocale.system(), 'i18n', '_', str(Path(__file__).resolve().parent)+'/translations'): + if self.translator.load(QLocale.system(), 'i18n', '_', str(Path(__file__).resolve().parent) + '/translations'): self.app.installTranslator(self.translator) self.tr = self.translator.translate @@ -104,7 +104,7 @@ def start_stop(self): """Controller for start/stop logging button""" if not self.start_stop_button_started: # Update button to starting - # TODO: fix signal blocking (not currently working) + # TODO: fix signal blocking (to prevent spam-clicking the button restarting logging, not currently working) self.start_stop_button.blockSignals(True) self.start_stop_button.setEnabled(False) self.start_stop_button.setText(self.tr("GUI", "Starting...")) @@ -238,10 +238,10 @@ def remove_banword(): else CaseSensitivity.INSENSITIVE) conf_dialog = ConfirmDialog() if len(selected_words) > 1: - confirmText = self.tr("GUI", "Unban {} words") + confirm_text = self.tr("GUI", "Unban {} words") else: - confirmText = self.tr("GUI", "Unban one word") - conf_dialog.confirmText.setText(confirmText.format(len(selected_words))) + confirm_text = self.tr("GUI", "Unban one word") + conf_dialog.confirmText.setText(confirm_text.format(len(selected_words))) conf_dialog.buttonBox.accepted.connect(lambda: self.temp_freqlog.unban_words(selected_words)) conf_dialog.exec() refresh_banlist() @@ -258,7 +258,7 @@ def export(self): filename += ".csv" num_exported = self.temp_freqlog.export_words_to_csv(filename) self.statusbar.showMessage( - self.tr("GUI", "Exported {} words to {}".format(num_exported, filename))) + self.tr("GUI", "Exported {} words to {}".format(num_exported, filename))) def exec(self): """Start the GUI""" diff --git a/src/nexus/__main__.py b/src/nexus/__main__.py index a2b1b92..3268b94 100644 --- a/src/nexus/__main__.py +++ b/src/nexus/__main__.py @@ -177,7 +177,7 @@ def main(): match args.command: case "startlog": # start freqlogging freqlog = Freqlog.Freqlog(args.freq_log_path, loggable=True) - signal.signal(signal.SIGINT, lambda *_: freqlog.stop_logging()) + signal.signal(signal.SIGINT, lambda: freqlog.stop_logging()) freqlog.start_logging(args.new_word_threshold, args.chord_char_threshold, args.allowed_keys_in_chord, Defaults.DEFAULT_MODIFIER_KEYS - set(args.remove_modifier_key) | set( args.add_modifier_key))