diff --git a/deluge/_libtorrent.py b/deluge/_libtorrent.py index 642855c52..182a5a057 100644 --- a/deluge/_libtorrent.py +++ b/deluge/_libtorrent.py @@ -14,6 +14,7 @@ Example: >>> from deluge._libtorrent import lt """ + from deluge.common import VersionSplit, get_version from deluge.error import LibtorrentImportError diff --git a/deluge/common.py b/deluge/common.py index 256f1f783..7b76d245c 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -7,6 +7,7 @@ # """Common functions for various parts of Deluge to use.""" + import base64 import binascii import functools diff --git a/deluge/config.py b/deluge/config.py index c5cb3122b..f32038ed1 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -38,6 +38,7 @@ this can only be done for the 'config file version' and not for the 'format' version as this will be done internally. """ + import json import logging import os diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py index cf541f015..24f47fddd 100644 --- a/deluge/core/alertmanager.py +++ b/deluge/core/alertmanager.py @@ -14,6 +14,7 @@ This should typically only be used by the Core. Plugins should utilize the `:mod:EventManager` for similar functionality. """ + import contextlib import logging import threading diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py index 0185dd8cb..01d1c7505 100644 --- a/deluge/core/daemon.py +++ b/deluge/core/daemon.py @@ -7,6 +7,7 @@ # """The Deluge daemon""" + import logging import os import socket diff --git a/deluge/core/pluginmanager.py b/deluge/core/pluginmanager.py index 0482b16e7..63c33c78b 100644 --- a/deluge/core/pluginmanager.py +++ b/deluge/core/pluginmanager.py @@ -8,6 +8,7 @@ """PluginManager for Core""" + import logging from twisted.internet import defer diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 81ab2e0a5..d84ac3a47 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -7,6 +7,7 @@ # """RPCServer Module""" + import logging import os import sys @@ -46,13 +47,11 @@ TCallable = TypeVar('TCallable', bound=Callable) @overload -def export(func: TCallable) -> TCallable: - ... +def export(func: TCallable) -> TCallable: ... @overload -def export(auth_level: int) -> Callable[[TCallable], TCallable]: - ... +def export(auth_level: int) -> Callable[[TCallable], TCallable]: ... def export(auth_level=AUTH_LEVEL_DEFAULT): @@ -274,9 +273,9 @@ class DelugeRPCProtocol(DelugeTransferProtocol): raise IncompatibleClient(deluge.common.get_version()) ret = component.get('AuthManager').authorize(*args, **kwargs) if ret: - self.factory.authorized_sessions[ - self.transport.sessionno - ] = self.AuthLevel(ret, args[0]) + self.factory.authorized_sessions[self.transport.sessionno] = ( + self.AuthLevel(ret, args[0]) + ) self.factory.session_protocols[self.transport.sessionno] = self except Exception as ex: send_error() diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 57ec26f37..dbcf8f101 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -1138,9 +1138,8 @@ class Torrent: 'download_location': lambda: self.options['download_location'], 'seeds_peers_ratio': lambda: -1.0 if self.status.num_incomplete == 0 - else ( # Use -1.0 to signify infinity - self.status.num_complete / self.status.num_incomplete - ), + # Use -1.0 to signify infinity + else (self.status.num_complete / self.status.num_incomplete), 'seed_rank': lambda: self.status.seed_rank, 'state': lambda: self.state, 'stop_at_ratio': lambda: self.options['stop_at_ratio'], @@ -1544,20 +1543,18 @@ class Torrent: self.status.pieces, self.handle.piece_availability() ): if piece: - pieces.append(3) # Completed. + # Completed. + pieces.append(3) elif avail_piece: - pieces.append( - 1 - ) # Available, just not downloaded nor being downloaded. + # Available, just not downloaded nor being downloaded. + pieces.append(1) else: - pieces.append( - 0 - ) # Missing, no known peer with piece, or not asked for yet. + # Missing, no known peer with piece, or not asked for yet. + pieces.append(0) for peer_info in self.handle.get_peer_info(): if peer_info.downloading_piece_index >= 0: - pieces[ - peer_info.downloading_piece_index - ] = 2 # Being downloaded from peer. + # Being downloaded from peer. + pieces[peer_info.downloading_piece_index] = 2 return pieces diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index c43a7a262..1233553a8 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -7,6 +7,7 @@ # """TorrentManager handles Torrent objects""" + import datetime import logging import operator diff --git a/deluge/decorators.py b/deluge/decorators.py index 92e3ecf59..7b1896c13 100644 --- a/deluge/decorators.py +++ b/deluge/decorators.py @@ -206,7 +206,7 @@ _RetT = TypeVar('_RetT') def maybe_coroutine( - f: Callable[..., Coroutine[Any, Any, _RetT]] + f: Callable[..., Coroutine[Any, Any, _RetT]], ) -> 'Callable[..., defer.Deferred[_RetT]]': """Wraps a coroutine function to make it usable as a normal function that returns a Deferred.""" diff --git a/deluge/event.py b/deluge/event.py index 38fc32ff8..c51fca4de 100644 --- a/deluge/event.py +++ b/deluge/event.py @@ -13,6 +13,7 @@ This module describes the types of events that can be generated by the daemon and subsequently emitted to the clients. """ + known_events = {} diff --git a/deluge/log.py b/deluge/log.py index ef31f4ddc..fc1b33077 100644 --- a/deluge/log.py +++ b/deluge/log.py @@ -8,6 +8,7 @@ # """Logging functions""" + import inspect import logging import logging.handlers diff --git a/deluge/pluginmanagerbase.py b/deluge/pluginmanagerbase.py index 835dbb268..52dae615b 100644 --- a/deluge/pluginmanagerbase.py +++ b/deluge/pluginmanagerbase.py @@ -8,6 +8,7 @@ """PluginManagerBase""" + import email import logging import os.path diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py index 271d5f0d9..4b1a27fa5 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/core.py @@ -292,7 +292,7 @@ class Core(CorePluginBase): if 'Label' in component.get('CorePluginManager').get_enabled_plugins(): if watchdir.get('label_toggle', True) and watchdir.get('label'): label = component.get('CorePlugin.Label') - if not watchdir['label'] in label.get_labels(): + if watchdir['label'] not in label.get_labels(): label.add(watchdir['label']) try: label.set_torrent(torrent_id, watchdir['label']) diff --git a/deluge/plugins/Label/deluge_label/core.py b/deluge/plugins/Label/deluge_label/core.py index c28490b46..8af980593 100644 --- a/deluge/plugins/Label/deluge_label/core.py +++ b/deluge/plugins/Label/deluge_label/core.py @@ -14,6 +14,7 @@ torrent-label core plugin. adds a status field for tracker. """ + import logging import re @@ -182,7 +183,7 @@ class Core(CorePluginBase): RE_VALID.match(label_id), _('Invalid label, valid characters:[a-z0-9_-]') ) check_input(label_id, _('Empty Label')) - check_input(not (label_id in self.labels), _('Label already exists')) + check_input(label_id not in self.labels, _('Label already exists')) self.labels[label_id] = dict(OPTIONS_DEFAULTS) self.config.save() diff --git a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py index 16222c835..a5a92739a 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py @@ -192,12 +192,12 @@ class GtkUI(Gtk3PluginBase): def disable(self): component.get('Preferences').remove_page(_('Scheduler')) # Reset statusbar dict. - self.statusbar.config_value_changed_dict[ - 'max_download_speed' - ] = self.statusbar._on_max_download_speed - self.statusbar.config_value_changed_dict[ - 'max_upload_speed' - ] = self.statusbar._on_max_upload_speed + self.statusbar.config_value_changed_dict['max_download_speed'] = ( + self.statusbar._on_max_download_speed + ) + self.statusbar.config_value_changed_dict['max_upload_speed'] = ( + self.statusbar._on_max_upload_speed + ) # Remove statusbar item. self.statusbar.remove_item(self.status_item) del self.status_item @@ -246,12 +246,12 @@ class GtkUI(Gtk3PluginBase): # Skip error due to Plugin being enabled before statusbar items created on startup. pass else: - self.statusbar.config_value_changed_dict[ - 'max_download_speed' - ] = self.statusbar._on_max_download_speed - self.statusbar.config_value_changed_dict[ - 'max_upload_speed' - ] = self.statusbar._on_max_upload_speed + self.statusbar.config_value_changed_dict['max_download_speed'] = ( + self.statusbar._on_max_download_speed + ) + self.statusbar.config_value_changed_dict['max_upload_speed'] = ( + self.statusbar._on_max_upload_speed + ) def update_config_values(config): try: diff --git a/deluge/plugins/Stats/deluge_stats/gtkui.py b/deluge/plugins/Stats/deluge_stats/gtkui.py index 39c1d4c37..09a8f1158 100644 --- a/deluge/plugins/Stats/deluge_stats/gtkui.py +++ b/deluge/plugins/Stats/deluge_stats/gtkui.py @@ -193,7 +193,9 @@ class GraphsTab(Tab): self.colors = colors # Fake switch page to update the graph colors (HACKY) self._on_notebook_switch_page( - self.notebook, None, self.notebook.get_current_page() # This is unused + self.notebook, + None, + self.notebook.get_current_page(), # This is unused ) def _on_intervals_changed(self, intervals): diff --git a/deluge/plugins/init.py b/deluge/plugins/init.py index 56b31977d..cab1036ab 100644 --- a/deluge/plugins/init.py +++ b/deluge/plugins/init.py @@ -9,6 +9,7 @@ """ This base class is used in plugin's __init__ for the plugin entry points. """ + import logging log = logging.getLogger(__name__) diff --git a/deluge/tests/test_alertmanager.py b/deluge/tests/test_alertmanager.py index bfab1b345..bb84610a5 100644 --- a/deluge/tests/test_alertmanager.py +++ b/deluge/tests/test_alertmanager.py @@ -61,8 +61,7 @@ class TestAlertManager: component.start(['AlertManager']) def test_register_handler(self): - def handler(alert): - ... + def handler(alert): ... self.am.register_handler('dummy1', handler) self.am.register_handler('dummy2_alert', handler) @@ -97,8 +96,7 @@ class TestAlertManager: assert len(self.am.session.alerts) == 2 def test_deregister_handler(self): - def handler(alert): - ... + def handler(alert): ... self.am.register_handler('dummy1', handler) self.am.register_handler('dummy2_alert', handler) diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py index 87a4a2c04..5412713bb 100644 --- a/deluge/tests/test_ui_common.py +++ b/deluge/tests/test_ui_common.py @@ -229,7 +229,11 @@ class TestUICommon: ti = TorrentInfo(filename, filetree=1, force_bt_version=1) assert ti.files_tree == files_tree del files_tree['torrent_test']['.pad'] - files_tree['torrent_test']['還在一個人無聊嗎~還不趕緊上來聊天美.txt'] = (1, 32, True) + files_tree['torrent_test']['還在一個人無聊嗎~還不趕緊上來聊天美.txt'] = ( + 1, + 32, + True, + ) ti = TorrentInfo(filename, filetree=1, force_bt_version=2) assert ti.files_tree == files_tree diff --git a/deluge/ui/common.py b/deluge/ui/common.py index 64d5ca216..b3f8bc713 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -10,6 +10,7 @@ """ The ui common module contains methods and classes that are deemed useful for all the interfaces. """ + import logging import os from hashlib import sha1 as sha diff --git a/deluge/ui/console/modes/preferences/preference_panes.py b/deluge/ui/console/modes/preferences/preference_panes.py index 61e86ae0b..8ae0deaca 100644 --- a/deluge/ui/console/modes/preferences/preference_panes.py +++ b/deluge/ui/console/modes/preferences/preference_panes.py @@ -109,13 +109,13 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler): elif ipt.name == 'proxy_port': conf_dict.setdefault('proxy', {})['port'] = ipt.get_value() elif ipt.name == 'proxy_hostnames': - conf_dict.setdefault('proxy', {})[ - 'proxy_hostnames' - ] = ipt.get_value() + conf_dict.setdefault('proxy', {})['proxy_hostnames'] = ( + ipt.get_value() + ) elif ipt.name == 'proxy_peer_connections': - conf_dict.setdefault('proxy', {})[ - 'proxy_peer_connections' - ] = ipt.get_value() + conf_dict.setdefault('proxy', {})['proxy_peer_connections'] = ( + ipt.get_value() + ) elif ipt.name == 'proxy_tracker_connections': conf_dict.setdefault('proxy', {})[ 'proxy_tracker_connections' @@ -123,9 +123,9 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler): elif ipt.name == 'force_proxy': conf_dict.setdefault('proxy', {})['force_proxy'] = ipt.get_value() elif ipt.name == 'anonymous_mode': - conf_dict.setdefault('proxy', {})[ - 'anonymous_mode' - ] = ipt.get_value() + conf_dict.setdefault('proxy', {})['anonymous_mode'] = ( + ipt.get_value() + ) else: conf_dict[ipt.name] = ipt.get_value() diff --git a/deluge/ui/console/modes/torrentlist/queue_mode.py b/deluge/ui/console/modes/torrentlist/queue_mode.py index 33af0135d..4ec86133a 100644 --- a/deluge/ui/console/modes/torrentlist/queue_mode.py +++ b/deluge/ui/console/modes/torrentlist/queue_mode.py @@ -42,9 +42,9 @@ class QueueMode: self.torrent_ids = torrent_ids def set_statusbar_args(self, statusbar_args): - statusbar_args[ - 'bottombar' - ] = '{!black,white!}Queue mode: change queue position of selected torrents.' + statusbar_args['bottombar'] = ( + '{!black,white!}Queue mode: change queue position of selected torrents.' + ) statusbar_args['bottombar_help'] = ' Press [h] for help' def update_cursor(self): diff --git a/deluge/ui/console/modes/torrentlist/torrentlist.py b/deluge/ui/console/modes/torrentlist/torrentlist.py index d3c32ec0e..9a55e1965 100644 --- a/deluge/ui/console/modes/torrentlist/torrentlist.py +++ b/deluge/ui/console/modes/torrentlist/torrentlist.py @@ -219,11 +219,11 @@ class TorrentList(BaseMode, PopupsHandler): # Update the status bars statusbar_args = {'scr': self.stdscr, 'bottombar_help': True} if self.torrentview.curr_filter is not None: - statusbar_args[ - 'topbar' - ] = '{} {{!filterstatus!}}Current filter: {}'.format( - self.statusbars.topbar, - self.torrentview.curr_filter, + statusbar_args['topbar'] = ( + '{} {{!filterstatus!}}Current filter: {}'.format( + self.statusbars.topbar, + self.torrentview.curr_filter, + ) ) if self.minor_mode: diff --git a/deluge/ui/console/widgets/inputpane.py b/deluge/ui/console/widgets/inputpane.py index d8d217501..f9c4f6f6d 100644 --- a/deluge/ui/console/widgets/inputpane.py +++ b/deluge/ui/console/widgets/inputpane.py @@ -49,7 +49,7 @@ class BaseInputPane(InputKeyHandler): border_off_east=0, border_off_south=0, active_wrap=False, - **kwargs + **kwargs, ): InputKeyHandler.__init__(self) self.inputs = [] @@ -155,7 +155,7 @@ class BaseInputPane(InputKeyHandler): self.visible_content_pane_width, value, col=col, - **kwargs + **kwargs, ) ) diff --git a/deluge/ui/console/widgets/popup.py b/deluge/ui/console/widgets/popup.py index 07d667d27..c17ca8a86 100644 --- a/deluge/ui/console/widgets/popup.py +++ b/deluge/ui/console/widgets/popup.py @@ -69,7 +69,7 @@ class Popup(BaseWindow, InputKeyHandler): close_cb=None, encoding=None, base_popup=None, - **kwargs + **kwargs, ): """ Init a new popup. The default constructor will handle sizing and borders and the like. @@ -212,7 +212,7 @@ class SelectablePopup(BaseInputPane, Popup): input_cb=None, allow_rearrange=False, immediate_action=False, - **kwargs + **kwargs, ): """ Args: @@ -262,7 +262,7 @@ class SelectablePopup(BaseInputPane, Popup): foreground=None, selectable=True, selected=False, - **kwargs + **kwargs, ): hotkey = None self.cb_arg[name] = cb_arg @@ -335,7 +335,7 @@ class MessagePopup(Popup, BaseInputPane): align=ALIGN.DEFAULT, height_req=0.75, width_req=0.5, - **kwargs + **kwargs, ): self.message = message Popup.__init__( diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py index 42a14b407..a588db66e 100644 --- a/deluge/ui/gtk3/common.py +++ b/deluge/ui/gtk3/common.py @@ -6,6 +6,7 @@ # See LICENSE for more details. # """Common functions for various parts of gtkui to use.""" + import contextlib import logging import os diff --git a/deluge/ui/gtk3/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py index aeb4c7a9e..6ef8fafc3 100755 --- a/deluge/ui/gtk3/path_combo_chooser.py +++ b/deluge/ui/gtk3/path_combo_chooser.py @@ -322,20 +322,20 @@ class StoredValuesList(ValueList): self.paths_without_trailing_path_sep = False # Add signal handlers - self.signal_handlers[ - 'on_stored_values_treeview_mouse_button_press_event' - ] = self.on_treeview_mouse_button_press_event + self.signal_handlers['on_stored_values_treeview_mouse_button_press_event'] = ( + self.on_treeview_mouse_button_press_event + ) - self.signal_handlers[ - 'on_stored_values_treeview_key_press_event' - ] = self.on_stored_values_treeview_key_press_event - self.signal_handlers[ - 'on_stored_values_treeview_key_release_event' - ] = self.on_stored_values_treeview_key_release_event + self.signal_handlers['on_stored_values_treeview_key_press_event'] = ( + self.on_stored_values_treeview_key_press_event + ) + self.signal_handlers['on_stored_values_treeview_key_release_event'] = ( + self.on_stored_values_treeview_key_release_event + ) - self.signal_handlers[ - 'on_cellrenderertext_edited' - ] = self.on_cellrenderertext_edited + self.signal_handlers['on_cellrenderertext_edited'] = ( + self.on_cellrenderertext_edited + ) def on_cellrenderertext_edited(self, cellrenderertext, path, new_text): """ @@ -447,9 +447,7 @@ class StoredValuesList(ValueList): return True # Add current value to saved list elif is_ascii_value(keyval, 's'): - super( - PathChooserComboBox, self - ).add_current_value_to_saved_list() # pylint: disable=bad-super-call + super(PathChooserComboBox, self).add_current_value_to_saved_list() # pylint: disable=bad-super-call return True # Edit selected value elif is_ascii_value(keyval, 'e'): @@ -465,17 +463,17 @@ class CompletionList(ValueList): self.completion_scrolled_window = self.builder.get_object( 'completion_scrolled_window' ) - self.signal_handlers[ - 'on_completion_treeview_key_press_event' - ] = self.on_completion_treeview_key_press_event - self.signal_handlers[ - 'on_completion_treeview_motion_notify_event' - ] = self.on_completion_treeview_motion_notify_event + self.signal_handlers['on_completion_treeview_key_press_event'] = ( + self.on_completion_treeview_key_press_event + ) + self.signal_handlers['on_completion_treeview_motion_notify_event'] = ( + self.on_completion_treeview_motion_notify_event + ) # Add super class signal handler - self.signal_handlers[ - 'on_completion_treeview_mouse_button_press_event' - ] = super().on_treeview_mouse_button_press_event + self.signal_handlers['on_completion_treeview_mouse_button_press_event'] = ( + super().on_treeview_mouse_button_press_event + ) def reduce_values(self, prefix): """ @@ -756,23 +754,23 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup): self.popup_buttonbox = self.builder.get_object('buttonbox') # Add signal handlers - self.signal_handlers[ - 'on_buttonbox_key_press_event' - ] = self.on_buttonbox_key_press_event - self.signal_handlers[ - 'on_stored_values_treeview_scroll_event' - ] = self.on_scroll_event - self.signal_handlers[ - 'on_button_toggle_dropdown_scroll_event' - ] = self.on_scroll_event + self.signal_handlers['on_buttonbox_key_press_event'] = ( + self.on_buttonbox_key_press_event + ) + self.signal_handlers['on_stored_values_treeview_scroll_event'] = ( + self.on_scroll_event + ) + self.signal_handlers['on_button_toggle_dropdown_scroll_event'] = ( + self.on_scroll_event + ) self.signal_handlers['on_entry_text_scroll_event'] = self.on_scroll_event - self.signal_handlers[ - 'on_stored_values_popup_window_focus_out_event' - ] = self.on_stored_values_popup_window_focus_out_event + self.signal_handlers['on_stored_values_popup_window_focus_out_event'] = ( + self.on_stored_values_popup_window_focus_out_event + ) # For when clicking outside the popup - self.signal_handlers[ - 'on_stored_values_popup_window_button_press_event' - ] = self.on_popup_window_button_press_event + self.signal_handlers['on_stored_values_popup_window_button_press_event'] = ( + self.on_popup_window_button_press_event + ) # Buttons for manipulating the list self.signal_handlers['on_button_add_clicked'] = self.on_button_add_clicked @@ -780,12 +778,12 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup): self.signal_handlers['on_button_remove_clicked'] = self.on_button_remove_clicked self.signal_handlers['on_button_up_clicked'] = self.on_button_up_clicked self.signal_handlers['on_button_down_clicked'] = self.on_button_down_clicked - self.signal_handlers[ - 'on_button_default_clicked' - ] = self.on_button_default_clicked - self.signal_handlers[ - 'on_button_properties_clicked' - ] = self.path_entry._on_button_properties_clicked + self.signal_handlers['on_button_default_clicked'] = ( + self.on_button_default_clicked + ) + self.signal_handlers['on_button_properties_clicked'] = ( + self.path_entry._on_button_properties_clicked + ) def popup(self): """ @@ -911,17 +909,17 @@ class PathCompletionPopup(CompletionList, PathChooserPopup): CompletionList.__init__(self) # Add signal handlers - self.signal_handlers[ - 'on_completion_treeview_scroll_event' - ] = self.on_scroll_event - self.signal_handlers[ - 'on_completion_popup_window_focus_out_event' - ] = self.on_completion_popup_window_focus_out_event + self.signal_handlers['on_completion_treeview_scroll_event'] = ( + self.on_scroll_event + ) + self.signal_handlers['on_completion_popup_window_focus_out_event'] = ( + self.on_completion_popup_window_focus_out_event + ) # For when clicking outside the popup - self.signal_handlers[ - 'on_completion_popup_window_button_press_event' - ] = self.on_popup_window_button_press_event + self.signal_handlers['on_completion_popup_window_button_press_event'] = ( + self.on_popup_window_button_press_event + ) def popup(self): """ @@ -986,15 +984,15 @@ class PathAutoCompleter: self.auto_complete_enabled = True self.signal_handlers = self.completion_popup.signal_handlers - self.signal_handlers[ - 'on_completion_popup_window_key_press_event' - ] = self.on_completion_popup_window_key_press_event - self.signal_handlers[ - 'on_entry_text_delete_text' - ] = self.on_entry_text_delete_text - self.signal_handlers[ - 'on_entry_text_insert_text' - ] = self.on_entry_text_insert_text + self.signal_handlers['on_completion_popup_window_key_press_event'] = ( + self.on_completion_popup_window_key_press_event + ) + self.signal_handlers['on_entry_text_delete_text'] = ( + self.on_entry_text_delete_text + ) + self.signal_handlers['on_entry_text_insert_text'] = ( + self.on_entry_text_insert_text + ) self.accelerator_string = Gtk.accelerator_name(Gdk.KEY_Tab, 0) def on_entry_text_insert_text(self, entry, new_text, new_text_length, position): diff --git a/deluge/ui/gtk3/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py index 08c37a1de..982a3d85e 100644 --- a/deluge/ui/gtk3/torrentdetails.py +++ b/deluge/ui/gtk3/torrentdetails.py @@ -8,6 +8,7 @@ """The torrent details component shows info about the selected torrent.""" + import logging from collections import namedtuple diff --git a/deluge/ui/gtk3/torrentview.py b/deluge/ui/gtk3/torrentview.py index 16de16ea7..27771d574 100644 --- a/deluge/ui/gtk3/torrentview.py +++ b/deluge/ui/gtk3/torrentview.py @@ -7,6 +7,7 @@ # """The torrent view component that lists all torrents in the session.""" + import logging from locale import strcoll @@ -577,7 +578,7 @@ class TorrentView(ListView, component.Component): status_keys = self.set_columns_to_update(columns) # If there is nothing in status_keys then we must not continue - if status_keys is []: + if status_keys == []: return # Remove duplicates from status_key list diff --git a/deluge/ui/ui_entry.py b/deluge/ui/ui_entry.py index e185fda33..f0a983106 100644 --- a/deluge/ui/ui_entry.py +++ b/deluge/ui/ui_entry.py @@ -11,6 +11,7 @@ # user runs the command 'deluge'. """Main starting point for Deluge""" + import argparse import logging import os diff --git a/gen_web_gettext.py b/gen_web_gettext.py index 80186e938..37ffba71c 100755 --- a/gen_web_gettext.py +++ b/gen_web_gettext.py @@ -60,7 +60,7 @@ def check_missing_markup(js_dir): # Ignore string that contains only digits or specificied strings in skip. if ( not string - or string.split('\'')[1].isdigit() + or string.split("'")[1].isdigit() or any(x in string for x in skip) ): continue @@ -82,7 +82,7 @@ GETTEXT_SUBST_TPL = "GetText.add('{key}','${{escape(_(\"{key}\"))}}')\n" def create_gettext_js(js_dir): - string_re = re.compile('_\\(\'(.*?)\'\\)') + string_re = re.compile("_\\('(.*?)'\\)") strings = {} for root, dnames, files in os.walk(js_dir): for filename in files: diff --git a/msgfmt.py b/msgfmt.py index 0d5367c3b..e5d62d002 100755 --- a/msgfmt.py +++ b/msgfmt.py @@ -24,6 +24,7 @@ Options: --version Display version information and exit. """ + import array import ast import getopt diff --git a/setup.py b/setup.py index ef70f20b0..6161d60d0 100755 --- a/setup.py +++ b/setup.py @@ -323,7 +323,7 @@ class CleanPlugins(Command): self.set_undefined_options('clean', ('all', 'all')) def run(self): - print('Cleaning the plugin\'s folders...') + print("Cleaning the plugin's folders...") plugin_path = 'deluge/plugins/*' @@ -332,7 +332,7 @@ class CleanPlugins(Command): c = 'cd ' + path + ' && ' + sys.executable + ' setup.py clean' if self.all: c += ' -a' - print('Calling \'%s\'' % c) + print("Calling '%s'" % c) os.system(c) # Delete the .eggs