diff options
Diffstat (limited to 'deluge/plugins')
85 files changed, 144 insertions, 415 deletions
diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py b/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py index a409cfcce..5f5e76616 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -22,7 +19,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class Gtk3UIPlugin(PluginInitBase): @@ -30,7 +27,7 @@ class Gtk3UIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(Gtk3UIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -38,4 +35,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/common.py b/deluge/plugins/AutoAdd/deluge_autoadd/common.py index 9b4b1e703..6a790cbd5 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/common.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py index 9a2260610..07ad53a8e 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com> # Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me> @@ -13,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import shutil @@ -30,7 +27,7 @@ import deluge.configmanager from deluge._libtorrent import lt from deluge.common import AUTH_LEVEL_ADMIN, is_magnet from deluge.core.rpcserver import export -from deluge.error import AddTorrentError +from deluge.error import AddTorrentError, InvalidTorrentError from deluge.event import DelugeEvent from deluge.plugins.pluginbase import CorePluginBase @@ -152,7 +149,7 @@ class Core(CorePluginBase): try: with open(filename, file_mode) as _file: filedump = _file.read() - except IOError as ex: + except OSError as ex: log.warning('Unable to open %s: %s', filename, ex) raise ex @@ -161,7 +158,10 @@ class Core(CorePluginBase): # Get the info to see if any exceptions are raised if not magnet: - lt.torrent_info(lt.bdecode(filedump)) + decoded_torrent = lt.bdecode(filedump) + if decoded_torrent is None: + raise InvalidTorrentError('Torrent file failed decoding.') + lt.torrent_info(decoded_torrent) return filedump @@ -169,9 +169,9 @@ class Core(CorePluginBase): log.debug('Attempting to open %s for splitting magnets.', filename) magnets = [] try: - with open(filename, 'r') as _file: + with open(filename) as _file: magnets = list(filter(len, _file.read().splitlines())) - except IOError as ex: + except OSError as ex: log.warning('Unable to open %s: %s', filename, ex) if len(magnets) < 2: @@ -196,7 +196,7 @@ class Core(CorePluginBase): try: with open(mname, 'w') as _mfile: _mfile.write(magnet) - except IOError as ex: + except OSError as ex: log.warning('Unable to open %s: %s', mname, ex) return magnets @@ -271,7 +271,7 @@ class Core(CorePluginBase): try: filedump = self.load_torrent(filepath, magnet) - except (IOError, EOFError) as ex: + except (OSError, EOFError, InvalidTorrentError) as ex: # If torrent is invalid, keep track of it so can try again on the next pass. # This catches torrent files that may not be fully saved to disk at load time. log.debug('Torrent is invalid: %s', ex) diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js index ebed40180..e68fce307 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js @@ -42,22 +42,21 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { dataIndex: 'enabled', tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { getCheckbox: function (checked, selected) { - Deluge.ux.AutoAdd.onClickFunctions[ - selected.id - ] = function () { - if (selected.enabled) { - deluge.client.autoadd.disable_watchdir( - selected.id - ); - checked = false; - } else { - deluge.client.autoadd.enable_watchdir( - selected.id - ); - checked = true; - } - autoAdd.updateWatchDirs(); - }; + Deluge.ux.AutoAdd.onClickFunctions[selected.id] = + function () { + if (selected.enabled) { + deluge.client.autoadd.disable_watchdir( + selected.id + ); + checked = false; + } else { + deluge.client.autoadd.enable_watchdir( + selected.id + ); + checked = true; + } + autoAdd.updateWatchDirs(); + }; return ( '<input id="enabled-' + selected.id + diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js index 797d76585..7ec4448b9 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js @@ -90,9 +90,8 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { options['enabled'] = Ext.getCmp('enabled').getValue(); options['path'] = Ext.getCmp('path').getValue(); - options['download_location'] = Ext.getCmp( - 'download_location' - ).getValue(); + options['download_location'] = + Ext.getCmp('download_location').getValue(); options['move_completed_path'] = Ext.getCmp( 'move_completed_path' ).getValue(); diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.ui b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.ui index a4cd364e9..f1870f183 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.ui +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.ui @@ -150,8 +150,6 @@ <property name="tooltip_text" translatable="yes">If a .torrent file is added to this directory, it will be added to the session.</property> <property name="invisible_char">●</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> @@ -284,8 +282,6 @@ and it will remain in the same directory.</property> <property name="can_focus">True</property> <property name="invisible_char">•</property> <property name="text" translatable="yes">.added</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> @@ -329,8 +325,6 @@ and deleted from the watch folder.</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">•</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> @@ -445,8 +439,6 @@ also delete the .torrent file used to add it.</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> @@ -534,8 +526,6 @@ also delete the .torrent file used to add it.</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> @@ -799,8 +789,6 @@ also delete the .torrent file used to add it.</property> <object class="GtkSpinButton" id="max_download_speed"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment1</property> <property name="climb_rate">1</property> <property name="digits">1</property> @@ -815,8 +803,6 @@ also delete the .torrent file used to add it.</property> <object class="GtkSpinButton" id="max_upload_speed"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment2</property> <property name="climb_rate">1</property> <property name="digits">1</property> @@ -833,8 +819,6 @@ also delete the .torrent file used to add it.</property> <object class="GtkSpinButton" id="max_connections"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment3</property> <property name="climb_rate">1</property> </object> @@ -850,8 +834,6 @@ also delete the .torrent file used to add it.</property> <object class="GtkSpinButton" id="max_upload_slots"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment4</property> <property name="climb_rate">1</property> </object> @@ -1063,8 +1045,6 @@ also delete the .torrent file used to add it.</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment5</property> <property name="climb_rate">1</property> <property name="digits">1</property> diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py b/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py index 35531419b..80fb9fcde 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com> # @@ -12,14 +11,12 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import gi # isort:skip (Required before Gtk import). -gi.require_version('Gtk', '3.0') # NOQA: E402 +gi.require_version('Gtk', '3.0') # isort:imports-thirdparty from gi.repository import Gtk @@ -41,7 +38,7 @@ class IncompatibleOption(Exception): pass -class OptionsDialog(object): +class OptionsDialog: spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio'] spin_int_ids = ['max_upload_slots', 'max_connections'] chk_ids = [ @@ -327,7 +324,7 @@ class OptionsDialog(object): dialogs.ErrorDialog(_('Incompatible Option'), str(ex), self.dialog).run() def on_error_show(self, result): - d = dialogs.ErrorDialog(_('Error'), result.value.exception_msg, self.dialog) + d = dialogs.ErrorDialog(_('Error'), result.value.message, self.dialog) result.cleanFailure() d.run() diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/webui.py b/deluge/plugins/AutoAdd/deluge_autoadd/webui.py index 7f36ba659..d328432fe 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/webui.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/AutoAdd/setup.py b/deluge/plugins/AutoAdd/setup.py index fcd018395..5a01ee9aa 100644 --- a/deluge/plugins/AutoAdd/setup.py +++ b/deluge/plugins/AutoAdd/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com> # Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me> diff --git a/deluge/plugins/Blocklist/deluge_blocklist/__init__.py b/deluge/plugins/Blocklist/deluge_blocklist/__init__.py index 96ccc02ae..40ce1d18f 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/__init__.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -17,7 +14,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -25,7 +22,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -33,4 +30,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Blocklist/deluge_blocklist/common.py b/deluge/plugins/Blocklist/deluge_blocklist/common.py index a9299cd2e..35b2f87c5 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/common.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,13 +11,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from functools import wraps from sys import exc_info -import six from pkg_resources import resource_filename @@ -47,7 +43,7 @@ def raises_errors_as(error): return func(self, *args, **kwargs) except Exception: (value, tb) = exc_info()[1:] - six.reraise(error, value, tb) + raise error(value).with_traceback(tb) from None return wrapper @@ -74,7 +70,7 @@ class BadIP(Exception): _message = None def __init__(self, message): - super(BadIP, self).__init__(message) + super().__init__(message) def __set_message(self, message): self._message = message @@ -86,7 +82,7 @@ class BadIP(Exception): del __get_message, __set_message -class IP(object): +class IP: __slots__ = ('q1', 'q2', 'q3', 'q4', '_long') def __init__(self, q1, q2, q3, q4): @@ -109,7 +105,7 @@ class IP(object): @classmethod def parse(cls, ip): try: - q1, q2, q3, q4 = [int(q) for q in ip.split('.')] + q1, q2, q3, q4 = (int(q) for q in ip.split('.')) except ValueError: raise BadIP(_('The IP address "%s" is badly formed' % ip)) if q1 < 0 or q2 < 0 or q3 < 0 or q4 < 0: @@ -169,7 +165,7 @@ class IP(object): return self.long == other.long def __repr__(self): - return '<%s long=%s address="%s">' % ( + return '<{} long={} address="{}">'.format( self.__class__.__name__, self.long, self.address, diff --git a/deluge/plugins/Blocklist/deluge_blocklist/core.py b/deluge/plugins/Blocklist/deluge_blocklist/core.py index a096b8ac9..176576740 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/core.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com> # Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com> @@ -8,14 +7,13 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import os import shutil import time from datetime import datetime, timedelta from email.utils import formatdate +from urllib.parse import urljoin from twisted.internet import defer, threads from twisted.internet.task import LoopingCall @@ -32,12 +30,6 @@ from .common import IP, BadIP from .detect import UnknownFormatError, create_reader, detect_compression, detect_format from .readers import ReaderParseError -try: - from urllib.parse import urljoin -except ImportError: - # PY2 fallback - from urlparse import urljoin # pylint: disable=ungrouped-imports - # TODO: check return values for deferred callbacks # TODO: review class attributes for redundancy diff --git a/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js b/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js index 8f1b93c21..3c10b81bc 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js +++ b/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js @@ -55,7 +55,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { }); this.checkListDays = this.SettingsFset.add({ - fieldLabel: _('Check for new list every:'), + fieldLabel: _('Check for new list every (days):'), labelSeparator: '', name: 'check_list_days', value: 4, diff --git a/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist_pref.ui b/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist_pref.ui index 013d8e70e..8c1f7a7ab 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist_pref.ui +++ b/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist_pref.ui @@ -53,8 +53,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> @@ -124,8 +122,6 @@ <object class="GtkSpinButton" id="spin_check_days"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment1</property> </object> <packing> @@ -139,7 +135,7 @@ <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">Check for new list every:</property> + <property name="label" translatable="yes">Check for new list every (days):</property> <property name="xalign">0</property> </object> <packing> diff --git a/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py index 35211b706..cd2ee8cad 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com> # @@ -8,8 +7,6 @@ # # pylint: disable=redefined-builtin -from __future__ import unicode_literals - import bz2 import gzip import zipfile diff --git a/deluge/plugins/Blocklist/deluge_blocklist/detect.py b/deluge/plugins/Blocklist/deluge_blocklist/detect.py index 262d5de4f..43ad305f2 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/detect.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/detect.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from .decompressers import BZipped2, GZipped, Zipped from .readers import EmuleReader, PeerGuardianReader, SafePeerReader diff --git a/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py b/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py index b6e5d5508..e6105cda0 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com> # @@ -7,14 +6,12 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from datetime import datetime import gi # isort:skip (Required before Gtk import). -gi.require_version('Gtk', '3.0') # NOQA: E402 +gi.require_version('Gtk', '3.0') # isort:imports-thirdparty from gi.repository import Gtk diff --git a/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py b/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py index ba410c2cf..b5fb181a2 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2007 Steve 'Tarka' Smith (tarka@internode.on.net) # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import gzip import logging import socket @@ -23,14 +20,14 @@ class PGException(Exception): # Incrementally reads PeerGuardian blocklists v1 and v2. # See http://wiki.phoenixlabs.org/wiki/P2B_Format -class PGReader(object): +class PGReader: def __init__(self, filename): log.debug('PGReader loading: %s', filename) try: with gzip.open(filename, 'rb') as _file: self.fd = _file - except IOError: + except OSError: log.debug('Blocklist: PGReader: Incorrect file type or list is corrupt') # 4 bytes, should be 0xffffffff @@ -65,8 +62,5 @@ class PGReader(object): return (start, end) - # Python 2 compatibility - next = __next__ - def close(self): self.fd.close() diff --git a/deluge/plugins/Blocklist/deluge_blocklist/readers.py b/deluge/plugins/Blocklist/deluge_blocklist/readers.py index 4079e849e..14230ed77 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/readers.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/readers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import re @@ -23,7 +20,7 @@ class ReaderParseError(Exception): pass -class BaseReader(object): +class BaseReader: """Base reader for blocklist files""" def __init__(self, _file): diff --git a/deluge/plugins/Blocklist/deluge_blocklist/webui.py b/deluge/plugins/Blocklist/deluge_blocklist/webui.py index 3da43c451..b8a0ca244 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/webui.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Blocklist/setup.py b/deluge/plugins/Blocklist/setup.py index 54ad002a3..2aa683407 100644 --- a/deluge/plugins/Blocklist/setup.py +++ b/deluge/plugins/Blocklist/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # diff --git a/deluge/plugins/Execute/deluge_execute/__init__.py b/deluge/plugins/Execute/deluge_execute/__init__.py index c6d55f4ec..3edfc4b1d 100644 --- a/deluge/plugins/Execute/deluge_execute/__init__.py +++ b/deluge/plugins/Execute/deluge_execute/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -17,7 +14,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -25,7 +22,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -33,4 +30,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Execute/deluge_execute/common.py b/deluge/plugins/Execute/deluge_execute/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/Execute/deluge_execute/common.py +++ b/deluge/plugins/Execute/deluge_execute/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Execute/deluge_execute/core.py b/deluge/plugins/Execute/deluge_execute/core.py index f5fa2c2e6..6d33e546d 100644 --- a/deluge/plugins/Execute/deluge_execute/core.py +++ b/deluge/plugins/Execute/deluge_execute/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import hashlib import logging import os diff --git a/deluge/plugins/Execute/deluge_execute/data/execute_prefs.ui b/deluge/plugins/Execute/deluge_execute/data/execute_prefs.ui index e2a5cd507..5d6354bc9 100644 --- a/deluge/plugins/Execute/deluge_execute/data/execute_prefs.ui +++ b/deluge/plugins/Execute/deluge_execute/data/execute_prefs.ui @@ -71,8 +71,6 @@ <property name="can_focus">True</property> <property name="can_default">True</property> <property name="has_default">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="left_attach">1</property> diff --git a/deluge/plugins/Execute/deluge_execute/gtkui.py b/deluge/plugins/Execute/deluge_execute/gtkui.py index c0c720089..f56a6defa 100644 --- a/deluge/plugins/Execute/deluge_execute/gtkui.py +++ b/deluge/plugins/Execute/deluge_execute/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # @@ -7,13 +6,11 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import gi # isort:skip (Required before Gtk import). -gi.require_version('Gtk', '3.0') # NOQA: E402 +gi.require_version('Gtk', '3.0') # isort:imports-thirdparty from gi.repository import Gtk @@ -41,7 +38,7 @@ EVENT_MAP = { EVENTS = ['complete', 'added', 'removed'] -class ExecutePreferences(object): +class ExecutePreferences: def __init__(self, plugin): self.plugin = plugin diff --git a/deluge/plugins/Execute/deluge_execute/webui.py b/deluge/plugins/Execute/deluge_execute/webui.py index 8327001b8..26a444533 100644 --- a/deluge/plugins/Execute/deluge_execute/webui.py +++ b/deluge/plugins/Execute/deluge_execute/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Execute/setup.py b/deluge/plugins/Execute/setup.py index 174d1a356..b65c1bd3d 100644 --- a/deluge/plugins/Execute/setup.py +++ b/deluge/plugins/Execute/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # diff --git a/deluge/plugins/Extractor/deluge_extractor/__init__.py b/deluge/plugins/Extractor/deluge_extractor/__init__.py index 6db72b63b..87d1584cd 100644 --- a/deluge/plugins/Extractor/deluge_extractor/__init__.py +++ b/deluge/plugins/Extractor/deluge_extractor/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -21,7 +18,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -29,7 +26,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -37,4 +34,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Extractor/deluge_extractor/common.py b/deluge/plugins/Extractor/deluge_extractor/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/Extractor/deluge_extractor/common.py +++ b/deluge/plugins/Extractor/deluge_extractor/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Extractor/deluge_extractor/core.py b/deluge/plugins/Extractor/deluge_extractor/core.py index 8fa5bd3da..23b2a00ac 100644 --- a/deluge/plugins/Extractor/deluge_extractor/core.py +++ b/deluge/plugins/Extractor/deluge_extractor/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import errno import logging import os @@ -37,14 +34,11 @@ if windows_check(): 'C:\\Program Files (x86)\\7-Zip\\7z.exe', ] - try: - import winreg - except ImportError: - import _winreg as winreg # For Python 2. + import winreg try: hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\7-Zip') - except WindowsError: + except OSError: pass else: win_7z_path = os.path.join(winreg.QueryValueEx(hkey, 'Path')[0], '7z.exe') diff --git a/deluge/plugins/Extractor/deluge_extractor/data/extractor_prefs.ui b/deluge/plugins/Extractor/deluge_extractor/data/extractor_prefs.ui index 6f34b4411..9e8070b50 100644 --- a/deluge/plugins/Extractor/deluge_extractor/data/extractor_prefs.ui +++ b/deluge/plugins/Extractor/deluge_extractor/data/extractor_prefs.ui @@ -62,8 +62,6 @@ <child> <object class="GtkEntry" id="entry_path"> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> diff --git a/deluge/plugins/Extractor/deluge_extractor/gtkui.py b/deluge/plugins/Extractor/deluge_extractor/gtkui.py index 113b33f6d..a754a5f22 100644 --- a/deluge/plugins/Extractor/deluge_extractor/gtkui.py +++ b/deluge/plugins/Extractor/deluge_extractor/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,13 +10,11 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import gi # isort:skip (Required before Gtk import). -gi.require_version('Gtk', '3.0') # NOQA: E402 +gi.require_version('Gtk', '3.0') # isort:imports-thirdparty from gi.repository import Gtk diff --git a/deluge/plugins/Extractor/deluge_extractor/webui.py b/deluge/plugins/Extractor/deluge_extractor/webui.py index feb7b4a83..715733cb7 100644 --- a/deluge/plugins/Extractor/deluge_extractor/webui.py +++ b/deluge/plugins/Extractor/deluge_extractor/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Extractor/setup.py b/deluge/plugins/Extractor/setup.py index 25ab153b3..09385c608 100644 --- a/deluge/plugins/Extractor/setup.py +++ b/deluge/plugins/Extractor/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # diff --git a/deluge/plugins/Label/deluge_label/__init__.py b/deluge/plugins/Label/deluge_label/__init__.py index bc0b0f243..a6c72f82b 100644 --- a/deluge/plugins/Label/deluge_label/__init__.py +++ b/deluge/plugins/Label/deluge_label/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -21,7 +18,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -29,7 +26,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -37,4 +34,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Label/deluge_label/common.py b/deluge/plugins/Label/deluge_label/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/Label/deluge_label/common.py +++ b/deluge/plugins/Label/deluge_label/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Label/deluge_label/core.py b/deluge/plugins/Label/deluge_label/core.py index b16156c91..a91275f03 100644 --- a/deluge/plugins/Label/deluge_label/core.py +++ b/deluge/plugins/Label/deluge_label/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -15,8 +14,6 @@ torrent-label core plugin. adds a status field for tracker. """ -from __future__ import unicode_literals - import logging import re diff --git a/deluge/plugins/Label/deluge_label/data/label.js b/deluge/plugins/Label/deluge_label/data/label.js index b84ea6b69..a0327e397 100644 --- a/deluge/plugins/Label/deluge_label/data/label.js +++ b/deluge/plugins/Label/deluge_label/data/label.js @@ -148,8 +148,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { xtype: 'fieldset', border: false, labelWidth: 1, - style: - 'margin-bottom: 0px; padding-bottom: 0px;', + style: 'margin-bottom: 0px; padding-bottom: 0px;', items: [ { xtype: 'checkbox', @@ -218,8 +217,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { xtype: 'fieldset', border: false, labelWidth: 1, - style: - 'margin-bottom: 0px; padding-bottom: 0px;', + style: 'margin-bottom: 0px; padding-bottom: 0px;', items: [ { xtype: 'checkbox', @@ -260,8 +258,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { width: 60, decimalPrecision: 2, incrementValue: 0.1, - style: - 'position: relative; left: 100px', + style: 'position: relative; left: 100px', disabled: true, }, { @@ -285,8 +282,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { xtype: 'fieldset', border: false, labelWidth: 1, - style: - 'margin-bottom: 0px; padding-bottom: 0px;', + style: 'margin-bottom: 0px; padding-bottom: 0px;', items: [ { xtype: 'checkbox', @@ -339,8 +335,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { xtype: 'fieldset', border: false, labelWidth: 1, - style: - 'margin-bottom: 0px; padding-bottom: 0px;', + style: 'margin-bottom: 0px; padding-bottom: 0px;', items: [ { xtype: 'checkbox', @@ -408,9 +403,8 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { onOkClick: function () { var values = this.form.getForm().getFieldValues(); if (values['auto_add_trackers']) { - values['auto_add_trackers'] = values['auto_add_trackers'].split( - '\n' - ); + values['auto_add_trackers'] = + values['auto_add_trackers'].split('\n'); } deluge.client.label.set_options(this.label, values); this.hide(); diff --git a/deluge/plugins/Label/deluge_label/data/label_add.ui b/deluge/plugins/Label/deluge_label/data/label_add.ui index 68f8a72b2..e55067596 100644 --- a/deluge/plugins/Label/deluge_label/data/label_add.ui +++ b/deluge/plugins/Label/deluge_label/data/label_add.ui @@ -141,8 +141,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="activates_default">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="expand">True</property> diff --git a/deluge/plugins/Label/deluge_label/data/label_options.ui b/deluge/plugins/Label/deluge_label/data/label_options.ui index c0fca4ff5..d390865b1 100644 --- a/deluge/plugins/Label/deluge_label/data/label_options.ui +++ b/deluge/plugins/Label/deluge_label/data/label_options.ui @@ -209,8 +209,6 @@ <object class="GtkSpinButton" id="max_upload_speed"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment1</property> </object> <packing> @@ -239,8 +237,6 @@ <object class="GtkSpinButton" id="max_download_speed"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment2</property> </object> <packing> @@ -310,8 +306,6 @@ <object class="GtkSpinButton" id="max_upload_slots"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment3</property> <property name="numeric">True</property> </object> @@ -342,8 +336,6 @@ <object class="GtkSpinButton" id="max_connections"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment4</property> <property name="numeric">True</property> </object> @@ -483,8 +475,6 @@ <object class="GtkSpinButton" id="stop_ratio"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment5</property> <property name="digits">2</property> </object> @@ -599,8 +589,6 @@ <child> <object class="GtkEntry" id="move_completed_path_entry"> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="left_attach">1</property> diff --git a/deluge/plugins/Label/deluge_label/gtkui/__init__.py b/deluge/plugins/Label/deluge_label/gtkui/__init__.py index eeaeadcc8..617071628 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/__init__.py +++ b/deluge/plugins/Label/deluge_label/gtkui/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge import component # for systray diff --git a/deluge/plugins/Label/deluge_label/gtkui/label_config.py b/deluge/plugins/Label/deluge_label/gtkui/label_config.py index b1bf56de6..26c827e9a 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/label_config.py +++ b/deluge/plugins/Label/deluge_label/gtkui/label_config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository.Gtk import Builder @@ -20,7 +17,7 @@ from ..common import get_resource log = logging.getLogger(__name__) -class LabelConfig(object): +class LabelConfig: """ there used to be some options here... """ diff --git a/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py b/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py index fe0e86bda..da1830269 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py +++ b/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com> @@ -8,13 +7,11 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import gi # isort:skip (Required before Gtk import). -gi.require_version('Gtk', '3.0') # NOQA: E402 +gi.require_version('Gtk', '3.0') # isort:imports-thirdparty from gi.repository import Gtk @@ -32,7 +29,7 @@ NO_LABEL = 'No Label' # menu -class LabelSidebarMenu(object): +class LabelSidebarMenu: def __init__(self): self.treeview = component.get('FilterTreeView') @@ -107,7 +104,7 @@ class LabelSidebarMenu(object): # dialogs: -class AddDialog(object): +class AddDialog: def __init__(self): pass @@ -129,7 +126,7 @@ class AddDialog(object): self.dialog.destroy() -class OptionsDialog(object): +class OptionsDialog: spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio'] spin_int_ids = ['max_upload_slots', 'max_connections'] chk_ids = [ @@ -174,7 +171,7 @@ class OptionsDialog(object): self.builder.connect_signals(self) # Show the label name in the header label self.builder.get_object('label_header').set_markup( - '<b>%s:</b> %s' % (_('Label Options'), self.label) + '<b>{}:</b> {}'.format(_('Label Options'), self.label) ) for chk_id, group in self.sensitive_groups: diff --git a/deluge/plugins/Label/deluge_label/gtkui/submenu.py b/deluge/plugins/Label/deluge_label/gtkui/submenu.py index c5f80e70c..ba9324b3d 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/submenu.py +++ b/deluge/plugins/Label/deluge_label/gtkui/submenu.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -8,8 +7,6 @@ # -from __future__ import unicode_literals - import logging from gi.repository.Gtk import Menu, MenuItem diff --git a/deluge/plugins/Label/deluge_label/test.py b/deluge/plugins/Label/deluge_label/test.py index 5c9ffcd00..739bae429 100644 --- a/deluge/plugins/Label/deluge_label/test.py +++ b/deluge/plugins/Label/deluge_label/test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- # # -*- coding: utf-8 -*- # @@ -10,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - from deluge.ui.client import sclient sclient.set_core_uri() diff --git a/deluge/plugins/Label/deluge_label/webui.py b/deluge/plugins/Label/deluge_label/webui.py index 58c38e941..9ccfa92b5 100644 --- a/deluge/plugins/Label/deluge_label/webui.py +++ b/deluge/plugins/Label/deluge_label/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Label/setup.py b/deluge/plugins/Label/setup.py index 567335be2..f8f2c5d3a 100644 --- a/deluge/plugins/Label/setup.py +++ b/deluge/plugins/Label/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # diff --git a/deluge/plugins/Notifications/deluge_notifications/__init__.py b/deluge/plugins/Notifications/deluge_notifications/__init__.py index 810e284df..d52b48de3 100644 --- a/deluge/plugins/Notifications/deluge_notifications/__init__.py +++ b/deluge/plugins/Notifications/deluge_notifications/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -22,7 +19,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -30,7 +27,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -38,4 +35,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Notifications/deluge_notifications/common.py b/deluge/plugins/Notifications/deluge_notifications/common.py index 6966122ca..9993f5ce4 100644 --- a/deluge/plugins/Notifications/deluge_notifications/common.py +++ b/deluge/plugins/Notifications/deluge_notifications/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path @@ -30,7 +27,7 @@ def get_resource(filename): return resource_filename(__package__, os.path.join('data', filename)) -class CustomNotifications(object): +class CustomNotifications: def __init__(self, plugin_name=None): self.custom_notifications = {'email': {}, 'popup': {}, 'blink': {}, 'sound': {}} diff --git a/deluge/plugins/Notifications/deluge_notifications/core.py b/deluge/plugins/Notifications/deluge_notifications/core.py index 9eede4576..aa200f9bd 100644 --- a/deluge/plugins/Notifications/deluge_notifications/core.py +++ b/deluge/plugins/Notifications/deluge_notifications/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import smtplib from email.utils import formatdate @@ -119,7 +116,6 @@ Date: %(date)s message = '\r\n'.join((headers + message).splitlines()) try: - # Python 2.6 server = smtplib.SMTP( self.config['smtp_host'], self.config['smtp_port'], timeout=60 ) @@ -152,7 +148,7 @@ Date: %(date)s try: try: - server.sendmail(self.config['smtp_from'], to_addrs, message) + server.sendmail(self.config['smtp_from'], to_addrs, message.encode()) except smtplib.SMTPException as ex: err_msg = ( _('There was an error sending the notification email: %s') % ex diff --git a/deluge/plugins/Notifications/deluge_notifications/data/config.ui b/deluge/plugins/Notifications/deluge_notifications/data/config.ui index c16b37acd..399cc9e1c 100644 --- a/deluge/plugins/Notifications/deluge_notifications/data/config.ui +++ b/deluge/plugins/Notifications/deluge_notifications/data/config.ui @@ -187,8 +187,6 @@ <object class="GtkEntry" id="smtp_host"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="left_attach">1</property> @@ -217,8 +215,6 @@ <property name="can_focus">True</property> <property name="max_length">5</property> <property name="width_chars">5</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment1</property> <property name="climb_rate">1</property> <property name="numeric">True</property> @@ -246,8 +242,6 @@ <object class="GtkEntry" id="smtp_user"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="left_attach">1</property> @@ -273,8 +267,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="visibility">False</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="left_attach">1</property> @@ -427,8 +419,6 @@ <object class="GtkEntry" id="smtp_from"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> </object> <packing> <property name="left_attach">1</property> diff --git a/deluge/plugins/Notifications/deluge_notifications/gtkui.py b/deluge/plugins/Notifications/deluge_notifications/gtkui.py index cb26901a7..4dc5ff8d1 100644 --- a/deluge/plugins/Notifications/deluge_notifications/gtkui.py +++ b/deluge/plugins/Notifications/deluge_notifications/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from os.path import basename diff --git a/deluge/plugins/Notifications/deluge_notifications/test.py b/deluge/plugins/Notifications/deluge_notifications/test.py index 2e6f9755b..013cdbfe1 100644 --- a/deluge/plugins/Notifications/deluge_notifications/test.py +++ b/deluge/plugins/Notifications/deluge_notifications/test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # vim: sw=4 ts=4 fenc=utf-8 et # ============================================================================== # Copyright © 2009-2010 UfSoft.org - Pedro Algarvio <pedro@algarvio.me> @@ -6,8 +5,6 @@ # License: BSD - Please view the LICENSE file for additional information. # ============================================================================== -from __future__ import unicode_literals - import logging from twisted.internet import task @@ -70,14 +67,14 @@ class TestEmailNotifications(component.Component): def custom_email_message_provider(self, *evt_args, **evt_kwargs): log.debug('Running custom email message provider: %s %s', evt_args, evt_kwargs) - subject = '%s Email Subject: %s' % (self.events[0].__class__.__name__, self.n) - message = '%s Email Message: %s' % (self.events[0].__class__.__name__, self.n) + subject = f'{self.events[0].__class__.__name__} Email Subject: {self.n}' + message = f'{self.events[0].__class__.__name__} Email Message: {self.n}' return subject, message def custom_popup_message_provider(self, *evt_args, **evt_kwargs): log.debug('Running custom popup message provider: %s %s', evt_args, evt_kwargs) - title = '%s Popup Title: %s' % (self.events[0].__class__.__name__, self.n) - message = '%s Popup Message: %s' % (self.events[0].__class__.__name__, self.n) + title = f'{self.events[0].__class__.__name__} Popup Title: {self.n}' + message = f'{self.events[0].__class__.__name__} Popup Message: {self.n}' return title, message def custom_blink_message_provider(self, *evt_args, **evt_kwargs): diff --git a/deluge/plugins/Notifications/deluge_notifications/webui.py b/deluge/plugins/Notifications/deluge_notifications/webui.py index d3529c4f9..ad090f5c1 100644 --- a/deluge/plugins/Notifications/deluge_notifications/webui.py +++ b/deluge/plugins/Notifications/deluge_notifications/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Notifications/setup.py b/deluge/plugins/Notifications/setup.py index 2b2f5aebc..3d8742392 100755 --- a/deluge/plugins/Notifications/setup.py +++ b/deluge/plugins/Notifications/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me> # diff --git a/deluge/plugins/Scheduler/deluge_scheduler/__init__.py b/deluge/plugins/Scheduler/deluge_scheduler/__init__.py index 6db72b63b..87d1584cd 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/__init__.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -21,7 +18,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -29,7 +26,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -37,4 +34,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Scheduler/deluge_scheduler/common.py b/deluge/plugins/Scheduler/deluge_scheduler/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/common.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Scheduler/deluge_scheduler/core.py b/deluge/plugins/Scheduler/deluge_scheduler/core.py index 388e4f0f6..10798ba42 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/core.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import time diff --git a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py index 12f5fb63c..16222c835 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging from gi.repository import Gdk, Gtk @@ -30,7 +27,7 @@ DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] class SchedulerSelectWidget(Gtk.DrawingArea): def __init__(self, hover): - super(SchedulerSelectWidget, self).__init__() + super().__init__() self.set_events( Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK diff --git a/deluge/plugins/Scheduler/deluge_scheduler/webui.py b/deluge/plugins/Scheduler/deluge_scheduler/webui.py index 518eaa6aa..4f5418b88 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/webui.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # @@ -10,8 +9,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Scheduler/setup.py b/deluge/plugins/Scheduler/setup.py index 71b69e9f9..3ac181d08 100644 --- a/deluge/plugins/Scheduler/setup.py +++ b/deluge/plugins/Scheduler/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com> # diff --git a/deluge/plugins/Stats/deluge_stats/__init__.py b/deluge/plugins/Stats/deluge_stats/__init__.py index a40379b9a..ca7b0bb83 100644 --- a/deluge/plugins/Stats/deluge_stats/__init__.py +++ b/deluge/plugins/Stats/deluge_stats/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -21,7 +18,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -29,7 +26,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -37,4 +34,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Stats/deluge_stats/common.py b/deluge/plugins/Stats/deluge_stats/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/Stats/deluge_stats/common.py +++ b/deluge/plugins/Stats/deluge_stats/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Stats/deluge_stats/core.py b/deluge/plugins/Stats/deluge_stats/core.py index 5f38b69b4..1be51e659 100644 --- a/deluge/plugins/Stats/deluge_stats/core.py +++ b/deluge/plugins/Stats/deluge_stats/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Ian Martin <ianmartin@cantab.net> # Copyright (C) 2008 Damien Churchill <damoxc@gmail.com> @@ -10,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import time diff --git a/deluge/plugins/Stats/deluge_stats/graph.py b/deluge/plugins/Stats/deluge_stats/graph.py index bc18913b3..0d3220fc1 100644 --- a/deluge/plugins/Stats/deluge_stats/graph.py +++ b/deluge/plugins/Stats/deluge_stats/graph.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Ian Martin <ianmartin@cantab.net> # Copyright (C) 2008 Damien Churchill <damoxc@gmail.com> @@ -14,15 +13,13 @@ port of old plugin by markybob. """ -from __future__ import division, unicode_literals - import logging import math import time import gi -gi.require_foreign('cairo') # NOQA: E402 +gi.require_foreign('cairo') import cairo # isort:skip (gi checks required before import). @@ -62,7 +59,7 @@ def change_opacity(color, opactiy): return tuple(color) -class Graph(object): +class Graph: def __init__(self): self.width = 100 self.height = 100 @@ -178,7 +175,7 @@ class Graph(object): te = self.ctx.text_extents(text) return math.ceil(te[4] - te[0]) - y_tick_width = max((space_required(text) for text in y_tick_text)) + y_tick_width = max(space_required(text) for text in y_tick_text) top = font_extents[2] / 2 # bounds(left, top, right, bottom) diff --git a/deluge/plugins/Stats/deluge_stats/gtkui.py b/deluge/plugins/Stats/deluge_stats/gtkui.py index 75e30150e..c088060dc 100644 --- a/deluge/plugins/Stats/deluge_stats/gtkui.py +++ b/deluge/plugins/Stats/deluge_stats/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Ian Martin <ianmartin@cantab.net> # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging from gi.repository import Gtk @@ -85,7 +82,7 @@ def text_to_rgba(color): class GraphsTab(Tab): def __init__(self, colors): - super(GraphsTab, self).__init__() + super().__init__() builder = Gtk.Builder() builder.add_from_file(get_resource('tabs.ui')) @@ -270,7 +267,7 @@ class GtkUI(Gtk3PluginBase): for graph, colors in self.config['colors'].items(): gtkconf[graph] = {} for value, color in colors.items(): - color_btn = self.builder.get_object('%s_%s_color' % (graph, value)) + color_btn = self.builder.get_object(f'{graph}_{value}_color') try: gtkconf[graph][value] = color_btn.get_color().to_string() except Exception: @@ -285,7 +282,7 @@ class GtkUI(Gtk3PluginBase): for graph, colors in self.config['colors'].items(): for value, color in colors.items(): try: - color_btn = self.builder.get_object('%s_%s_color' % (graph, value)) + color_btn = self.builder.get_object(f'{graph}_{value}_color') color_btn.set_rgba(text_to_rgba(color)) except Exception as ex: log.debug('Unable to set %s %s %s: %s', graph, value, color, ex) diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py index ab2456877..9c66ee107 100644 --- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py @@ -1,19 +1,14 @@ -# -*- coding: utf-8 -*- # # This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import pytest +import pytest_twisted from twisted.internet import defer -from twisted.trial import unittest import deluge.component as component from deluge.common import fsize, fspeed -from deluge.tests import common as tests_common -from deluge.tests.basetest import BaseTestCase from deluge.ui.client import client @@ -26,42 +21,42 @@ def print_totals(totals): print('down:', fsize(totals['total_download'] - totals['total_payload_download'])) -class StatsTestCase(BaseTestCase): - def set_up(self): +@pytest.mark.usefixtures('component') +class TestStatsPlugin: + @pytest_twisted.async_yield_fixture(autouse=True) + async def set_up(self): defer.setDebugging(True) - tests_common.set_tmp_config_dir() client.start_standalone() client.core.enable_plugin('Stats') - return component.start() - - def tear_down(self): + await component.start() + yield client.stop_standalone() - return component.shutdown() + await component.shutdown() @defer.inlineCallbacks def test_client_totals(self): plugins = yield client.core.get_available_plugins() if 'Stats' not in plugins: - raise unittest.SkipTest('WebUi plugin not available for testing') + pytest.skip('Stats plugin not available for testing') totals = yield client.stats.get_totals() - self.assertEqual(totals['total_upload'], 0) - self.assertEqual(totals['total_payload_upload'], 0) - self.assertEqual(totals['total_payload_download'], 0) - self.assertEqual(totals['total_download'], 0) + assert totals['total_upload'] == 0 + assert totals['total_payload_upload'] == 0 + assert totals['total_payload_download'] == 0 + assert totals['total_download'] == 0 # print_totals(totals) @defer.inlineCallbacks def test_session_totals(self): plugins = yield client.core.get_available_plugins() if 'Stats' not in plugins: - raise unittest.SkipTest('WebUi plugin not available for testing') + pytest.skip('Stats plugin not available for testing') totals = yield client.stats.get_session_totals() - self.assertEqual(totals['total_upload'], 0) - self.assertEqual(totals['total_payload_upload'], 0) - self.assertEqual(totals['total_payload_download'], 0) - self.assertEqual(totals['total_download'], 0) + assert totals['total_upload'] == 0 + assert totals['total_payload_upload'] == 0 + assert totals['total_payload_download'] == 0 + assert totals['total_download'] == 0 # print_totals(totals) @pytest.mark.gtkui @@ -90,7 +85,7 @@ class StatsTestCase(BaseTestCase): TorrentDetails() Preferences() - class FakeFile(object): + class FakeFile: def __init__(self): self.data = [] diff --git a/deluge/plugins/Stats/deluge_stats/webui.py b/deluge/plugins/Stats/deluge_stats/webui.py index 4c11260e5..f38daeb64 100644 --- a/deluge/plugins/Stats/deluge_stats/webui.py +++ b/deluge/plugins/Stats/deluge_stats/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Stats/setup.py b/deluge/plugins/Stats/setup.py index 174c652a9..0f3e0695b 100644 --- a/deluge/plugins/Stats/setup.py +++ b/deluge/plugins/Stats/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Ian Martin <ianmartin@cantab.net> # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> diff --git a/deluge/plugins/Toggle/deluge_toggle/__init__.py b/deluge/plugins/Toggle/deluge_toggle/__init__.py index e63e4aa4c..b0332ee9c 100644 --- a/deluge/plugins/Toggle/deluge_toggle/__init__.py +++ b/deluge/plugins/Toggle/deluge_toggle/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -22,7 +19,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -30,7 +27,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -38,4 +35,4 @@ class WebUIPlugin(PluginInitBase): from .webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/Toggle/deluge_toggle/common.py b/deluge/plugins/Toggle/deluge_toggle/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/Toggle/deluge_toggle/common.py +++ b/deluge/plugins/Toggle/deluge_toggle/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Toggle/deluge_toggle/core.py b/deluge/plugins/Toggle/deluge_toggle/core.py index dad52ce61..ab4581b47 100644 --- a/deluge/plugins/Toggle/deluge_toggle/core.py +++ b/deluge/plugins/Toggle/deluge_toggle/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/plugins/Toggle/deluge_toggle/gtkui.py b/deluge/plugins/Toggle/deluge_toggle/gtkui.py index c54bca46f..bfb90de1b 100644 --- a/deluge/plugins/Toggle/deluge_toggle/gtkui.py +++ b/deluge/plugins/Toggle/deluge_toggle/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/plugins/Toggle/deluge_toggle/webui.py b/deluge/plugins/Toggle/deluge_toggle/webui.py index 8f0fc8c99..d16d29fff 100644 --- a/deluge/plugins/Toggle/deluge_toggle/webui.py +++ b/deluge/plugins/Toggle/deluge_toggle/webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com> # @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Toggle/setup.py b/deluge/plugins/Toggle/setup.py index acc6e6c7d..dadd32ebc 100644 --- a/deluge/plugins/Toggle/setup.py +++ b/deluge/plugins/Toggle/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com> # diff --git a/deluge/plugins/WebUi/deluge_webui/__init__.py b/deluge/plugins/WebUi/deluge_webui/__init__.py index a3d29805a..ba978b224 100644 --- a/deluge/plugins/WebUi/deluge_webui/__init__.py +++ b/deluge/plugins/WebUi/deluge_webui/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase @@ -21,7 +18,7 @@ class CorePlugin(PluginInitBase): from .core import Core as _pluginCls self._plugin_cls = _pluginCls - super(CorePlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class GtkUIPlugin(PluginInitBase): @@ -29,7 +26,7 @@ class GtkUIPlugin(PluginInitBase): from .gtkui import GtkUI as _pluginCls self._plugin_cls = _pluginCls - super(GtkUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) class WebUIPlugin(PluginInitBase): @@ -37,4 +34,4 @@ class WebUIPlugin(PluginInitBase): from webui import WebUI as _pluginCls self._plugin_cls = _pluginCls - super(WebUIPlugin, self).__init__(plugin_name) + super().__init__(plugin_name) diff --git a/deluge/plugins/WebUi/deluge_webui/common.py b/deluge/plugins/WebUi/deluge_webui/common.py index 4c9db09d5..eb47f1398 100644 --- a/deluge/plugins/WebUi/deluge_webui/common.py +++ b/deluge/plugins/WebUi/deluge_webui/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com> @@ -12,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/WebUi/deluge_webui/core.py b/deluge/plugins/WebUi/deluge_webui/core.py index cc3330fc0..f18203e90 100644 --- a/deluge/plugins/WebUi/deluge_webui/core.py +++ b/deluge/plugins/WebUi/deluge_webui/core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from twisted.internet import defer diff --git a/deluge/plugins/WebUi/deluge_webui/data/config.ui b/deluge/plugins/WebUi/deluge_webui/data/config.ui index 18647a415..c58edd0cd 100644 --- a/deluge/plugins/WebUi/deluge_webui/data/config.ui +++ b/deluge/plugins/WebUi/deluge_webui/data/config.ui @@ -86,8 +86,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> <property name="adjustment">adjustment1</property> <property name="numeric">True</property> </object> diff --git a/deluge/plugins/WebUi/deluge_webui/gtkui.py b/deluge/plugins/WebUi/deluge_webui/gtkui.py index ca3a16ea4..3d19417dc 100644 --- a/deluge/plugins/WebUi/deluge_webui/gtkui.py +++ b/deluge/plugins/WebUi/deluge_webui/gtkui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # @@ -11,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository import Gtk diff --git a/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py b/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py index 56e1cc023..1badedca0 100644 --- a/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py +++ b/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com> # @@ -6,44 +5,44 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # - -from __future__ import unicode_literals - -from twisted.trial import unittest +import pytest +import pytest_twisted import deluge.component as component from deluge.core.core import Core from deluge.core.rpcserver import RPCServer from deluge.tests import common -from deluge.tests.basetest import BaseTestCase common.disable_new_release_check() -class WebUIPluginTestCase(BaseTestCase): - def set_up(self): - common.set_tmp_config_dir() +@pytest.mark.usefixtures('component') +class TestWebUIPlugin: + @pytest_twisted.async_yield_fixture(autouse=True) + async def set_up(self, request): + self = request.instance self.rpcserver = RPCServer(listen=False) self.core = Core() - return component.start() + await component.start() + + yield - def tear_down(self): def on_shutdown(result): del self.rpcserver del self.core - return component.shutdown().addCallback(on_shutdown) + await component.shutdown().addCallback(on_shutdown) def test_enable_webui(self): if 'WebUi' not in self.core.get_available_plugins(): - raise unittest.SkipTest('WebUi plugin not available for testing') + pytest.skip('WebUi plugin not available for testing') d = self.core.enable_plugin('WebUi') def result_cb(result): if 'WebUi' not in self.core.get_enabled_plugins(): self.fail('Failed to enable WebUi plugin') - self.assertTrue(result) + assert result d.addBoth(result_cb) return d diff --git a/deluge/plugins/WebUi/setup.py b/deluge/plugins/WebUi/setup.py index 861a05a50..5f2184cc9 100644 --- a/deluge/plugins/WebUi/setup.py +++ b/deluge/plugins/WebUi/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009 Damien Churchill <damoxc@gmail.com> # diff --git a/deluge/plugins/init.py b/deluge/plugins/init.py index addeae9f3..56b31977d 100644 --- a/deluge/plugins/init.py +++ b/deluge/plugins/init.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com> # @@ -10,14 +9,12 @@ """ This base class is used in plugin's __init__ for the plugin entry points. """ -from __future__ import unicode_literals - import logging log = logging.getLogger(__name__) -class PluginInitBase(object): +class PluginInitBase: _plugin_cls = None def __init__(self, plugin_name): diff --git a/deluge/plugins/pluginbase.py b/deluge/plugins/pluginbase.py index e80199df1..5dda2f077 100644 --- a/deluge/plugins/pluginbase.py +++ b/deluge/plugins/pluginbase.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com> # @@ -7,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component @@ -21,7 +18,7 @@ class PluginBase(component.Component): update_interval = 1 def __init__(self, name): - super(PluginBase, self).__init__(name, self.update_interval) + super().__init__(name, self.update_interval) def enable(self): raise NotImplementedError('Need to define an enable method!') @@ -32,7 +29,7 @@ class PluginBase(component.Component): class CorePluginBase(PluginBase): def __init__(self, plugin_name): - super(CorePluginBase, self).__init__('CorePlugin.' + plugin_name) + super().__init__('CorePlugin.' + plugin_name) # Register RPC methods component.get('RPCServer').register_object(self, plugin_name.lower()) log.debug('CorePlugin initialized..') @@ -41,22 +38,22 @@ class CorePluginBase(PluginBase): component.get('RPCServer').deregister_object(self) def enable(self): - super(CorePluginBase, self).enable() + super().enable() def disable(self): - super(CorePluginBase, self).disable() + super().disable() class Gtk3PluginBase(PluginBase): def __init__(self, plugin_name): - super(Gtk3PluginBase, self).__init__('Gtk3Plugin.' + plugin_name) + super().__init__('Gtk3Plugin.' + plugin_name) log.debug('Gtk3Plugin initialized..') def enable(self): - super(Gtk3PluginBase, self).enable() + super().enable() def disable(self): - super(Gtk3PluginBase, self).disable() + super().disable() class WebPluginBase(PluginBase): @@ -68,7 +65,7 @@ class WebPluginBase(PluginBase): debug_stylesheets = [] def __init__(self, plugin_name): - super(WebPluginBase, self).__init__('WebPlugin.' + plugin_name) + super().__init__('WebPlugin.' + plugin_name) # Register JSON rpc methods component.get('JSON').register_object(self, plugin_name.lower()) |