[Lint] Format code with ruff
`pre-commit run --all-files`
This commit is contained in:
parent
2247668571
commit
0d72195281
|
@ -14,6 +14,7 @@ Example:
|
||||||
>>> from deluge._libtorrent import lt
|
>>> from deluge._libtorrent import lt
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from deluge.common import VersionSplit, get_version
|
from deluge.common import VersionSplit, get_version
|
||||||
from deluge.error import LibtorrentImportError
|
from deluge.error import LibtorrentImportError
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""Common functions for various parts of Deluge to use."""
|
"""Common functions for various parts of Deluge to use."""
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import binascii
|
import binascii
|
||||||
import functools
|
import functools
|
||||||
|
|
|
@ -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.
|
version as this will be done internally.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -14,6 +14,7 @@ This should typically only be used by the Core. Plugins should utilize the
|
||||||
`:mod:EventManager` for similar functionality.
|
`:mod:EventManager` for similar functionality.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""The Deluge daemon"""
|
"""The Deluge daemon"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
|
|
||||||
"""PluginManager for Core"""
|
"""PluginManager for Core"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""RPCServer Module"""
|
"""RPCServer Module"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -46,13 +47,11 @@ TCallable = TypeVar('TCallable', bound=Callable)
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def export(func: TCallable) -> TCallable:
|
def export(func: TCallable) -> TCallable: ...
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def export(auth_level: int) -> Callable[[TCallable], TCallable]:
|
def export(auth_level: int) -> Callable[[TCallable], TCallable]: ...
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
def export(auth_level=AUTH_LEVEL_DEFAULT):
|
def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
|
@ -274,9 +273,9 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||||
raise IncompatibleClient(deluge.common.get_version())
|
raise IncompatibleClient(deluge.common.get_version())
|
||||||
ret = component.get('AuthManager').authorize(*args, **kwargs)
|
ret = component.get('AuthManager').authorize(*args, **kwargs)
|
||||||
if ret:
|
if ret:
|
||||||
self.factory.authorized_sessions[
|
self.factory.authorized_sessions[self.transport.sessionno] = (
|
||||||
self.transport.sessionno
|
self.AuthLevel(ret, args[0])
|
||||||
] = self.AuthLevel(ret, args[0])
|
)
|
||||||
self.factory.session_protocols[self.transport.sessionno] = self
|
self.factory.session_protocols[self.transport.sessionno] = self
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
send_error()
|
send_error()
|
||||||
|
|
|
@ -1138,9 +1138,8 @@ class Torrent:
|
||||||
'download_location': lambda: self.options['download_location'],
|
'download_location': lambda: self.options['download_location'],
|
||||||
'seeds_peers_ratio': lambda: -1.0
|
'seeds_peers_ratio': lambda: -1.0
|
||||||
if self.status.num_incomplete == 0
|
if self.status.num_incomplete == 0
|
||||||
else ( # Use -1.0 to signify infinity
|
# Use -1.0 to signify infinity
|
||||||
self.status.num_complete / self.status.num_incomplete
|
else (self.status.num_complete / self.status.num_incomplete),
|
||||||
),
|
|
||||||
'seed_rank': lambda: self.status.seed_rank,
|
'seed_rank': lambda: self.status.seed_rank,
|
||||||
'state': lambda: self.state,
|
'state': lambda: self.state,
|
||||||
'stop_at_ratio': lambda: self.options['stop_at_ratio'],
|
'stop_at_ratio': lambda: self.options['stop_at_ratio'],
|
||||||
|
@ -1544,20 +1543,18 @@ class Torrent:
|
||||||
self.status.pieces, self.handle.piece_availability()
|
self.status.pieces, self.handle.piece_availability()
|
||||||
):
|
):
|
||||||
if piece:
|
if piece:
|
||||||
pieces.append(3) # Completed.
|
# Completed.
|
||||||
|
pieces.append(3)
|
||||||
elif avail_piece:
|
elif avail_piece:
|
||||||
pieces.append(
|
# Available, just not downloaded nor being downloaded.
|
||||||
1
|
pieces.append(1)
|
||||||
) # Available, just not downloaded nor being downloaded.
|
|
||||||
else:
|
else:
|
||||||
pieces.append(
|
# Missing, no known peer with piece, or not asked for yet.
|
||||||
0
|
pieces.append(0)
|
||||||
) # Missing, no known peer with piece, or not asked for yet.
|
|
||||||
|
|
||||||
for peer_info in self.handle.get_peer_info():
|
for peer_info in self.handle.get_peer_info():
|
||||||
if peer_info.downloading_piece_index >= 0:
|
if peer_info.downloading_piece_index >= 0:
|
||||||
pieces[
|
# Being downloaded from peer.
|
||||||
peer_info.downloading_piece_index
|
pieces[peer_info.downloading_piece_index] = 2
|
||||||
] = 2 # Being downloaded from peer.
|
|
||||||
|
|
||||||
return pieces
|
return pieces
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""TorrentManager handles Torrent objects"""
|
"""TorrentManager handles Torrent objects"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
|
|
|
@ -206,7 +206,7 @@ _RetT = TypeVar('_RetT')
|
||||||
|
|
||||||
|
|
||||||
def maybe_coroutine(
|
def maybe_coroutine(
|
||||||
f: Callable[..., Coroutine[Any, Any, _RetT]]
|
f: Callable[..., Coroutine[Any, Any, _RetT]],
|
||||||
) -> 'Callable[..., defer.Deferred[_RetT]]':
|
) -> 'Callable[..., defer.Deferred[_RetT]]':
|
||||||
"""Wraps a coroutine function to make it usable as a normal function that returns a Deferred."""
|
"""Wraps a coroutine function to make it usable as a normal function that returns a Deferred."""
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ This module describes the types of events that can be generated by the daemon
|
||||||
and subsequently emitted to the clients.
|
and subsequently emitted to the clients.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
known_events = {}
|
known_events = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""Logging functions"""
|
"""Logging functions"""
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
|
|
||||||
"""PluginManagerBase"""
|
"""PluginManagerBase"""
|
||||||
|
|
||||||
import email
|
import email
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
|
|
|
@ -292,7 +292,7 @@ class Core(CorePluginBase):
|
||||||
if 'Label' in component.get('CorePluginManager').get_enabled_plugins():
|
if 'Label' in component.get('CorePluginManager').get_enabled_plugins():
|
||||||
if watchdir.get('label_toggle', True) and watchdir.get('label'):
|
if watchdir.get('label_toggle', True) and watchdir.get('label'):
|
||||||
label = component.get('CorePlugin.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'])
|
label.add(watchdir['label'])
|
||||||
try:
|
try:
|
||||||
label.set_torrent(torrent_id, watchdir['label'])
|
label.set_torrent(torrent_id, watchdir['label'])
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
torrent-label core plugin.
|
torrent-label core plugin.
|
||||||
adds a status field for tracker.
|
adds a status field for tracker.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ class Core(CorePluginBase):
|
||||||
RE_VALID.match(label_id), _('Invalid label, valid characters:[a-z0-9_-]')
|
RE_VALID.match(label_id), _('Invalid label, valid characters:[a-z0-9_-]')
|
||||||
)
|
)
|
||||||
check_input(label_id, _('Empty Label'))
|
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.labels[label_id] = dict(OPTIONS_DEFAULTS)
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
|
@ -192,12 +192,12 @@ class GtkUI(Gtk3PluginBase):
|
||||||
def disable(self):
|
def disable(self):
|
||||||
component.get('Preferences').remove_page(_('Scheduler'))
|
component.get('Preferences').remove_page(_('Scheduler'))
|
||||||
# Reset statusbar dict.
|
# Reset statusbar dict.
|
||||||
self.statusbar.config_value_changed_dict[
|
self.statusbar.config_value_changed_dict['max_download_speed'] = (
|
||||||
'max_download_speed'
|
self.statusbar._on_max_download_speed
|
||||||
] = self.statusbar._on_max_download_speed
|
)
|
||||||
self.statusbar.config_value_changed_dict[
|
self.statusbar.config_value_changed_dict['max_upload_speed'] = (
|
||||||
'max_upload_speed'
|
self.statusbar._on_max_upload_speed
|
||||||
] = self.statusbar._on_max_upload_speed
|
)
|
||||||
# Remove statusbar item.
|
# Remove statusbar item.
|
||||||
self.statusbar.remove_item(self.status_item)
|
self.statusbar.remove_item(self.status_item)
|
||||||
del 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.
|
# Skip error due to Plugin being enabled before statusbar items created on startup.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.statusbar.config_value_changed_dict[
|
self.statusbar.config_value_changed_dict['max_download_speed'] = (
|
||||||
'max_download_speed'
|
self.statusbar._on_max_download_speed
|
||||||
] = self.statusbar._on_max_download_speed
|
)
|
||||||
self.statusbar.config_value_changed_dict[
|
self.statusbar.config_value_changed_dict['max_upload_speed'] = (
|
||||||
'max_upload_speed'
|
self.statusbar._on_max_upload_speed
|
||||||
] = self.statusbar._on_max_upload_speed
|
)
|
||||||
|
|
||||||
def update_config_values(config):
|
def update_config_values(config):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -193,7 +193,9 @@ class GraphsTab(Tab):
|
||||||
self.colors = colors
|
self.colors = colors
|
||||||
# Fake switch page to update the graph colors (HACKY)
|
# Fake switch page to update the graph colors (HACKY)
|
||||||
self._on_notebook_switch_page(
|
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):
|
def _on_intervals_changed(self, intervals):
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"""
|
"""
|
||||||
This base class is used in plugin's __init__ for the plugin entry points.
|
This base class is used in plugin's __init__ for the plugin entry points.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
|
@ -61,8 +61,7 @@ class TestAlertManager:
|
||||||
component.start(['AlertManager'])
|
component.start(['AlertManager'])
|
||||||
|
|
||||||
def test_register_handler(self):
|
def test_register_handler(self):
|
||||||
def handler(alert):
|
def handler(alert): ...
|
||||||
...
|
|
||||||
|
|
||||||
self.am.register_handler('dummy1', handler)
|
self.am.register_handler('dummy1', handler)
|
||||||
self.am.register_handler('dummy2_alert', handler)
|
self.am.register_handler('dummy2_alert', handler)
|
||||||
|
@ -97,8 +96,7 @@ class TestAlertManager:
|
||||||
assert len(self.am.session.alerts) == 2
|
assert len(self.am.session.alerts) == 2
|
||||||
|
|
||||||
def test_deregister_handler(self):
|
def test_deregister_handler(self):
|
||||||
def handler(alert):
|
def handler(alert): ...
|
||||||
...
|
|
||||||
|
|
||||||
self.am.register_handler('dummy1', handler)
|
self.am.register_handler('dummy1', handler)
|
||||||
self.am.register_handler('dummy2_alert', handler)
|
self.am.register_handler('dummy2_alert', handler)
|
||||||
|
|
|
@ -229,7 +229,11 @@ class TestUICommon:
|
||||||
ti = TorrentInfo(filename, filetree=1, force_bt_version=1)
|
ti = TorrentInfo(filename, filetree=1, force_bt_version=1)
|
||||||
assert ti.files_tree == files_tree
|
assert ti.files_tree == files_tree
|
||||||
del files_tree['torrent_test']['.pad']
|
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)
|
ti = TorrentInfo(filename, filetree=1, force_bt_version=2)
|
||||||
assert ti.files_tree == files_tree
|
assert ti.files_tree == files_tree
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"""
|
"""
|
||||||
The ui common module contains methods and classes that are deemed useful for all the interfaces.
|
The ui common module contains methods and classes that are deemed useful for all the interfaces.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from hashlib import sha1 as sha
|
from hashlib import sha1 as sha
|
||||||
|
|
|
@ -109,13 +109,13 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler):
|
||||||
elif ipt.name == 'proxy_port':
|
elif ipt.name == 'proxy_port':
|
||||||
conf_dict.setdefault('proxy', {})['port'] = ipt.get_value()
|
conf_dict.setdefault('proxy', {})['port'] = ipt.get_value()
|
||||||
elif ipt.name == 'proxy_hostnames':
|
elif ipt.name == 'proxy_hostnames':
|
||||||
conf_dict.setdefault('proxy', {})[
|
conf_dict.setdefault('proxy', {})['proxy_hostnames'] = (
|
||||||
'proxy_hostnames'
|
ipt.get_value()
|
||||||
] = ipt.get_value()
|
)
|
||||||
elif ipt.name == 'proxy_peer_connections':
|
elif ipt.name == 'proxy_peer_connections':
|
||||||
conf_dict.setdefault('proxy', {})[
|
conf_dict.setdefault('proxy', {})['proxy_peer_connections'] = (
|
||||||
'proxy_peer_connections'
|
ipt.get_value()
|
||||||
] = ipt.get_value()
|
)
|
||||||
elif ipt.name == 'proxy_tracker_connections':
|
elif ipt.name == 'proxy_tracker_connections':
|
||||||
conf_dict.setdefault('proxy', {})[
|
conf_dict.setdefault('proxy', {})[
|
||||||
'proxy_tracker_connections'
|
'proxy_tracker_connections'
|
||||||
|
@ -123,9 +123,9 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler):
|
||||||
elif ipt.name == 'force_proxy':
|
elif ipt.name == 'force_proxy':
|
||||||
conf_dict.setdefault('proxy', {})['force_proxy'] = ipt.get_value()
|
conf_dict.setdefault('proxy', {})['force_proxy'] = ipt.get_value()
|
||||||
elif ipt.name == 'anonymous_mode':
|
elif ipt.name == 'anonymous_mode':
|
||||||
conf_dict.setdefault('proxy', {})[
|
conf_dict.setdefault('proxy', {})['anonymous_mode'] = (
|
||||||
'anonymous_mode'
|
ipt.get_value()
|
||||||
] = ipt.get_value()
|
)
|
||||||
else:
|
else:
|
||||||
conf_dict[ipt.name] = ipt.get_value()
|
conf_dict[ipt.name] = ipt.get_value()
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ class QueueMode:
|
||||||
self.torrent_ids = torrent_ids
|
self.torrent_ids = torrent_ids
|
||||||
|
|
||||||
def set_statusbar_args(self, statusbar_args):
|
def set_statusbar_args(self, statusbar_args):
|
||||||
statusbar_args[
|
statusbar_args['bottombar'] = (
|
||||||
'bottombar'
|
'{!black,white!}Queue mode: change queue position of selected torrents.'
|
||||||
] = '{!black,white!}Queue mode: change queue position of selected torrents.'
|
)
|
||||||
statusbar_args['bottombar_help'] = ' Press [h] for help'
|
statusbar_args['bottombar_help'] = ' Press [h] for help'
|
||||||
|
|
||||||
def update_cursor(self):
|
def update_cursor(self):
|
||||||
|
|
|
@ -219,11 +219,11 @@ class TorrentList(BaseMode, PopupsHandler):
|
||||||
# Update the status bars
|
# Update the status bars
|
||||||
statusbar_args = {'scr': self.stdscr, 'bottombar_help': True}
|
statusbar_args = {'scr': self.stdscr, 'bottombar_help': True}
|
||||||
if self.torrentview.curr_filter is not None:
|
if self.torrentview.curr_filter is not None:
|
||||||
statusbar_args[
|
statusbar_args['topbar'] = (
|
||||||
'topbar'
|
'{} {{!filterstatus!}}Current filter: {}'.format(
|
||||||
] = '{} {{!filterstatus!}}Current filter: {}'.format(
|
self.statusbars.topbar,
|
||||||
self.statusbars.topbar,
|
self.torrentview.curr_filter,
|
||||||
self.torrentview.curr_filter,
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.minor_mode:
|
if self.minor_mode:
|
||||||
|
|
|
@ -49,7 +49,7 @@ class BaseInputPane(InputKeyHandler):
|
||||||
border_off_east=0,
|
border_off_east=0,
|
||||||
border_off_south=0,
|
border_off_south=0,
|
||||||
active_wrap=False,
|
active_wrap=False,
|
||||||
**kwargs
|
**kwargs,
|
||||||
):
|
):
|
||||||
InputKeyHandler.__init__(self)
|
InputKeyHandler.__init__(self)
|
||||||
self.inputs = []
|
self.inputs = []
|
||||||
|
@ -155,7 +155,7 @@ class BaseInputPane(InputKeyHandler):
|
||||||
self.visible_content_pane_width,
|
self.visible_content_pane_width,
|
||||||
value,
|
value,
|
||||||
col=col,
|
col=col,
|
||||||
**kwargs
|
**kwargs,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Popup(BaseWindow, InputKeyHandler):
|
||||||
close_cb=None,
|
close_cb=None,
|
||||||
encoding=None,
|
encoding=None,
|
||||||
base_popup=None,
|
base_popup=None,
|
||||||
**kwargs
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Init a new popup. The default constructor will handle sizing and borders and the like.
|
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,
|
input_cb=None,
|
||||||
allow_rearrange=False,
|
allow_rearrange=False,
|
||||||
immediate_action=False,
|
immediate_action=False,
|
||||||
**kwargs
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
|
@ -262,7 +262,7 @@ class SelectablePopup(BaseInputPane, Popup):
|
||||||
foreground=None,
|
foreground=None,
|
||||||
selectable=True,
|
selectable=True,
|
||||||
selected=False,
|
selected=False,
|
||||||
**kwargs
|
**kwargs,
|
||||||
):
|
):
|
||||||
hotkey = None
|
hotkey = None
|
||||||
self.cb_arg[name] = cb_arg
|
self.cb_arg[name] = cb_arg
|
||||||
|
@ -335,7 +335,7 @@ class MessagePopup(Popup, BaseInputPane):
|
||||||
align=ALIGN.DEFAULT,
|
align=ALIGN.DEFAULT,
|
||||||
height_req=0.75,
|
height_req=0.75,
|
||||||
width_req=0.5,
|
width_req=0.5,
|
||||||
**kwargs
|
**kwargs,
|
||||||
):
|
):
|
||||||
self.message = message
|
self.message = message
|
||||||
Popup.__init__(
|
Popup.__init__(
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
"""Common functions for various parts of gtkui to use."""
|
"""Common functions for various parts of gtkui to use."""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -322,20 +322,20 @@ class StoredValuesList(ValueList):
|
||||||
self.paths_without_trailing_path_sep = False
|
self.paths_without_trailing_path_sep = False
|
||||||
|
|
||||||
# Add signal handlers
|
# Add signal handlers
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_stored_values_treeview_mouse_button_press_event'] = (
|
||||||
'on_stored_values_treeview_mouse_button_press_event'
|
self.on_treeview_mouse_button_press_event
|
||||||
] = self.on_treeview_mouse_button_press_event
|
)
|
||||||
|
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_stored_values_treeview_key_press_event'] = (
|
||||||
'on_stored_values_treeview_key_press_event'
|
self.on_stored_values_treeview_key_press_event
|
||||||
] = self.on_stored_values_treeview_key_press_event
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_stored_values_treeview_key_release_event'] = (
|
||||||
'on_stored_values_treeview_key_release_event'
|
self.on_stored_values_treeview_key_release_event
|
||||||
] = self.on_stored_values_treeview_key_release_event
|
)
|
||||||
|
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_cellrenderertext_edited'] = (
|
||||||
'on_cellrenderertext_edited'
|
self.on_cellrenderertext_edited
|
||||||
] = self.on_cellrenderertext_edited
|
)
|
||||||
|
|
||||||
def on_cellrenderertext_edited(self, cellrenderertext, path, new_text):
|
def on_cellrenderertext_edited(self, cellrenderertext, path, new_text):
|
||||||
"""
|
"""
|
||||||
|
@ -447,9 +447,7 @@ class StoredValuesList(ValueList):
|
||||||
return True
|
return True
|
||||||
# Add current value to saved list
|
# Add current value to saved list
|
||||||
elif is_ascii_value(keyval, 's'):
|
elif is_ascii_value(keyval, 's'):
|
||||||
super(
|
super(PathChooserComboBox, self).add_current_value_to_saved_list() # pylint: disable=bad-super-call
|
||||||
PathChooserComboBox, self
|
|
||||||
).add_current_value_to_saved_list() # pylint: disable=bad-super-call
|
|
||||||
return True
|
return True
|
||||||
# Edit selected value
|
# Edit selected value
|
||||||
elif is_ascii_value(keyval, 'e'):
|
elif is_ascii_value(keyval, 'e'):
|
||||||
|
@ -465,17 +463,17 @@ class CompletionList(ValueList):
|
||||||
self.completion_scrolled_window = self.builder.get_object(
|
self.completion_scrolled_window = self.builder.get_object(
|
||||||
'completion_scrolled_window'
|
'completion_scrolled_window'
|
||||||
)
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_treeview_key_press_event'] = (
|
||||||
'on_completion_treeview_key_press_event'
|
self.on_completion_treeview_key_press_event
|
||||||
] = self.on_completion_treeview_key_press_event
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_treeview_motion_notify_event'] = (
|
||||||
'on_completion_treeview_motion_notify_event'
|
self.on_completion_treeview_motion_notify_event
|
||||||
] = self.on_completion_treeview_motion_notify_event
|
)
|
||||||
|
|
||||||
# Add super class signal handler
|
# Add super class signal handler
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_treeview_mouse_button_press_event'] = (
|
||||||
'on_completion_treeview_mouse_button_press_event'
|
super().on_treeview_mouse_button_press_event
|
||||||
] = super().on_treeview_mouse_button_press_event
|
)
|
||||||
|
|
||||||
def reduce_values(self, prefix):
|
def reduce_values(self, prefix):
|
||||||
"""
|
"""
|
||||||
|
@ -756,23 +754,23 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup):
|
||||||
self.popup_buttonbox = self.builder.get_object('buttonbox')
|
self.popup_buttonbox = self.builder.get_object('buttonbox')
|
||||||
|
|
||||||
# Add signal handlers
|
# Add signal handlers
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_buttonbox_key_press_event'] = (
|
||||||
'on_buttonbox_key_press_event'
|
self.on_buttonbox_key_press_event
|
||||||
] = self.on_buttonbox_key_press_event
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_stored_values_treeview_scroll_event'] = (
|
||||||
'on_stored_values_treeview_scroll_event'
|
self.on_scroll_event
|
||||||
] = self.on_scroll_event
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_button_toggle_dropdown_scroll_event'] = (
|
||||||
'on_button_toggle_dropdown_scroll_event'
|
self.on_scroll_event
|
||||||
] = self.on_scroll_event
|
)
|
||||||
self.signal_handlers['on_entry_text_scroll_event'] = self.on_scroll_event
|
self.signal_handlers['on_entry_text_scroll_event'] = self.on_scroll_event
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_stored_values_popup_window_focus_out_event'] = (
|
||||||
'on_stored_values_popup_window_focus_out_event'
|
self.on_stored_values_popup_window_focus_out_event
|
||||||
] = self.on_stored_values_popup_window_focus_out_event
|
)
|
||||||
# For when clicking outside the popup
|
# For when clicking outside the popup
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_stored_values_popup_window_button_press_event'] = (
|
||||||
'on_stored_values_popup_window_button_press_event'
|
self.on_popup_window_button_press_event
|
||||||
] = self.on_popup_window_button_press_event
|
)
|
||||||
|
|
||||||
# Buttons for manipulating the list
|
# Buttons for manipulating the list
|
||||||
self.signal_handlers['on_button_add_clicked'] = self.on_button_add_clicked
|
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_remove_clicked'] = self.on_button_remove_clicked
|
||||||
self.signal_handlers['on_button_up_clicked'] = self.on_button_up_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_down_clicked'] = self.on_button_down_clicked
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_button_default_clicked'] = (
|
||||||
'on_button_default_clicked'
|
self.on_button_default_clicked
|
||||||
] = self.on_button_default_clicked
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_button_properties_clicked'] = (
|
||||||
'on_button_properties_clicked'
|
self.path_entry._on_button_properties_clicked
|
||||||
] = self.path_entry._on_button_properties_clicked
|
)
|
||||||
|
|
||||||
def popup(self):
|
def popup(self):
|
||||||
"""
|
"""
|
||||||
|
@ -911,17 +909,17 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
|
||||||
CompletionList.__init__(self)
|
CompletionList.__init__(self)
|
||||||
|
|
||||||
# Add signal handlers
|
# Add signal handlers
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_treeview_scroll_event'] = (
|
||||||
'on_completion_treeview_scroll_event'
|
self.on_scroll_event
|
||||||
] = self.on_scroll_event
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_popup_window_focus_out_event'] = (
|
||||||
'on_completion_popup_window_focus_out_event'
|
self.on_completion_popup_window_focus_out_event
|
||||||
] = self.on_completion_popup_window_focus_out_event
|
)
|
||||||
|
|
||||||
# For when clicking outside the popup
|
# For when clicking outside the popup
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_popup_window_button_press_event'] = (
|
||||||
'on_completion_popup_window_button_press_event'
|
self.on_popup_window_button_press_event
|
||||||
] = self.on_popup_window_button_press_event
|
)
|
||||||
|
|
||||||
def popup(self):
|
def popup(self):
|
||||||
"""
|
"""
|
||||||
|
@ -986,15 +984,15 @@ class PathAutoCompleter:
|
||||||
self.auto_complete_enabled = True
|
self.auto_complete_enabled = True
|
||||||
self.signal_handlers = self.completion_popup.signal_handlers
|
self.signal_handlers = self.completion_popup.signal_handlers
|
||||||
|
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_completion_popup_window_key_press_event'] = (
|
||||||
'on_completion_popup_window_key_press_event'
|
self.on_completion_popup_window_key_press_event
|
||||||
] = self.on_completion_popup_window_key_press_event
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_entry_text_delete_text'] = (
|
||||||
'on_entry_text_delete_text'
|
self.on_entry_text_delete_text
|
||||||
] = self.on_entry_text_delete_text
|
)
|
||||||
self.signal_handlers[
|
self.signal_handlers['on_entry_text_insert_text'] = (
|
||||||
'on_entry_text_insert_text'
|
self.on_entry_text_insert_text
|
||||||
] = self.on_entry_text_insert_text
|
)
|
||||||
self.accelerator_string = Gtk.accelerator_name(Gdk.KEY_Tab, 0)
|
self.accelerator_string = Gtk.accelerator_name(Gdk.KEY_Tab, 0)
|
||||||
|
|
||||||
def on_entry_text_insert_text(self, entry, new_text, new_text_length, position):
|
def on_entry_text_insert_text(self, entry, new_text, new_text_length, position):
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
|
|
||||||
"""The torrent details component shows info about the selected torrent."""
|
"""The torrent details component shows info about the selected torrent."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""The torrent view component that lists all torrents in the session."""
|
"""The torrent view component that lists all torrents in the session."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from locale import strcoll
|
from locale import strcoll
|
||||||
|
|
||||||
|
@ -577,7 +578,7 @@ class TorrentView(ListView, component.Component):
|
||||||
status_keys = self.set_columns_to_update(columns)
|
status_keys = self.set_columns_to_update(columns)
|
||||||
|
|
||||||
# If there is nothing in status_keys then we must not continue
|
# If there is nothing in status_keys then we must not continue
|
||||||
if status_keys is []:
|
if status_keys == []:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Remove duplicates from status_key list
|
# Remove duplicates from status_key list
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# user runs the command 'deluge'.
|
# user runs the command 'deluge'.
|
||||||
|
|
||||||
"""Main starting point for Deluge"""
|
"""Main starting point for Deluge"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -60,7 +60,7 @@ def check_missing_markup(js_dir):
|
||||||
# Ignore string that contains only digits or specificied strings in skip.
|
# Ignore string that contains only digits or specificied strings in skip.
|
||||||
if (
|
if (
|
||||||
not string
|
not string
|
||||||
or string.split('\'')[1].isdigit()
|
or string.split("'")[1].isdigit()
|
||||||
or any(x in string for x in skip)
|
or any(x in string for x in skip)
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
@ -82,7 +82,7 @@ GETTEXT_SUBST_TPL = "GetText.add('{key}','${{escape(_(\"{key}\"))}}')\n"
|
||||||
|
|
||||||
|
|
||||||
def create_gettext_js(js_dir):
|
def create_gettext_js(js_dir):
|
||||||
string_re = re.compile('_\\(\'(.*?)\'\\)')
|
string_re = re.compile("_\\('(.*?)'\\)")
|
||||||
strings = {}
|
strings = {}
|
||||||
for root, dnames, files in os.walk(js_dir):
|
for root, dnames, files in os.walk(js_dir):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
|
|
|
@ -24,6 +24,7 @@ Options:
|
||||||
--version
|
--version
|
||||||
Display version information and exit.
|
Display version information and exit.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import array
|
import array
|
||||||
import ast
|
import ast
|
||||||
import getopt
|
import getopt
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -323,7 +323,7 @@ class CleanPlugins(Command):
|
||||||
self.set_undefined_options('clean', ('all', 'all'))
|
self.set_undefined_options('clean', ('all', 'all'))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print('Cleaning the plugin\'s folders...')
|
print("Cleaning the plugin's folders...")
|
||||||
|
|
||||||
plugin_path = 'deluge/plugins/*'
|
plugin_path = 'deluge/plugins/*'
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ class CleanPlugins(Command):
|
||||||
c = 'cd ' + path + ' && ' + sys.executable + ' setup.py clean'
|
c = 'cd ' + path + ' && ' + sys.executable + ' setup.py clean'
|
||||||
if self.all:
|
if self.all:
|
||||||
c += ' -a'
|
c += ' -a'
|
||||||
print('Calling \'%s\'' % c)
|
print("Calling '%s'" % c)
|
||||||
os.system(c)
|
os.system(c)
|
||||||
|
|
||||||
# Delete the .eggs
|
# Delete the .eggs
|
||||||
|
|
Loading…
Reference in New Issue