summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDjLegolas <djlegolas@protonmail.com>2021-12-28 22:20:57 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2021-12-29 21:51:07 +0000
commitec0bcc11f510cd113bbdb6cd551b27c697f03f53 (patch)
treec60c19a61a14fa157227ad7531406f250493b78e
parent16895b4a492aedca8bcc2929a905207341c36b35 (diff)
downloaddeluge-ec0bcc11f510cd113bbdb6cd551b27c697f03f53.tar.gz
deluge-ec0bcc11f510cd113bbdb6cd551b27c697f03f53.tar.bz2
deluge-ec0bcc11f510cd113bbdb6cd551b27c697f03f53.zip
Upgrade codebase with pyupgrade (>=py3.6)
Added pyupgrade utility with manual stage to pre-commit and run on all files. Ref: https://github.com/asottile/pyupgrade Closes: deluge-torrent/deluge#326
-rw-r--r--.pre-commit-config.yaml6
-rw-r--r--DEPENDS.md2
-rw-r--r--deluge/_libtorrent.py3
-rw-r--r--deluge/argparserbase.py11
-rw-r--r--deluge/bencode.py2
-rw-r--r--deluge/common.py31
-rw-r--r--deluge/component.py11
-rw-r--r--deluge/config.py18
-rw-r--r--deluge/configmanager.py3
-rw-r--r--deluge/core/alertmanager.py1
-rw-r--r--deluge/core/authmanager.py20
-rw-r--r--deluge/core/core.py9
-rw-r--r--deluge/core/daemon.py11
-rw-r--r--deluge/core/daemon_entry.py1
-rw-r--r--deluge/core/eventmanager.py1
-rw-r--r--deluge/core/filtermanager.py1
-rw-r--r--deluge/core/pluginmanager.py1
-rw-r--r--deluge/core/preferencesmanager.py5
-rw-r--r--deluge/core/rpcserver.py5
-rw-r--r--deluge/core/torrent.py13
-rw-r--r--deluge/core/torrentmanager.py7
-rw-r--r--deluge/crypto_utils.py1
-rw-r--r--deluge/decorators.py7
-rw-r--r--deluge/error.py15
-rw-r--r--deluge/event.py3
-rw-r--r--deluge/httpdownloader.py13
-rw-r--r--deluge/i18n/languages.py1
-rw-r--r--deluge/i18n/util.py3
-rw-r--r--deluge/log.py7
-rw-r--r--deluge/maketorrent.py3
-rw-r--r--deluge/metafile.py3
-rw-r--r--deluge/path_chooser_common.py1
-rw-r--r--deluge/pluginmanagerbase.py3
-rw-r--r--deluge/plugins/AutoAdd/deluge_autoadd/__init__.py7
-rw-r--r--deluge/plugins/AutoAdd/deluge_autoadd/common.py1
-rw-r--r--deluge/plugins/AutoAdd/deluge_autoadd/core.py11
-rw-r--r--deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py3
-rw-r--r--deluge/plugins/AutoAdd/deluge_autoadd/webui.py1
-rw-r--r--deluge/plugins/AutoAdd/setup.py1
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/__init__.py7
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/common.py9
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/core.py1
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/decompressers.py1
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/detect.py1
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/gtkui.py1
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py5
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/readers.py3
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/webui.py1
-rw-r--r--deluge/plugins/Blocklist/setup.py1
-rw-r--r--deluge/plugins/Execute/deluge_execute/__init__.py7
-rw-r--r--deluge/plugins/Execute/deluge_execute/common.py1
-rw-r--r--deluge/plugins/Execute/deluge_execute/core.py1
-rw-r--r--deluge/plugins/Execute/deluge_execute/gtkui.py3
-rw-r--r--deluge/plugins/Execute/deluge_execute/webui.py1
-rw-r--r--deluge/plugins/Execute/setup.py1
-rw-r--r--deluge/plugins/Extractor/deluge_extractor/__init__.py7
-rw-r--r--deluge/plugins/Extractor/deluge_extractor/common.py1
-rw-r--r--deluge/plugins/Extractor/deluge_extractor/core.py3
-rw-r--r--deluge/plugins/Extractor/deluge_extractor/gtkui.py1
-rw-r--r--deluge/plugins/Extractor/deluge_extractor/webui.py1
-rw-r--r--deluge/plugins/Extractor/setup.py1
-rw-r--r--deluge/plugins/Label/deluge_label/__init__.py7
-rw-r--r--deluge/plugins/Label/deluge_label/common.py1
-rw-r--r--deluge/plugins/Label/deluge_label/core.py1
-rw-r--r--deluge/plugins/Label/deluge_label/gtkui/__init__.py1
-rw-r--r--deluge/plugins/Label/deluge_label/gtkui/label_config.py3
-rw-r--r--deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py9
-rw-r--r--deluge/plugins/Label/deluge_label/gtkui/submenu.py1
-rw-r--r--deluge/plugins/Label/deluge_label/test.py1
-rw-r--r--deluge/plugins/Label/deluge_label/webui.py1
-rw-r--r--deluge/plugins/Label/setup.py1
-rw-r--r--deluge/plugins/Notifications/deluge_notifications/__init__.py7
-rw-r--r--deluge/plugins/Notifications/deluge_notifications/common.py3
-rw-r--r--deluge/plugins/Notifications/deluge_notifications/core.py1
-rw-r--r--deluge/plugins/Notifications/deluge_notifications/gtkui.py1
-rw-r--r--deluge/plugins/Notifications/deluge_notifications/test.py9
-rw-r--r--deluge/plugins/Notifications/deluge_notifications/webui.py1
-rwxr-xr-xdeluge/plugins/Notifications/setup.py1
-rw-r--r--deluge/plugins/Scheduler/deluge_scheduler/__init__.py7
-rw-r--r--deluge/plugins/Scheduler/deluge_scheduler/common.py1
-rw-r--r--deluge/plugins/Scheduler/deluge_scheduler/core.py1
-rw-r--r--deluge/plugins/Scheduler/deluge_scheduler/gtkui.py3
-rw-r--r--deluge/plugins/Scheduler/deluge_scheduler/webui.py1
-rw-r--r--deluge/plugins/Scheduler/setup.py1
-rw-r--r--deluge/plugins/Stats/deluge_stats/__init__.py7
-rw-r--r--deluge/plugins/Stats/deluge_stats/common.py1
-rw-r--r--deluge/plugins/Stats/deluge_stats/core.py1
-rw-r--r--deluge/plugins/Stats/deluge_stats/graph.py5
-rw-r--r--deluge/plugins/Stats/deluge_stats/gtkui.py7
-rw-r--r--deluge/plugins/Stats/deluge_stats/tests/test_stats.py3
-rw-r--r--deluge/plugins/Stats/deluge_stats/webui.py1
-rw-r--r--deluge/plugins/Stats/setup.py1
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/__init__.py7
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/common.py1
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/core.py1
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/gtkui.py1
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/webui.py1
-rw-r--r--deluge/plugins/Toggle/setup.py1
-rw-r--r--deluge/plugins/WebUi/deluge_webui/__init__.py7
-rw-r--r--deluge/plugins/WebUi/deluge_webui/common.py1
-rw-r--r--deluge/plugins/WebUi/deluge_webui/core.py1
-rw-r--r--deluge/plugins/WebUi/deluge_webui/gtkui.py1
-rw-r--r--deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py1
-rw-r--r--deluge/plugins/WebUi/setup.py1
-rw-r--r--deluge/plugins/init.py3
-rw-r--r--deluge/plugins/pluginbase.py17
-rw-r--r--deluge/scripts/deluge_remote.py1
-rw-r--r--deluge/tests/basetest.py1
-rw-r--r--deluge/tests/common.py5
-rw-r--r--deluge/tests/common_web.py3
-rw-r--r--deluge/tests/daemon_base.py3
-rw-r--r--deluge/tests/test_alertmanager.py1
-rw-r--r--deluge/tests/test_authmanager.py1
-rw-r--r--deluge/tests/test_bencode.py1
-rw-r--r--deluge/tests/test_client.py1
-rw-r--r--deluge/tests/test_common.py1
-rw-r--r--deluge/tests/test_component.py1
-rw-r--r--deluge/tests/test_config.py1
-rw-r--r--deluge/tests/test_core.py1
-rw-r--r--deluge/tests/test_decorators.py3
-rw-r--r--deluge/tests/test_error.py1
-rw-r--r--deluge/tests/test_files_tab.py3
-rw-r--r--deluge/tests/test_httpdownloader.py8
-rw-r--r--deluge/tests/test_json_api.py3
-rw-r--r--deluge/tests/test_log.py1
-rw-r--r--deluge/tests/test_maketorrent.py1
-rw-r--r--deluge/tests/test_metafile.py1
-rw-r--r--deluge/tests/test_plugin_metadata.py3
-rw-r--r--deluge/tests/test_rpcserver.py1
-rw-r--r--deluge/tests/test_security.py9
-rw-r--r--deluge/tests/test_sessionproxy.py5
-rw-r--r--deluge/tests/test_torrent.py3
-rw-r--r--deluge/tests/test_torrentmanager.py3
-rw-r--r--deluge/tests/test_torrentview.py1
-rw-r--r--deluge/tests/test_tracker_icons.py1
-rw-r--r--deluge/tests/test_transfer.py1
-rw-r--r--deluge/tests/test_ui_common.py1
-rw-r--r--deluge/tests/test_ui_console.py3
-rw-r--r--deluge/tests/test_ui_entry.py21
-rw-r--r--deluge/tests/test_ui_gtk3.py3
-rw-r--r--deluge/tests/test_web_api.py7
-rw-r--r--deluge/tests/test_web_auth.py6
-rw-r--r--deluge/tests/test_webserver.py1
-rw-r--r--deluge/tests/twisted/plugins/delugereporter.py3
-rw-r--r--deluge/transfer.py5
-rw-r--r--deluge/ui/client.py9
-rw-r--r--deluge/ui/common.py9
-rw-r--r--deluge/ui/console/__init__.py1
-rw-r--r--deluge/ui/console/cmdline/command.py5
-rw-r--r--deluge/ui/console/cmdline/commands/__init__.py1
-rw-r--r--deluge/ui/console/cmdline/commands/add.py1
-rw-r--r--deluge/ui/console/cmdline/commands/cache.py3
-rw-r--r--deluge/ui/console/cmdline/commands/config.py7
-rw-r--r--deluge/ui/console/cmdline/commands/connect.py3
-rw-r--r--deluge/ui/console/cmdline/commands/debug.py1
-rw-r--r--deluge/ui/console/cmdline/commands/gui.py1
-rw-r--r--deluge/ui/console/cmdline/commands/halt.py1
-rw-r--r--deluge/ui/console/cmdline/commands/help.py1
-rw-r--r--deluge/ui/console/cmdline/commands/info.py27
-rw-r--r--deluge/ui/console/cmdline/commands/manage.py7
-rw-r--r--deluge/ui/console/cmdline/commands/move.py3
-rw-r--r--deluge/ui/console/cmdline/commands/pause.py1
-rw-r--r--deluge/ui/console/cmdline/commands/plugin.py1
-rw-r--r--deluge/ui/console/cmdline/commands/quit.py1
-rw-r--r--deluge/ui/console/cmdline/commands/recheck.py1
-rw-r--r--deluge/ui/console/cmdline/commands/resume.py1
-rw-r--r--deluge/ui/console/cmdline/commands/rm.py3
-rw-r--r--deluge/ui/console/cmdline/commands/status.py1
-rw-r--r--deluge/ui/console/cmdline/commands/update_tracker.py1
-rw-r--r--deluge/ui/console/console.py9
-rw-r--r--deluge/ui/console/main.py9
-rw-r--r--deluge/ui/console/modes/add_util.py1
-rw-r--r--deluge/ui/console/modes/addtorrents.py3
-rw-r--r--deluge/ui/console/modes/basemode.py7
-rw-r--r--deluge/ui/console/modes/cmdline.py16
-rw-r--r--deluge/ui/console/modes/connectionmanager.py3
-rw-r--r--deluge/ui/console/modes/eventview.py1
-rw-r--r--deluge/ui/console/modes/preferences/preference_panes.py1
-rw-r--r--deluge/ui/console/modes/preferences/preferences.py3
-rw-r--r--deluge/ui/console/modes/torrentdetail.py31
-rw-r--r--deluge/ui/console/modes/torrentlist/__init__.py2
-rw-r--r--deluge/ui/console/modes/torrentlist/add_torrents_popup.py3
-rw-r--r--deluge/ui/console/modes/torrentlist/filtersidebar.py1
-rw-r--r--deluge/ui/console/modes/torrentlist/queue_mode.py3
-rw-r--r--deluge/ui/console/modes/torrentlist/search_mode.py3
-rw-r--r--deluge/ui/console/modes/torrentlist/torrentactions.py5
-rw-r--r--deluge/ui/console/modes/torrentlist/torrentlist.py7
-rw-r--r--deluge/ui/console/modes/torrentlist/torrentview.py5
-rw-r--r--deluge/ui/console/modes/torrentlist/torrentviewcolumns.py1
-rw-r--r--deluge/ui/console/parser.py11
-rw-r--r--deluge/ui/console/utils/colors.py5
-rw-r--r--deluge/ui/console/utils/column.py1
-rw-r--r--deluge/ui/console/utils/common.py1
-rw-r--r--deluge/ui/console/utils/curses_util.py5
-rw-r--r--deluge/ui/console/utils/format_utils.py13
-rw-r--r--deluge/ui/console/widgets/fields.py37
-rw-r--r--deluge/ui/console/widgets/inputpane.py1
-rw-r--r--deluge/ui/console/widgets/popup.py5
-rw-r--r--deluge/ui/console/widgets/sidebar.py1
-rw-r--r--deluge/ui/console/widgets/statusbars.py1
-rw-r--r--deluge/ui/console/widgets/window.py3
-rw-r--r--deluge/ui/coreconfig.py1
-rw-r--r--deluge/ui/countries.py1
-rw-r--r--deluge/ui/gtk3/__init__.py5
-rw-r--r--deluge/ui/gtk3/aboutdialog.py3
-rw-r--r--deluge/ui/gtk3/addtorrentdialog.py5
-rw-r--r--deluge/ui/gtk3/common.py17
-rw-r--r--deluge/ui/gtk3/connectionmanager.py1
-rw-r--r--deluge/ui/gtk3/createtorrentdialog.py3
-rw-r--r--deluge/ui/gtk3/details_tab.py5
-rw-r--r--deluge/ui/gtk3/dialogs.py19
-rw-r--r--deluge/ui/gtk3/edittrackersdialog.py5
-rw-r--r--deluge/ui/gtk3/files_tab.py3
-rw-r--r--deluge/ui/gtk3/filtertreeview.py3
-rw-r--r--deluge/ui/gtk3/gtkui.py3
-rw-r--r--deluge/ui/gtk3/ipcinterface.py1
-rw-r--r--deluge/ui/gtk3/listview.py9
-rw-r--r--deluge/ui/gtk3/mainwindow.py3
-rw-r--r--deluge/ui/gtk3/menubar.py1
-rw-r--r--deluge/ui/gtk3/menubar_osx.py1
-rw-r--r--deluge/ui/gtk3/new_release_dialog.py3
-rw-r--r--deluge/ui/gtk3/options_tab.py3
-rw-r--r--deluge/ui/gtk3/path_chooser.py3
-rwxr-xr-xdeluge/ui/gtk3/path_combo_chooser.py29
-rw-r--r--deluge/ui/gtk3/peers_tab.py5
-rw-r--r--deluge/ui/gtk3/piecesbar.py3
-rw-r--r--deluge/ui/gtk3/pluginmanager.py1
-rw-r--r--deluge/ui/gtk3/preferences.py1
-rw-r--r--deluge/ui/gtk3/queuedtorrents.py1
-rw-r--r--deluge/ui/gtk3/removetorrentdialog.py3
-rw-r--r--deluge/ui/gtk3/sidebar.py1
-rw-r--r--deluge/ui/gtk3/status_tab.py3
-rw-r--r--deluge/ui/gtk3/statusbar.py5
-rw-r--r--deluge/ui/gtk3/systemtray.py7
-rw-r--r--deluge/ui/gtk3/tab_data_funcs.py9
-rw-r--r--deluge/ui/gtk3/toolbar.py1
-rw-r--r--deluge/ui/gtk3/torrentdetails.py3
-rw-r--r--deluge/ui/gtk3/torrentview.py3
-rw-r--r--deluge/ui/gtk3/torrentview_data_funcs.py5
-rw-r--r--deluge/ui/gtk3/trackers_tab.py5
-rw-r--r--deluge/ui/hostlist.py3
-rw-r--r--deluge/ui/sessionproxy.py1
-rw-r--r--deluge/ui/tracker_icons.py7
-rw-r--r--deluge/ui/ui.py3
-rw-r--r--deluge/ui/ui_entry.py5
-rw-r--r--deluge/ui/web/auth.py3
-rw-r--r--deluge/ui/web/common.py1
-rw-r--r--deluge/ui/web/json_api.py17
-rw-r--r--deluge/ui/web/pluginmanager.py26
-rw-r--r--deluge/ui/web/server.py3
-rw-r--r--deluge/ui/web/web.py5
-rw-r--r--docs/source/conf.py3
-rw-r--r--docs/source/devguide/how-to/update-1.3-plugin.md2
-rwxr-xr-xgen_web_gettext.py3
-rwxr-xr-xgenerate_pot.py3
-rwxr-xr-xminify_web_js.py5
-rwxr-xr-xmsgfmt.py9
-rwxr-xr-xpackaging/source/make_release.py3
-rw-r--r--packaging/win32/deluge-bbfreeze.py4
-rwxr-xr-xsetup.py15
-rwxr-xr-xversion.py5
261 files changed, 440 insertions, 713 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8f00d42fb..a0f0a5dbe 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -41,3 +41,9 @@ repos:
args: [--fix=auto]
- id: trailing-whitespace
name: Fix Trailing whitespace
+ - repo: https://github.com/asottile/pyupgrade
+ rev: v2.29.1
+ hooks:
+ - id: pyupgrade
+ args: [--py36-plus]
+ stages: [manual]
diff --git a/DEPENDS.md b/DEPENDS.md
index 076069566..04d95c8a2 100644
--- a/DEPENDS.md
+++ b/DEPENDS.md
@@ -7,7 +7,7 @@ All modules will require the [common](#common) section dependencies.
## Prerequisite
-- [Python] _>= 3.5_
+- [Python] _>= 3.6_
## Build
diff --git a/deluge/_libtorrent.py b/deluge/_libtorrent.py
index 86025b56a..7130d7efd 100644
--- a/deluge/_libtorrent.py
+++ b/deluge/_libtorrent.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -32,5 +31,5 @@ LT_VERSION = lt.__version__
if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
raise LibtorrentImportError(
- 'Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION)
+ f'Deluge {get_version()} requires libtorrent >= {REQUIRED_VERSION}'
)
diff --git a/deluge/argparserbase.py b/deluge/argparserbase.py
index a27ba1aaf..45417ee31 100644
--- a/deluge/argparserbase.py
+++ b/deluge/argparserbase.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
@@ -93,7 +92,7 @@ def _get_version_detail():
except ImportError:
pass
version_str += 'Python: %s\n' % platform.python_version()
- version_str += 'OS: %s %s\n' % (platform.system(), common.get_os_version())
+ version_str += f'OS: {platform.system()} {common.get_os_version()}\n'
return version_str
@@ -135,7 +134,7 @@ class DelugeTextHelpFormatter(argparse.RawDescriptionHelpFormatter):
default = action.dest.upper()
args_string = self._format_args(action, default)
opt = ', '.join(action.option_strings)
- parts.append('%s %s' % (opt, args_string))
+ parts.append(f'{opt} {args_string}')
return ', '.join(parts)
@@ -163,7 +162,7 @@ class ArgParserBase(argparse.ArgumentParser):
self.log_stream = kwargs['log_stream']
del kwargs['log_stream']
- super(ArgParserBase, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
self.common_setup = False
self.process_arg_group = False
@@ -244,7 +243,7 @@ class ArgParserBase(argparse.ArgumentParser):
argparse.Namespace: The parsed arguments.
"""
- options = super(ArgParserBase, self).parse_args(args=args)
+ options = super().parse_args(args=args)
return self._handle_ui_options(options)
def parse_known_ui_args(self, args, withhold=None):
@@ -260,7 +259,7 @@ class ArgParserBase(argparse.ArgumentParser):
"""
if withhold:
args = [a for a in args if a not in withhold]
- options, remaining = super(ArgParserBase, self).parse_known_args(args=args)
+ options, remaining = super().parse_known_args(args=args)
options.remaining = remaining
# Handle common and process group options
return self._handle_ui_options(options)
diff --git a/deluge/bencode.py b/deluge/bencode.py
index f065783e9..b012ca097 100644
--- a/deluge/bencode.py
+++ b/deluge/bencode.py
@@ -84,7 +84,7 @@ def bdecode(x):
return r
-class Bencached(object):
+class Bencached:
__slots__ = ['bencoded']
diff --git a/deluge/common.py b/deluge/common.py
index 0bb085813..509e5c355 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -24,7 +23,7 @@ import tarfile
import time
from contextlib import closing
from datetime import datetime
-from io import BytesIO, open
+from io import BytesIO
from urllib.parse import unquote_plus, urljoin
from urllib.request import pathname2url
@@ -135,14 +134,14 @@ def get_default_download_dir():
try:
user_dirs_path = os.path.join(xdg_config_home, 'user-dirs.dirs')
- with open(user_dirs_path, 'r', encoding='utf8') as _file:
+ with open(user_dirs_path, encoding='utf8') as _file:
for line in _file:
if not line.startswith('#') and line.startswith('XDG_DOWNLOAD_DIR'):
download_dir = os.path.expandvars(
line.partition('=')[2].rstrip().strip('"')
)
break
- except IOError:
+ except OSError:
pass
if not download_dir:
@@ -540,9 +539,9 @@ def fpeer(num_peers, total_peers):
"""
if total_peers > -1:
- return '{:d} ({:d})'.format(num_peers, total_peers)
+ return f'{num_peers:d} ({total_peers:d})'
else:
- return '{:d}'.format(num_peers)
+ return f'{num_peers:d}'
def ftime(secs):
@@ -568,17 +567,17 @@ def ftime(secs):
if secs <= 0:
time_str = ''
elif secs < 60:
- time_str = '{}s'.format(secs)
+ time_str = f'{secs}s'
elif secs < 3600:
- time_str = '{}m {}s'.format(secs // 60, secs % 60)
+ time_str = f'{secs // 60}m {secs % 60}s'
elif secs < 86400:
- time_str = '{}h {}m'.format(secs // 3600, secs // 60 % 60)
+ time_str = f'{secs // 3600}h {secs // 60 % 60}m'
elif secs < 604800:
- time_str = '{}d {}h'.format(secs // 86400, secs // 3600 % 24)
+ time_str = f'{secs // 86400}d {secs // 3600 % 24}h'
elif secs < 31449600:
- time_str = '{}w {}d'.format(secs // 604800, secs // 86400 % 7)
+ time_str = f'{secs // 604800}w {secs // 86400 % 7}d'
else:
- time_str = '{}y {}w'.format(secs // 31449600, secs // 604800 % 52)
+ time_str = f'{secs // 31449600}y {secs // 604800 % 52}w'
return time_str
@@ -934,7 +933,7 @@ def is_ipv4(ip):
return socket.inet_aton(ip)
else:
return socket.inet_pton(socket.AF_INET, ip)
- except socket.error:
+ except OSError:
return False
@@ -960,7 +959,7 @@ def is_ipv6(ip):
try:
return socket.inet_pton(socket.AF_INET6, ip)
- except (socket.error, AttributeError):
+ except (OSError, AttributeError):
if windows_check():
log.warning('Unable to verify IPv6 Address on Windows.')
return True
@@ -1048,7 +1047,7 @@ def utf8_encode_structure(data):
@functools.total_ordering
-class VersionSplit(object):
+class VersionSplit:
"""
Used for comparing version numbers.
@@ -1246,7 +1245,7 @@ def set_env_variable(name, value):
)
# Update the copy maintained by msvcrt (used by gtk+ runtime)
- result = cdll.msvcrt._wputenv('%s=%s' % (name, value))
+ result = cdll.msvcrt._wputenv(f'{name}={value}')
if result != 0:
log.info("Failed to set Env Var '%s' (msvcrt._putenv)", name)
else:
diff --git a/deluge/component.py b/deluge/component.py
index bbbd33b6f..5646e8bd2 100644
--- a/deluge/component.py
+++ b/deluge/component.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
#
@@ -24,13 +23,13 @@ class ComponentAlreadyRegistered(Exception):
class ComponentException(Exception):
def __init__(self, message, tb):
- super(ComponentException, self).__init__(message)
+ super().__init__(message)
self.message = message
self.tb = tb
def __str__(self):
- s = super(ComponentException, self).__str__()
- return '%s\n%s' % (s, ''.join(self.tb))
+ s = super().__str__()
+ return '{}\n{}'.format(s, ''.join(self.tb))
def __eq__(self, other):
if isinstance(other, self.__class__):
@@ -42,7 +41,7 @@ class ComponentException(Exception):
return not self.__eq__(other)
-class Component(object):
+class Component:
"""Component objects are singletons managed by the :class:`ComponentRegistry`.
When a new Component object is instantiated, it will be automatically
@@ -247,7 +246,7 @@ class Component(object):
pass
-class ComponentRegistry(object):
+class ComponentRegistry:
"""The ComponentRegistry holds a list of currently registered :class:`Component` objects.
It is used to manage the Components by starting, stopping, pausing and shutting them down.
diff --git a/deluge/config.py b/deluge/config.py
index 0900e7a36..59225bc01 100644
--- a/deluge/config.py
+++ b/deluge/config.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -45,7 +44,6 @@ import os
import pickle
import shutil
from codecs import getwriter
-from io import open
from tempfile import NamedTemporaryFile
from deluge.common import JSON_FORMAT, get_default_config_dir
@@ -102,7 +100,7 @@ def find_json_objects(text, decoder=json.JSONDecoder()):
return objects
-class Config(object):
+class Config:
"""This class is used to access/create/modify config files.
Args:
@@ -396,9 +394,9 @@ class Config(object):
filename = self.__config_file
try:
- with open(filename, 'r', encoding='utf8') as _file:
+ with open(filename, encoding='utf8') as _file:
data = _file.read()
- except IOError as ex:
+ except OSError as ex:
log.warning('Unable to open config file %s: %s', filename, ex)
return
@@ -451,7 +449,7 @@ class Config(object):
# Check to see if the current config differs from the one on disk
# We will only write a new config file if there is a difference
try:
- with open(filename, 'r', encoding='utf8') as _file:
+ with open(filename, encoding='utf8') as _file:
data = _file.read()
objects = find_json_objects(data)
start, end = objects[0]
@@ -463,7 +461,7 @@ class Config(object):
if self._save_timer and self._save_timer.active():
self._save_timer.cancel()
return True
- except (IOError, IndexError) as ex:
+ except (OSError, IndexError) as ex:
log.warning('Unable to open config file: %s because: %s', filename, ex)
# Save the new config and make sure it's written to disk
@@ -477,7 +475,7 @@ class Config(object):
json.dump(self.__config, getwriter('utf8')(_file), **JSON_FORMAT)
_file.flush()
os.fsync(_file.fileno())
- except IOError as ex:
+ except OSError as ex:
log.error('Error writing new config file: %s', ex)
return False
@@ -488,7 +486,7 @@ class Config(object):
try:
log.debug('Backing up old config file to %s.bak', filename)
shutil.move(filename, filename + '.bak')
- except IOError as ex:
+ except OSError as ex:
log.warning('Unable to backup old config: %s', ex)
# The new config file has been written successfully, so let's move it over
@@ -496,7 +494,7 @@ class Config(object):
try:
log.debug('Moving new config file %s to %s', filename_tmp, filename)
shutil.move(filename_tmp, filename)
- except IOError as ex:
+ except OSError as ex:
log.error('Error moving new config file: %s', ex)
return False
else:
diff --git a/deluge/configmanager.py b/deluge/configmanager.py
index dcd71916a..6e965b863 100644
--- a/deluge/configmanager.py
+++ b/deluge/configmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
@@ -17,7 +16,7 @@ from deluge.config import Config
log = logging.getLogger(__name__)
-class _ConfigManager(object):
+class _ConfigManager:
def __init__(self):
log.debug('ConfigManager started..')
self.config_files = {}
diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py
index 9d5c18ccb..381380a71 100644
--- a/deluge/core/alertmanager.py
+++ b/deluge/core/alertmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/core/authmanager.py b/deluge/core/authmanager.py
index ecb4948b9..8db4902df 100644
--- a/deluge/core/authmanager.py
+++ b/deluge/core/authmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
@@ -11,7 +10,6 @@
import logging
import os
import shutil
-from io import open
import deluge.component as component
import deluge.configmanager as configmanager
@@ -37,7 +35,7 @@ AUTH_LEVELS_MAPPING = {
AUTH_LEVELS_MAPPING_REVERSE = {v: k for k, v in AUTH_LEVELS_MAPPING.items()}
-class Account(object):
+class Account:
__slots__ = ('username', 'password', 'authlevel')
def __init__(self, username, password, authlevel):
@@ -54,10 +52,10 @@ class Account(object):
}
def __repr__(self):
- return '<Account username="%(username)s" authlevel=%(authlevel)s>' % {
- 'username': self.username,
- 'authlevel': self.authlevel,
- }
+ return '<Account username="{username}" authlevel={authlevel}>'.format(
+ username=self.username,
+ authlevel=self.authlevel,
+ )
class AuthManager(component.Component):
@@ -182,7 +180,7 @@ class AuthManager(component.Component):
if os.path.isfile(filepath):
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
shutil.copy2(filepath, filepath_bak)
- except IOError as ex:
+ except OSError as ex:
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
else:
log.info('Saving the %s at: %s', filename, filepath)
@@ -196,7 +194,7 @@ class AuthManager(component.Component):
_file.flush()
os.fsync(_file.fileno())
shutil.move(filepath_tmp, filepath)
- except IOError as ex:
+ except OSError as ex:
log.error('Unable to save %s: %s', filename, ex)
if os.path.isfile(filepath_bak):
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
@@ -225,9 +223,9 @@ class AuthManager(component.Component):
for _filepath in (auth_file, auth_file_bak):
log.info('Opening %s for load: %s', filename, _filepath)
try:
- with open(_filepath, 'r', encoding='utf8') as _file:
+ with open(_filepath, encoding='utf8') as _file:
file_data = _file.readlines()
- except IOError as ex:
+ except OSError as ex:
log.warning('Unable to load %s: %s', _filepath, ex)
file_data = []
else:
diff --git a/deluge/core/core.py b/deluge/core/core.py
index acd3a0b47..4fa75a414 100644
--- a/deluge/core/core.py
+++ b/deluge/core/core.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
@@ -112,7 +111,7 @@ class Core(component.Component):
component.Component.__init__(self, 'Core')
# Start the libtorrent session.
- user_agent = 'Deluge/{} libtorrent/{}'.format(DELUGE_VER, LT_VERSION)
+ user_agent = f'Deluge/{DELUGE_VER} libtorrent/{LT_VERSION}'
peer_id = self._create_peer_id(DELUGE_VER)
log.debug('Starting session (peer_id: %s, user_agent: %s)', peer_id, user_agent)
settings_pack = {
@@ -293,7 +292,7 @@ class Core(component.Component):
if os.path.isfile(filepath):
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
shutil.copy2(filepath, filepath_bak)
- except IOError as ex:
+ except OSError as ex:
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
else:
log.info('Saving the %s at: %s', filename, filepath)
@@ -303,7 +302,7 @@ class Core(component.Component):
_file.flush()
os.fsync(_file.fileno())
shutil.move(filepath_tmp, filepath)
- except (IOError, EOFError) as ex:
+ except (OSError, EOFError) as ex:
log.error('Unable to save %s: %s', filename, ex)
if os.path.isfile(filepath_bak):
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
@@ -325,7 +324,7 @@ class Core(component.Component):
try:
with open(_filepath, 'rb') as _file:
state = lt.bdecode(_file.read())
- except (IOError, EOFError, RuntimeError) as ex:
+ except (OSError, EOFError, RuntimeError) as ex:
log.warning('Unable to load %s: %s', _filepath, ex)
else:
log.info('Successfully loaded %s: %s', filename, _filepath)
diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py
index 269558928..0185dd8cb 100644
--- a/deluge/core/daemon.py
+++ b/deluge/core/daemon.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -42,8 +41,8 @@ def is_daemon_running(pid_file):
try:
with open(pid_file) as _file:
- pid, port = [int(x) for x in _file.readline().strip().split(';')]
- except (EnvironmentError, ValueError):
+ pid, port = (int(x) for x in _file.readline().strip().split(';'))
+ except (OSError, ValueError):
return False
if is_process_running(pid):
@@ -51,7 +50,7 @@ def is_daemon_running(pid_file):
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
_socket.connect(('127.0.0.1', port))
- except socket.error:
+ except OSError:
# Can't connect, so pid is not a deluged process.
return False
else:
@@ -60,7 +59,7 @@ def is_daemon_running(pid_file):
return True
-class Daemon(object):
+class Daemon:
"""The Deluge Daemon class"""
def __init__(
@@ -154,7 +153,7 @@ class Daemon(object):
pid = os.getpid()
log.debug('Storing pid %s & port %s in: %s', pid, self.port, self.pid_file)
with open(self.pid_file, 'w') as _file:
- _file.write('%s;%s\n' % (pid, self.port))
+ _file.write(f'{pid};{self.port}\n')
component.start()
diff --git a/deluge/core/daemon_entry.py b/deluge/core/daemon_entry.py
index 33304fd08..c49fd2a35 100644
--- a/deluge/core/daemon_entry.py
+++ b/deluge/core/daemon_entry.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
diff --git a/deluge/core/eventmanager.py b/deluge/core/eventmanager.py
index da60ac7e3..d43847a77 100644
--- a/deluge/core/eventmanager.py
+++ b/deluge/core/eventmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py
index c4f342097..a60cc5bc4 100644
--- a/deluge/core/filtermanager.py
+++ b/deluge/core/filtermanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
#
diff --git a/deluge/core/pluginmanager.py b/deluge/core/pluginmanager.py
index 74b7d0039..0482b16e7 100644
--- a/deluge/core/pluginmanager.py
+++ b/deluge/core/pluginmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py
index f3d104103..42e4eb6f2 100644
--- a/deluge/core/preferencesmanager.py
+++ b/deluge/core/preferencesmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2010 Andrew Resch <andrewresch@gmail.com>
#
@@ -218,7 +217,7 @@ class PreferencesManager(component.Component):
self.config['listen_use_sys_port'],
)
interfaces = [
- '%s:%s' % (interface, port)
+ f'{interface}:{port}'
for port in range(listen_ports[0], listen_ports[1] + 1)
]
self.core.apply_session_settings(
@@ -393,7 +392,7 @@ class PreferencesManager(component.Component):
+ quote_plus(':'.join(self.config['enabled_plugins']))
)
urlopen(url)
- except IOError as ex:
+ except OSError as ex:
log.debug('Network error while trying to send info: %s', ex)
else:
self.config['info_sent'] = now
diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py
index db570d175..104399df9 100644
--- a/deluge/core/rpcserver.py
+++ b/deluge/core/rpcserver.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008,2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -65,7 +64,7 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
if func.__doc__:
if func.__doc__.endswith(' '):
indent = func.__doc__.split('\n')[-1]
- func.__doc__ += '\n{}'.format(indent)
+ func.__doc__ += f'\n{indent}'
else:
func.__doc__ += '\n\n'
func.__doc__ += rpc_text
@@ -110,7 +109,7 @@ def format_request(call):
class DelugeRPCProtocol(DelugeTransferProtocol):
def __init__(self):
- super(DelugeRPCProtocol, self).__init__()
+ super().__init__()
# namedtuple subclass with auth_level, username for the connected session.
self.AuthLevel = namedtuple('SessionAuthlevel', 'auth_level, username')
diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index ee3669338..bae962770 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -148,7 +147,7 @@ class TorrentOptions(dict):
"""
def __init__(self):
- super(TorrentOptions, self).__init__()
+ super().__init__()
config = ConfigManager('core.conf').config
options_conf_map = {
'add_paused': 'add_paused',
@@ -178,14 +177,14 @@ class TorrentOptions(dict):
self['seed_mode'] = False
-class TorrentError(object):
+class TorrentError:
def __init__(self, error_message, was_paused=False, restart_to_resume=False):
self.error_message = error_message
self.was_paused = was_paused
self.restart_to_resume = restart_to_resume
-class Torrent(object):
+class Torrent:
"""Torrent holds information about torrents added to the libtorrent session.
Args:
@@ -825,7 +824,7 @@ class Torrent(object):
'client': client,
'country': country,
'down_speed': peer.payload_down_speed,
- 'ip': '%s:%s' % (peer.ip[0], peer.ip[1]),
+ 'ip': f'{peer.ip[0]}:{peer.ip[1]}',
'progress': peer.progress,
'seed': peer.flags & peer.seed,
'up_speed': peer.payload_up_speed,
@@ -897,7 +896,7 @@ class Torrent(object):
# Check if hostname is an IP address and just return it if that's the case
try:
socket.inet_aton(host)
- except socket.error:
+ except OSError:
pass
else:
# This is an IP address because an exception wasn't raised
@@ -1292,7 +1291,7 @@ class Torrent(object):
try:
with open(filepath, 'wb') as save_file:
save_file.write(filedump)
- except IOError as ex:
+ except OSError as ex:
log.error('Unable to save torrent file to: %s', ex)
filepath = os.path.join(get_config_dir(), 'state', self.torrent_id + '.torrent')
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index 84d147a49..1a12fbc9f 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -819,8 +818,8 @@ class TorrentManager(component.Component):
try:
with open(filepath, 'rb') as _file:
state = pickle.load(_file, encoding='utf8')
- except (IOError, EOFError, pickle.UnpicklingError) as ex:
- message = 'Unable to load {}: {}'.format(filepath, ex)
+ except (OSError, EOFError, pickle.UnpicklingError) as ex:
+ message = f'Unable to load {filepath}: {ex}'
log.error(message)
if not filepath.endswith('.bak'):
self.archive_state(message)
@@ -1076,7 +1075,7 @@ class TorrentManager(component.Component):
try:
with open(_filepath, 'rb') as _file:
resume_data = lt.bdecode(_file.read())
- except (IOError, EOFError, RuntimeError) as ex:
+ except (OSError, EOFError, RuntimeError) as ex:
if self.torrents:
log.warning('Unable to load %s: %s', _filepath, ex)
resume_data = None
diff --git a/deluge/crypto_utils.py b/deluge/crypto_utils.py
index 840a24533..d636c05e7 100644
--- a/deluge/crypto_utils.py
+++ b/deluge/crypto_utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/decorators.py b/deluge/decorators.py
index 0c66572f0..8ca8b805d 100644
--- a/deluge/decorators.py
+++ b/deluge/decorators.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
#
@@ -125,7 +124,7 @@ def _overrides(stack, method, explicit_base_classes=None):
% (
method.__name__,
cls,
- 'File: %s:%s' % (stack[1][1], stack[1][2]),
+ f'File: {stack[1][1]}:{stack[1][2]}',
)
)
@@ -135,7 +134,7 @@ def _overrides(stack, method, explicit_base_classes=None):
% (
method.__name__,
check_classes,
- 'File: %s:%s' % (stack[1][1], stack[1][2]),
+ f'File: {stack[1][1]}:{stack[1][2]}',
)
)
return method
@@ -152,7 +151,7 @@ def deprecated(func):
def depr_func(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning) # Turn off filter
warnings.warn(
- 'Call to deprecated function {}.'.format(func.__name__),
+ f'Call to deprecated function {func.__name__}.',
category=DeprecationWarning,
stacklevel=2,
)
diff --git a/deluge/error.py b/deluge/error.py
index ba8529452..d542dc2c0 100644
--- a/deluge/error.py
+++ b/deluge/error.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
@@ -11,13 +10,13 @@
class DelugeError(Exception):
def __new__(cls, *args, **kwargs):
- inst = super(DelugeError, cls).__new__(cls, *args, **kwargs)
+ inst = super().__new__(cls, *args, **kwargs)
inst._args = args
inst._kwargs = kwargs
return inst
def __init__(self, message=None):
- super(DelugeError, self).__init__(message)
+ super().__init__(message)
self.message = message
def __str__(self):
@@ -42,12 +41,12 @@ class InvalidPathError(DelugeError):
class WrappedException(DelugeError):
def __init__(self, message, exception_type, traceback):
- super(WrappedException, self).__init__(message)
+ super().__init__(message)
self.type = exception_type
self.traceback = traceback
def __str__(self):
- return '%s\n%s' % (self.message, self.traceback)
+ return f'{self.message}\n{self.traceback}'
class _ClientSideRecreateError(DelugeError):
@@ -61,7 +60,7 @@ class IncompatibleClient(_ClientSideRecreateError):
'Your deluge client is not compatible with the daemon. '
'Please upgrade your client to %(daemon_version)s'
) % {'daemon_version': self.daemon_version}
- super(IncompatibleClient, self).__init__(message=msg)
+ super().__init__(message=msg)
class NotAuthorizedError(_ClientSideRecreateError):
@@ -70,14 +69,14 @@ class NotAuthorizedError(_ClientSideRecreateError):
'current_level': current_level,
'required_level': required_level,
}
- super(NotAuthorizedError, self).__init__(message=msg)
+ super().__init__(message=msg)
self.current_level = current_level
self.required_level = required_level
class _UsernameBasedPasstroughError(_ClientSideRecreateError):
def __init__(self, message, username):
- super(_UsernameBasedPasstroughError, self).__init__(message)
+ super().__init__(message)
self.username = username
diff --git a/deluge/event.py b/deluge/event.py
index a90707060..38fc32ff8 100644
--- a/deluge/event.py
+++ b/deluge/event.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -23,7 +22,7 @@ class DelugeEventMetaClass(type):
"""
def __init__(cls, name, bases, dct): # pylint: disable=bad-mcs-method-argument
- super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
+ super().__init__(name, bases, dct)
if name != 'DelugeEvent':
known_events[name] = cls
diff --git a/deluge/httpdownloader.py b/deluge/httpdownloader.py
index da7bf3a16..43b32b6b9 100644
--- a/deluge/httpdownloader.py
+++ b/deluge/httpdownloader.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -38,11 +37,11 @@ class CompressionDecoderProtocol(client._GzipProtocol):
"""A compression decoder protocol for CompressionDecoder."""
def __init__(self, protocol, response):
- super(CompressionDecoderProtocol, self).__init__(protocol, response)
+ super().__init__(protocol, response)
self._zlibDecompress = zlib.decompressobj(32 + zlib.MAX_WBITS)
-class BodyHandler(HTTPClientParser, object):
+class BodyHandler(HTTPClientParser):
"""An HTTP parser that saves the response to a file."""
def __init__(self, request, finished, length, agent, encoding=None):
@@ -54,7 +53,7 @@ class BodyHandler(HTTPClientParser, object):
length (int): The length of the response.
agent (t.w.i.IAgent): The agent from which the request was sent.
"""
- super(BodyHandler, self).__init__(request, finished)
+ super().__init__(request, finished)
self.agent = agent
self.finished = finished
self.total_length = length
@@ -74,12 +73,12 @@ class BodyHandler(HTTPClientParser, object):
with open(self.agent.filename, 'wb') as _file:
_file.write(self.data)
self.finished.callback(self.agent.filename)
- self.state = u'DONE'
+ self.state = 'DONE'
HTTPClientParser.connectionLost(self, reason)
@implementer(IAgent)
-class HTTPDownloaderAgent(object):
+class HTTPDownloaderAgent:
"""A File Downloader Agent."""
def __init__(
@@ -144,7 +143,7 @@ class HTTPDownloaderAgent(object):
fileext = os.path.splitext(new_file_name)[1]
while os.path.isfile(new_file_name):
# Increment filename if already exists
- new_file_name = '%s-%s%s' % (fileroot, count, fileext)
+ new_file_name = f'{fileroot}-{count}{fileext}'
count += 1
self.filename = new_file_name
diff --git a/deluge/i18n/languages.py b/deluge/i18n/languages.py
index 5f7defc80..5673c7116 100644
--- a/deluge/i18n/languages.py
+++ b/deluge/i18n/languages.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# This file is public domain.
#
diff --git a/deluge/i18n/util.py b/deluge/i18n/util.py
index 897f412f2..3741c365c 100644
--- a/deluge/i18n/util.py
+++ b/deluge/i18n/util.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -77,7 +76,7 @@ def set_language(lang):
translation = gettext.translation(
'deluge', localedir=get_translations_path(), languages=[lang]
)
- except IOError:
+ except OSError:
log.warning('Unable to find translation (.mo) to set language: %s', lang)
else:
translation.install()
diff --git a/deluge/log.py b/deluge/log.py
index 868be4593..265186e7e 100644
--- a/deluge/log.py
+++ b/deluge/log.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
@@ -37,7 +36,7 @@ MAX_LOGGER_NAME_LENGTH = 10
class Logging(LoggingLoggerClass):
def __init__(self, logger_name):
- super(Logging, self).__init__(logger_name)
+ super().__init__(logger_name)
# This makes module name padding increase to the biggest module name
# so that logs keep readability.
@@ -238,7 +237,7 @@ def tweak_logging_levels():
log.warning(
'logging.conf found! tweaking logging levels from %s', logging_config_file
)
- with open(logging_config_file, 'r') as _file:
+ with open(logging_config_file) as _file:
for line in _file:
if line.strip().startswith('#'):
continue
@@ -309,7 +308,7 @@ Triggering code:
"""
-class _BackwardsCompatibleLOG(object):
+class _BackwardsCompatibleLOG:
def __getattribute__(self, name):
import warnings
diff --git a/deluge/maketorrent.py b/deluge/maketorrent.py
index 0a4eb93c9..c0051cae0 100644
--- a/deluge/maketorrent.py
+++ b/deluge/maketorrent.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -30,7 +29,7 @@ class InvalidPieceSize(Exception):
pass
-class TorrentMetadata(object):
+class TorrentMetadata:
"""This class is used to create .torrent files.
Examples:
diff --git a/deluge/metafile.py b/deluge/metafile.py
index b39da11b1..cd6545a75 100644
--- a/deluge/metafile.py
+++ b/deluge/metafile.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Original file from BitTorrent-5.3-GPL.tar.gz
# Copyright (C) Bram Cohen
@@ -42,7 +41,7 @@ def dummy(*v):
pass
-class RemoteFileProgress(object):
+class RemoteFileProgress:
def __init__(self, session_id):
self.session_id = session_id
diff --git a/deluge/path_chooser_common.py b/deluge/path_chooser_common.py
index 002a6e80a..858f7c2da 100644
--- a/deluge/path_chooser_common.py
+++ b/deluge/path_chooser_common.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 Bro <bro.development@gmail.com>
#
diff --git a/deluge/pluginmanagerbase.py b/deluge/pluginmanagerbase.py
index da016ed66..0bf217264 100644
--- a/deluge/pluginmanagerbase.py
+++ b/deluge/pluginmanagerbase.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
@@ -45,7 +44,7 @@ git repository to have an idea of what needs to be changed.
"""
-class PluginManagerBase(object):
+class PluginManagerBase:
"""PluginManagerBase is a base class for PluginManagers to inherit"""
def __init__(self, config_file, entry_name):
diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py b/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py
index ec98d8848..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>
#
@@ -20,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):
@@ -28,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):
@@ -36,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 f6783de42..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>
diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py
index 33f5350f3..ed6a0323b 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>
@@ -150,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
@@ -167,9 +166,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:
@@ -194,7 +193,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
@@ -269,7 +268,7 @@ class Core(CorePluginBase):
try:
filedump = self.load_torrent(filepath, magnet)
- except (IOError, EOFError) as ex:
+ except (OSError, EOFError) 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/gtkui.py b/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py
index 969a1638f..fc9954ce0 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>
#
@@ -39,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 = [
diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/webui.py b/deluge/plugins/AutoAdd/deluge_autoadd/webui.py
index 41dc4d80e..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>
#
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 80775cc1d..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>
#
@@ -15,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):
@@ -23,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):
@@ -31,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 b45de94b0..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>
@@ -71,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
@@ -83,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):
@@ -106,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:
@@ -166,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 53e36705d..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>
diff --git a/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py
index 4a0f0a05e..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>
#
diff --git a/deluge/plugins/Blocklist/deluge_blocklist/detect.py b/deluge/plugins/Blocklist/deluge_blocklist/detect.py
index 5d7858d68..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>
#
diff --git a/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py b/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py
index 215c71231..5444107d0 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>
#
diff --git a/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py b/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py
index f5389016f..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)
#
@@ -21,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
diff --git a/deluge/plugins/Blocklist/deluge_blocklist/readers.py b/deluge/plugins/Blocklist/deluge_blocklist/readers.py
index 6eda027a8..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>
#
@@ -21,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 7d7b0c846..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>
#
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 d515d4911..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>
#
@@ -15,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):
@@ -23,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):
@@ -31,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 28233e984..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>
diff --git a/deluge/plugins/Execute/deluge_execute/core.py b/deluge/plugins/Execute/deluge_execute/core.py
index 388e47eb7..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>
#
diff --git a/deluge/plugins/Execute/deluge_execute/gtkui.py b/deluge/plugins/Execute/deluge_execute/gtkui.py
index 15d735cbd..73bd8cf94 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>
#
@@ -39,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 de337e73c..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>
#
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 63e88bd47..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>
#
@@ -19,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):
@@ -27,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):
@@ -35,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 28233e984..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>
diff --git a/deluge/plugins/Extractor/deluge_extractor/core.py b/deluge/plugins/Extractor/deluge_extractor/core.py
index 54440e446..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>
#
@@ -39,7 +38,7 @@ if windows_check():
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/gtkui.py b/deluge/plugins/Extractor/deluge_extractor/gtkui.py
index 5536a0e28..cc53e95ca 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>
#
diff --git a/deluge/plugins/Extractor/deluge_extractor/webui.py b/deluge/plugins/Extractor/deluge_extractor/webui.py
index eaab79a74..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>
#
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 fea7dcdcd..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>
#
@@ -19,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):
@@ -27,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):
@@ -35,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 28233e984..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>
diff --git a/deluge/plugins/Label/deluge_label/core.py b/deluge/plugins/Label/deluge_label/core.py
index d4200f618..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>
#
diff --git a/deluge/plugins/Label/deluge_label/gtkui/__init__.py b/deluge/plugins/Label/deluge_label/gtkui/__init__.py
index 88c470d4d..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>
#
diff --git a/deluge/plugins/Label/deluge_label/gtkui/label_config.py b/deluge/plugins/Label/deluge_label/gtkui/label_config.py
index 6edf4ddeb..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>
#
@@ -18,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 499175bfd..c65995288 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>
@@ -30,7 +29,7 @@ NO_LABEL = 'No Label'
# menu
-class LabelSidebarMenu(object):
+class LabelSidebarMenu:
def __init__(self):
self.treeview = component.get('FilterTreeView')
@@ -105,7 +104,7 @@ class LabelSidebarMenu(object):
# dialogs:
-class AddDialog(object):
+class AddDialog:
def __init__(self):
pass
@@ -127,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 = [
@@ -172,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 f41b8457d..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>
#
diff --git a/deluge/plugins/Label/deluge_label/test.py b/deluge/plugins/Label/deluge_label/test.py
index 00d052bfa..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 -*-
#
diff --git a/deluge/plugins/Label/deluge_label/webui.py b/deluge/plugins/Label/deluge_label/webui.py
index cc044e932..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>
#
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 c3001088f..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>
#
@@ -20,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):
@@ -28,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):
@@ -36,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 2361862dd..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>
#
@@ -28,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 5f4ab7afe..d48d449ba 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>
#
diff --git a/deluge/plugins/Notifications/deluge_notifications/gtkui.py b/deluge/plugins/Notifications/deluge_notifications/gtkui.py
index 96146f939..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>
#
diff --git a/deluge/plugins/Notifications/deluge_notifications/test.py b/deluge/plugins/Notifications/deluge_notifications/test.py
index 16dbbf18d..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>
@@ -68,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 9ce1b0012..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>
#
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 63e88bd47..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>
#
@@ -19,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):
@@ -27,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):
@@ -35,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 28233e984..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>
diff --git a/deluge/plugins/Scheduler/deluge_scheduler/core.py b/deluge/plugins/Scheduler/deluge_scheduler/core.py
index 008afbcd4..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>
#
diff --git a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py
index 3b768eb48..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>
#
@@ -28,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 daf5b9955..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>
#
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 a7ec1b701..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>
#
@@ -19,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):
@@ -27,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):
@@ -35,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 28233e984..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>
diff --git a/deluge/plugins/Stats/deluge_stats/core.py b/deluge/plugins/Stats/deluge_stats/core.py
index 148a4033a..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>
diff --git a/deluge/plugins/Stats/deluge_stats/graph.py b/deluge/plugins/Stats/deluge_stats/graph.py
index eb54dbd5f..7589a31c8 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>
@@ -60,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
@@ -176,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 e207c0471..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>
@@ -83,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'))
@@ -268,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:
@@ -283,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 7b2c2fbff..f40497b15 100644
--- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
+++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -88,7 +87,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 9e7e6992d..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>
#
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 13fa017ef..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>
#
@@ -20,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):
@@ -28,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):
@@ -36,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 28233e984..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>
diff --git a/deluge/plugins/Toggle/deluge_toggle/core.py b/deluge/plugins/Toggle/deluge_toggle/core.py
index 77727e451..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>
#
diff --git a/deluge/plugins/Toggle/deluge_toggle/gtkui.py b/deluge/plugins/Toggle/deluge_toggle/gtkui.py
index f9d8cf917..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>
#
diff --git a/deluge/plugins/Toggle/deluge_toggle/webui.py b/deluge/plugins/Toggle/deluge_toggle/webui.py
index c46af6d65..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>
#
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 5b9aec38b..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>
#
@@ -19,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):
@@ -27,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):
@@ -35,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 28233e984..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>
diff --git a/deluge/plugins/WebUi/deluge_webui/core.py b/deluge/plugins/WebUi/deluge_webui/core.py
index bf6b62e37..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>
#
diff --git a/deluge/plugins/WebUi/deluge_webui/gtkui.py b/deluge/plugins/WebUi/deluge_webui/gtkui.py
index 8092ff78c..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>
#
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 a5fb92315..260d18daa 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>
#
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 28b1efbc1..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>
#
@@ -15,7 +14,7 @@ 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 6b08c27dc..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>
#
@@ -19,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!')
@@ -30,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..')
@@ -39,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):
@@ -66,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())
diff --git a/deluge/scripts/deluge_remote.py b/deluge/scripts/deluge_remote.py
index 174254329..d983e5398 100644
--- a/deluge/scripts/deluge_remote.py
+++ b/deluge/scripts/deluge_remote.py
@@ -1,5 +1,4 @@
#!/usr/bin/python
-# -*- coding: utf-8 -*-
#
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
diff --git a/deluge/tests/basetest.py b/deluge/tests/basetest.py
index ac6514156..f51a93068 100644
--- a/deluge/tests/basetest.py
+++ b/deluge/tests/basetest.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/common.py b/deluge/tests/common.py
index 170a2a288..ce5d83656 100644
--- a/deluge/tests/common.py
+++ b/deluge/tests/common.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -53,7 +52,7 @@ def todo_test(caller):
filename = os.path.basename(traceback.extract_stack(None, 2)[0][0])
funcname = traceback.extract_stack(None, 2)[0][2]
- raise unittest.SkipTest('TODO: %s:%s' % (filename, funcname))
+ raise unittest.SkipTest(f'TODO: {filename}:{funcname}')
def add_watchdog(deferred, timeout=0.05, message=None):
@@ -71,7 +70,7 @@ def add_watchdog(deferred, timeout=0.05, message=None):
return watchdog
-class ReactorOverride(object):
+class ReactorOverride:
"""Class used to patch reactor while running unit tests
to avoid starting and stopping the twisted reactor
"""
diff --git a/deluge/tests/common_web.py b/deluge/tests/common_web.py
index f2b82aad5..5a7f40fc6 100644
--- a/deluge/tests/common_web.py
+++ b/deluge/tests/common_web.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -54,7 +53,7 @@ class WebServerTestBase(BaseTestCase, DaemonBase):
return d
-class WebServerMockBase(object):
+class WebServerMockBase:
"""
Class with utility functions for mocking with tests using the webserver
diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py
index 92ccf0c62..badc93768 100644
--- a/deluge/tests/daemon_base.py
+++ b/deluge/tests/daemon_base.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -18,7 +17,7 @@ from . import common
@pytest.mark.usefixtures('get_pytest_basetemp')
-class DaemonBase(object):
+class DaemonBase:
basetemp = None
if windows_check():
diff --git a/deluge/tests/test_alertmanager.py b/deluge/tests/test_alertmanager.py
index b9dfce5a8..85512d47b 100644
--- a/deluge/tests/test_alertmanager.py
+++ b/deluge/tests/test_alertmanager.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_authmanager.py b/deluge/tests/test_authmanager.py
index 31a79a857..cee399890 100644
--- a/deluge/tests/test_authmanager.py
+++ b/deluge/tests/test_authmanager.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_bencode.py b/deluge/tests/test_bencode.py
index 420869139..05c6814b2 100644
--- a/deluge/tests/test_bencode.py
+++ b/deluge/tests/test_bencode.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_client.py b/deluge/tests/test_client.py
index bccbdd5e0..901bb85b0 100644
--- a/deluge/tests/test_client.py
+++ b/deluge/tests/test_client.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_common.py b/deluge/tests/test_common.py
index 7459997de..ccb468cb9 100644
--- a/deluge/tests/test_common.py
+++ b/deluge/tests/test_common.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_component.py b/deluge/tests/test_component.py
index 5bdb16589..37cee03eb 100644
--- a/deluge/tests/test_component.py
+++ b/deluge/tests/test_component.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_config.py b/deluge/tests/test_config.py
index a514ebcf5..e8a267185 100644
--- a/deluge/tests/test_config.py
+++ b/deluge/tests/test_config.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py
index 5e5815ca0..f33f60c4c 100644
--- a/deluge/tests/test_core.py
+++ b/deluge/tests/test_core.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_decorators.py b/deluge/tests/test_decorators.py
index 405a4ffc8..fc279f05f 100644
--- a/deluge/tests/test_decorators.py
+++ b/deluge/tests/test_decorators.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -33,7 +32,7 @@ class DecoratorsTestCase(unittest.TestCase):
def negate(func, *args, **kwargs):
return -func(*args, **kwargs)
- class Test(object):
+ class Test:
def __init__(self, number):
self.number = number
diff --git a/deluge/tests/test_error.py b/deluge/tests/test_error.py
index 29f19c429..1c2ff5f4b 100644
--- a/deluge/tests/test_error.py
+++ b/deluge/tests/test_error.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_files_tab.py b/deluge/tests/test_files_tab.py
index 108c4db0d..54664e093 100644
--- a/deluge/tests/test_files_tab.py
+++ b/deluge/tests/test_files_tab.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -51,7 +50,7 @@ class FilesTabTestCase(BaseTestCase):
level = 1
def p_level(s, l):
- print('%s%s' % (' ' * l, s))
+ print('{}{}'.format(' ' * l, s))
def _print_treestore_children(i, lvl):
while i:
diff --git a/deluge/tests/test_httpdownloader.py b/deluge/tests/test_httpdownloader.py
index 649c43cab..69291fc7b 100644
--- a/deluge/tests/test_httpdownloader.py
+++ b/deluge/tests/test_httpdownloader.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -8,7 +7,6 @@
import os
import tempfile
from email.utils import formatdate
-from io import open
from twisted.internet import reactor
from twisted.internet.error import CannotListenError
@@ -69,7 +67,7 @@ class TorrentResource(Resource):
content_type += b'; charset=' + charset
request.setHeader(b'Content-Type', content_type)
request.setHeader(b'Content-Disposition', b'attachment; filename=test.torrent')
- return 'Binary attachment ignore charset 世丕且\n'.encode('utf8')
+ return 'Binary attachment ignore charset 世丕且\n'.encode()
class CookieResource(Resource):
@@ -160,7 +158,7 @@ class DownloadFileTestCase(unittest.TestCase):
return self.webserver.stopListening()
def assertContains(self, filename, contents): # NOQA
- with open(filename, 'r', encoding='utf8') as _file:
+ with open(filename, encoding='utf8') as _file:
try:
self.assertEqual(_file.read(), contents)
except Exception as ex:
@@ -168,7 +166,7 @@ class DownloadFileTestCase(unittest.TestCase):
return filename
def assertNotContains(self, filename, contents, file_mode=''): # NOQA
- with open(filename, 'r', encoding='utf8') as _file:
+ with open(filename, encoding='utf8') as _file:
try:
self.assertNotEqual(_file.read(), contents)
except Exception as ex:
diff --git a/deluge/tests/test_json_api.py b/deluge/tests/test_json_api.py
index 0e933e89e..765eb0e0b 100644
--- a/deluge/tests/test_json_api.py
+++ b/deluge/tests/test_json_api.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -8,8 +7,8 @@
#
import json as json_lib
+from unittest.mock import MagicMock
-from mock import MagicMock
from twisted.internet import defer
from twisted.web import server
from twisted.web.http import Request
diff --git a/deluge/tests/test_log.py b/deluge/tests/test_log.py
index d5e1fdb53..424fd4720 100644
--- a/deluge/tests/test_log.py
+++ b/deluge/tests/test_log.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Calum Lind <calumlind@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <ufs@ufsoft.org>
diff --git a/deluge/tests/test_maketorrent.py b/deluge/tests/test_maketorrent.py
index ffab14b82..90ca61a3c 100644
--- a/deluge/tests/test_maketorrent.py
+++ b/deluge/tests/test_maketorrent.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_metafile.py b/deluge/tests/test_metafile.py
index d3099c692..af8f72d40 100644
--- a/deluge/tests/test_metafile.py
+++ b/deluge/tests/test_metafile.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_plugin_metadata.py b/deluge/tests/test_plugin_metadata.py
index e7c14b591..341839e22 100644
--- a/deluge/tests/test_plugin_metadata.py
+++ b/deluge/tests/test_plugin_metadata.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Calum Lind <calumlind@gmail.com>
#
@@ -21,7 +20,7 @@ class PluginManagerBaseTestCase(BaseTestCase):
pm = PluginManagerBase('core.conf', 'deluge.plugin.core')
for p in pm.get_available_plugins():
for key, value in pm.get_plugin_info(p).items():
- self.assertTrue(isinstance('%s: %s' % (key, value), ''.__class__))
+ self.assertTrue(isinstance(f'{key}: {value}', ''.__class__))
def test_get_plugin_info_invalid_name(self):
pm = PluginManagerBase('core.conf', 'deluge.plugin.core')
diff --git a/deluge/tests/test_rpcserver.py b/deluge/tests/test_rpcserver.py
index 59d84304a..ab0844038 100644
--- a/deluge/tests/test_rpcserver.py
+++ b/deluge/tests/test_rpcserver.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 Bro <bro.development@gmail.com>
#
diff --git a/deluge/tests/test_security.py b/deluge/tests/test_security.py
index 6154d32d8..6fac802e8 100644
--- a/deluge/tests/test_security.py
+++ b/deluge/tests/test_security.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -24,7 +23,7 @@ from .daemon_base import DaemonBase
SECURITY_TESTS = bool(os.getenv('SECURITY_TESTS', False))
-class SecurityBaseTestCase(object):
+class SecurityBaseTestCase:
if windows_check():
skip = 'windows cannot run .sh files'
elif not SECURITY_TESTS:
@@ -134,7 +133,7 @@ class DaemonSecurityTestCase(BaseTestCase, DaemonBase, SecurityBaseTestCase):
skip = 'windows cannot start_core not enough arguments for format string'
def __init__(self, testname):
- super(DaemonSecurityTestCase, self).__init__(testname)
+ super().__init__(testname)
DaemonBase.__init__(self)
SecurityBaseTestCase.__init__(self)
@@ -145,7 +144,7 @@ class DaemonSecurityTestCase(BaseTestCase, DaemonBase, SecurityBaseTestCase):
self.skipTest(SecurityBaseTestCase.http_err)
skip = True
if not skip:
- super(DaemonSecurityTestCase, self).setUp()
+ super().setUp()
def set_up(self):
d = self.common_set_up()
@@ -163,7 +162,7 @@ class DaemonSecurityTestCase(BaseTestCase, DaemonBase, SecurityBaseTestCase):
@pytest.mark.security
class WebUISecurityTestBase(WebServerTestBase, SecurityBaseTestCase):
def __init__(self, testname):
- super(WebUISecurityTestBase, self).__init__(testname)
+ super().__init__(testname)
SecurityBaseTestCase.__init__(self)
def start_webapi(self, arg):
diff --git a/deluge/tests/test_sessionproxy.py b/deluge/tests/test_sessionproxy.py
index 88400342b..f73e522f1 100644
--- a/deluge/tests/test_sessionproxy.py
+++ b/deluge/tests/test_sessionproxy.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -16,7 +15,7 @@ import deluge.ui.sessionproxy
from .basetest import BaseTestCase
-class Core(object):
+class Core:
def __init__(self):
self.reset()
@@ -89,7 +88,7 @@ class Core(object):
return succeed(ret)
-class Client(object):
+class Client:
def __init__(self):
self.core = Core()
diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py
index c8372f5c1..8d22403fc 100644
--- a/deluge/tests/test_torrent.py
+++ b/deluge/tests/test_torrent.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -8,8 +7,8 @@
import os
import time
from base64 import b64encode
+from unittest import mock
-import mock
from twisted.internet import defer, reactor
from twisted.internet.task import deferLater
from twisted.trial import unittest
diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py
index 1be5ba3ac..d719889ba 100644
--- a/deluge/tests/test_torrentmanager.py
+++ b/deluge/tests/test_torrentmanager.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -9,8 +8,8 @@ import os
import shutil
import warnings
from base64 import b64encode
+from unittest import mock
-import mock
import pytest
from twisted.internet import defer, task
from twisted.trial import unittest
diff --git a/deluge/tests/test_torrentview.py b/deluge/tests/test_torrentview.py
index 1153e968f..72995f6e2 100644
--- a/deluge/tests/test_torrentview.py
+++ b/deluge/tests/test_torrentview.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Bro <bro.development@gmail.com>
# Copyright (C) 2014 Calum Lind <calumlind@gmail.com>
diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py
index 0f7a66c61..c8e2f32d9 100644
--- a/deluge/tests/test_tracker_icons.py
+++ b/deluge/tests/test_tracker_icons.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/tests/test_transfer.py b/deluge/tests/test_transfer.py
index f38833f77..a67e0da03 100644
--- a/deluge/tests/test_transfer.py
+++ b/deluge/tests/test_transfer.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Bro <bro.development@gmail.com>
#
diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py
index d9df0f4d3..809abbd8e 100644
--- a/deluge/tests/test_ui_common.py
+++ b/deluge/tests/test_ui_common.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
diff --git a/deluge/tests/test_ui_console.py b/deluge/tests/test_ui_console.py
index eacf170da..201feee70 100644
--- a/deluge/tests/test_ui_console.py
+++ b/deluge/tests/test_ui_console.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -14,7 +13,7 @@ from deluge.ui.console.widgets.fields import TextInput
from .basetest import BaseTestCase
-class MockParent(object):
+class MockParent:
def __init__(self):
self.border_off_x = 1
self.pane_width = 20
diff --git a/deluge/tests/test_ui_entry.py b/deluge/tests/test_ui_entry.py
index 0699dabc6..a01653bb1 100644
--- a/deluge/tests/test_ui_entry.py
+++ b/deluge/tests/test_ui_entry.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -10,8 +9,8 @@
import argparse
import sys
from io import StringIO
+from unittest import mock
-import mock
import pytest
from twisted.internet import defer
@@ -39,7 +38,7 @@ sys_stdout = sys.stdout
# To print to terminal from the tests, use: print('Message...', file=sys_stdout)
-class StringFileDescriptor(object):
+class StringFileDescriptor:
"""File descriptor that writes to string buffer"""
def __init__(self, fd):
@@ -56,7 +55,7 @@ class StringFileDescriptor(object):
self.out.flush()
-class UIBaseTestCase(object):
+class UIBaseTestCase:
def __init__(self):
self.var = {}
@@ -170,7 +169,7 @@ class GtkUIBaseTestCase(UIBaseTestCase):
@pytest.mark.gtkui
class GtkUIDelugeScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
def __init__(self, testname):
- super(GtkUIDelugeScriptEntryTestCase, self).__init__(testname)
+ super().__init__(testname)
GtkUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge gtk'
@@ -187,7 +186,7 @@ class GtkUIDelugeScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
@pytest.mark.gtkui
class GtkUIScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
def __init__(self, testname):
- super(GtkUIScriptEntryTestCase, self).__init__(testname)
+ super().__init__(testname)
GtkUIBaseTestCase.__init__(self)
from deluge.ui import gtk3
@@ -246,7 +245,7 @@ class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname):
- super(WebUIScriptEntryTestCase, self).__init__(testname)
+ super().__init__(testname)
WebUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge-web'
self.var['start_cmd'] = deluge.ui.web.start
@@ -265,7 +264,7 @@ class WebUIDelugeScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname):
- super(WebUIDelugeScriptEntryTestCase, self).__init__(testname)
+ super().__init__(testname)
WebUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge web'
self.var['start_cmd'] = ui_entry.start_ui
@@ -458,7 +457,7 @@ class ConsoleScriptEntryWithDaemonTestCase(
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname):
- super(ConsoleScriptEntryWithDaemonTestCase, self).__init__(testname)
+ super().__init__(testname)
ConsoleUIWithDaemonBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge-console'
self.var['sys_arg_cmd'] = ['./deluge-console']
@@ -484,7 +483,7 @@ class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname):
- super(ConsoleScriptEntryTestCase, self).__init__(testname)
+ super().__init__(testname)
ConsoleUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge-console'
self.var['start_cmd'] = deluge.ui.console.start
@@ -503,7 +502,7 @@ class ConsoleDelugeScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
skip = 'cannot test console ui on windows'
def __init__(self, testname):
- super(ConsoleDelugeScriptEntryTestCase, self).__init__(testname)
+ super().__init__(testname)
ConsoleUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge console'
self.var['start_cmd'] = ui_entry.start_ui
diff --git a/deluge/tests/test_ui_gtk3.py b/deluge/tests/test_ui_gtk3.py
index fb8f9e6d3..707a3ef2d 100644
--- a/deluge/tests/test_ui_gtk3.py
+++ b/deluge/tests/test_ui_gtk3.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -6,8 +5,8 @@
#
import sys
+from unittest import mock
-import mock
import pytest
from twisted.trial import unittest
diff --git a/deluge/tests/test_web_api.py b/deluge/tests/test_web_api.py
index 96b5234b1..8bac165e7 100644
--- a/deluge/tests/test_web_api.py
+++ b/deluge/tests/test_web_api.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -75,9 +74,9 @@ class WebAPITestCase(WebServerTestBase):
}
self.deluge_web.web_api.set_config(config)
web_config = component.get('DelugeWeb').config.config
- self.assertNotEquals(config['pwd_salt'], web_config['pwd_salt'])
- self.assertNotEquals(config['pwd_sha1'], web_config['pwd_sha1'])
- self.assertNotEquals(config['sessions'], web_config['sessions'])
+ self.assertNotEqual(config['pwd_salt'], web_config['pwd_salt'])
+ self.assertNotEqual(config['pwd_sha1'], web_config['pwd_sha1'])
+ self.assertNotEqual(config['sessions'], web_config['sessions'])
@defer.inlineCallbacks
def get_host_status(self):
diff --git a/deluge/tests/test_web_auth.py b/deluge/tests/test_web_auth.py
index 84a5586f4..9ca906108 100644
--- a/deluge/tests/test_web_auth.py
+++ b/deluge/tests/test_web_auth.py
@@ -1,16 +1,16 @@
-# -*- 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 mock import patch
+from unittest.mock import patch
+
from twisted.trial import unittest
from deluge.ui.web import auth
-class MockConfig(object):
+class MockConfig:
def __init__(self, config):
self.config = config
diff --git a/deluge/tests/test_webserver.py b/deluge/tests/test_webserver.py
index cdb0ee6ba..37a0c0d28 100644
--- a/deluge/tests/test_webserver.py
+++ b/deluge/tests/test_webserver.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
diff --git a/deluge/tests/twisted/plugins/delugereporter.py b/deluge/tests/twisted/plugins/delugereporter.py
index 66e9a48b2..7f07edba7 100644
--- a/deluge/tests/twisted/plugins/delugereporter.py
+++ b/deluge/tests/twisted/plugins/delugereporter.py
@@ -1,5 +1,4 @@
#! /usr/bin/env python
-# -*- 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.
@@ -14,7 +13,7 @@ from twisted.trial.reporter import TreeReporter
from zope.interface import implements
-class _Reporter(object):
+class _Reporter:
implements(IPlugin, IReporter)
def __init__(
diff --git a/deluge/transfer.py b/deluge/transfer.py
index 92240d2bf..ed7d6dd9a 100644
--- a/deluge/transfer.py
+++ b/deluge/transfer.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Bro <bro.development@gmail.com>
# Copyright (C) 2018 Andrew Resch <andrewresch@gmail.com>
@@ -22,7 +21,7 @@ MESSAGE_HEADER_FORMAT = '!BI'
MESSAGE_HEADER_SIZE = struct.calcsize(MESSAGE_HEADER_FORMAT)
-class DelugeTransferProtocol(Protocol, object):
+class DelugeTransferProtocol(Protocol):
"""
Deluge RPC wire protocol.
@@ -54,7 +53,7 @@ class DelugeTransferProtocol(Protocol, object):
body = zlib.compress(rencode.dumps(data))
body_len = len(body)
message = struct.pack(
- '{}{}s'.format(MESSAGE_HEADER_FORMAT, body_len),
+ f'{MESSAGE_HEADER_FORMAT}{body_len}s',
PROTOCOL_VERSION,
body_len,
body,
diff --git a/deluge/ui/client.py b/deluge/ui/client.py
index 3d7b2fc06..fc3509cf4 100644
--- a/deluge/ui/client.py
+++ b/deluge/ui/client.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
@@ -31,7 +30,7 @@ def format_kwargs(kwargs):
return ', '.join([key + '=' + str(value) for key, value in kwargs.items()])
-class DelugeRPCRequest(object):
+class DelugeRPCRequest:
"""
This object is created whenever there is a RPCRequest to be sent to the
daemon. It is generally only used by the DaemonProxy's call method.
@@ -241,7 +240,7 @@ class DelugeRPCClientFactory(ClientFactory):
self.daemon.disconnect_callback()
-class DaemonProxy(object):
+class DaemonProxy:
pass
@@ -524,7 +523,7 @@ class DaemonStandaloneProxy(DaemonProxy):
self.__daemon.core.eventmanager.deregister_event_handler(event, handler)
-class DottedObject(object):
+class DottedObject:
"""
This is used for dotted name calls to client
"""
@@ -549,7 +548,7 @@ class RemoteMethod(DottedObject):
return self.daemon.call(self.base, *args, **kwargs)
-class Client(object):
+class Client:
"""
This class is used to connect to a daemon process and issue RPC requests.
"""
diff --git a/deluge/ui/common.py b/deluge/ui/common.py
index ca7d30537..f9f774e23 100644
--- a/deluge/ui/common.py
+++ b/deluge/ui/common.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) Damien Churchill 2008-2009 <damoxc@gmail.com>
# Copyright (C) Andrew Resch 2009 <andrewresch@gmail.com>
@@ -165,7 +164,7 @@ DISK_CACHE_KEYS = [
]
-class TorrentInfo(object):
+class TorrentInfo:
"""Collects information about a torrent file.
Args:
@@ -184,7 +183,7 @@ class TorrentInfo(object):
try:
with open(filename, 'rb') as _file:
self._filedata = _file.read()
- except IOError as ex:
+ except OSError as ex:
log.warning('Unable to open %s: %s', filename, ex)
return
@@ -385,7 +384,7 @@ class TorrentInfo(object):
return self._filedata
-class FileTree2(object):
+class FileTree2:
"""
Converts a list of paths in to a file tree.
@@ -465,7 +464,7 @@ class FileTree2(object):
return '\n'.join(lines)
-class FileTree(object):
+class FileTree:
"""
Convert a list of paths in a file tree.
diff --git a/deluge/ui/console/__init__.py b/deluge/ui/console/__init__.py
index 0ed345853..5152980fc 100644
--- a/deluge/ui/console/__init__.py
+++ b/deluge/ui/console/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
#
diff --git a/deluge/ui/console/cmdline/command.py b/deluge/ui/console/cmdline/command.py
index 0db7b2f47..40edd78f0 100644
--- a/deluge/ui/console/cmdline/command.py
+++ b/deluge/ui/console/cmdline/command.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -21,7 +20,7 @@ from deluge.ui.console.utils.colors import strip_colors
log = logging.getLogger(__name__)
-class Commander(object):
+class Commander:
def __init__(self, cmds, interactive=False):
self._commands = cmds
self.interactive = interactive
@@ -142,7 +141,7 @@ class Commander(object):
return ret
-class BaseCommand(object):
+class BaseCommand:
usage = None
interactive_only = False
diff --git a/deluge/ui/console/cmdline/commands/__init__.py b/deluge/ui/console/cmdline/commands/__init__.py
index aa3f32cd5..39dbefe2a 100644
--- a/deluge/ui/console/cmdline/commands/__init__.py
+++ b/deluge/ui/console/cmdline/commands/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from deluge.ui.console.cmdline.command import BaseCommand
__all__ = ['BaseCommand']
diff --git a/deluge/ui/console/cmdline/commands/add.py b/deluge/ui/console/cmdline/commands/add.py
index b1d08cee3..706ae168e 100644
--- a/deluge/ui/console/cmdline/commands/add.py
+++ b/deluge/ui/console/cmdline/commands/add.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/cache.py b/deluge/ui/console/cmdline/commands/cache.py
index 724329b8d..fe6cd580d 100644
--- a/deluge/ui/console/cmdline/commands/cache.py
+++ b/deluge/ui/console/cmdline/commands/cache.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -22,7 +21,7 @@ class Command(BaseCommand):
def on_cache_status(status):
for key, value in sorted(status.items()):
- self.console.write('{!info!}%s: {!input!}%s' % (key, value))
+ self.console.write(f'{{!info!}}{key}: {{!input!}}{value}')
return client.core.get_session_status(DISK_CACHE_KEYS).addCallback(
on_cache_status
diff --git a/deluge/ui/console/cmdline/commands/config.py b/deluge/ui/console/cmdline/commands/config.py
index 0b2629633..8b31ca3cd 100644
--- a/deluge/ui/console/cmdline/commands/config.py
+++ b/deluge/ui/console/cmdline/commands/config.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -95,10 +94,10 @@ class Command(BaseCommand):
value = pprint.pformat(value, 2, 80)
new_value = []
for line in value.splitlines():
- new_value.append('%s%s' % (color, line))
+ new_value.append(f'{color}{line}')
value = '\n'.join(new_value)
- string += '%s: %s%s\n' % (key, color, value)
+ string += f'{key}: {color}{value}\n'
self.console.write(string.strip())
return client.core.get_config().addCallback(_on_get_config)
@@ -130,7 +129,7 @@ class Command(BaseCommand):
def on_set_config(result):
self.console.write('{!success!}Configuration value successfully updated.')
- self.console.write('Setting "%s" to: %r' % (key, val))
+ self.console.write(f'Setting "{key}" to: {val!r}')
return client.core.set_config({key: val}).addCallback(on_set_config)
def complete(self, text):
diff --git a/deluge/ui/console/cmdline/commands/connect.py b/deluge/ui/console/cmdline/commands/connect.py
index 677b15958..d917fdcca 100644
--- a/deluge/ui/console/cmdline/commands/connect.py
+++ b/deluge/ui/console/cmdline/commands/connect.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -55,7 +54,7 @@ class Command(BaseCommand):
def on_connect(result):
if self.console.interactive:
- self.console.write('{!success!}Connected to %s:%s!' % (host, port))
+ self.console.write(f'{{!success!}}Connected to {host}:{port}!')
return component.start()
def on_connect_fail(result):
diff --git a/deluge/ui/console/cmdline/commands/debug.py b/deluge/ui/console/cmdline/commands/debug.py
index b62c85171..af48a8b7f 100644
--- a/deluge/ui/console/cmdline/commands/debug.py
+++ b/deluge/ui/console/cmdline/commands/debug.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/gui.py b/deluge/ui/console/cmdline/commands/gui.py
index 6c750f394..575bc9b3a 100644
--- a/deluge/ui/console/cmdline/commands/gui.py
+++ b/deluge/ui/console/cmdline/commands/gui.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
diff --git a/deluge/ui/console/cmdline/commands/halt.py b/deluge/ui/console/cmdline/commands/halt.py
index e68bcec33..608f2de9d 100644
--- a/deluge/ui/console/cmdline/commands/halt.py
+++ b/deluge/ui/console/cmdline/commands/halt.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/help.py b/deluge/ui/console/cmdline/commands/help.py
index 42b463b3b..754dadbec 100644
--- a/deluge/ui/console/cmdline/commands/help.py
+++ b/deluge/ui/console/cmdline/commands/help.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/info.py b/deluge/ui/console/cmdline/commands/info.py
index c00583958..afcc13e3f 100644
--- a/deluge/ui/console/cmdline/commands/info.py
+++ b/deluge/ui/console/cmdline/commands/info.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -216,9 +215,9 @@ class Command(BaseCommand):
for depth, subdir in enumerate(filepath):
indent = ' ' * depth * spaces_per_level
if depth >= len(prevpath):
- self.console.write('%s{!cyan!}%s' % (indent, subdir))
+ self.console.write(f'{indent}{{!cyan!}}{subdir}')
elif subdir != prevpath[depth]:
- self.console.write('%s{!cyan!}%s' % (indent, subdir))
+ self.console.write(f'{indent}{{!cyan!}}{subdir}')
depth = len(filepath)
@@ -294,7 +293,7 @@ class Command(BaseCommand):
s += peer['ip']
else:
# IPv6
- s += '[%s]:%s' % (
+ s += '[{}]:{}'.format(
':'.join(peer['ip'].split(':')[:-1]),
peer['ip'].split(':')[-1],
)
@@ -306,7 +305,7 @@ class Command(BaseCommand):
s += '\t\t'
else:
s += '\t'
- s += '%s%s\t%s%s' % (
+ s += '{}{}\t{}{}'.format(
colors.state_color['Seeding'],
fspeed(peer['up_speed']),
colors.state_color['Downloading'],
@@ -334,7 +333,7 @@ class Command(BaseCommand):
if verbose or detailed:
self.console.write('{!info!}Name: {!input!}%s' % (status['name']))
self.console.write('{!info!}ID: {!input!}%s' % (torrent_id))
- s = '{!info!}State: %s%s' % (
+ s = '{{!info!}}State: {}{}'.format(
colors.state_color[status['state']],
status['state'],
)
@@ -352,12 +351,12 @@ class Command(BaseCommand):
self.console.write(s)
if status['state'] in ('Seeding', 'Downloading', 'Queued'):
- s = '{!info!}Seeds: {!input!}%s (%s)' % (
+ s = '{{!info!}}Seeds: {{!input!}}{} ({})'.format(
status['num_seeds'],
status['total_seeds'],
)
s += sep
- s += '{!info!}Peers: {!input!}%s (%s)' % (
+ s += '{{!info!}}Peers: {{!input!}}{} ({})'.format(
status['num_peers'],
status['total_peers'],
)
@@ -376,7 +375,7 @@ class Command(BaseCommand):
if total_done == total_size:
s = '{!info!}Size: {!input!}%s' % (total_size)
else:
- s = '{!info!}Size: {!input!}%s/%s' % (total_done, total_size)
+ s = f'{{!info!}}Size: {{!input!}}{total_done}/{total_size}'
s += sep
s += '{!info!}Downloaded: {!input!}%s' % fsize(
status['all_time_download'], shortform=True
@@ -416,7 +415,9 @@ class Command(BaseCommand):
pbar = f_progressbar(
status['progress'], cols - (13 + len('%.2f%%' % status['progress']))
)
- s = '{!info!}Progress: {!input!}%.2f%% %s' % (status['progress'], pbar)
+ s = '{{!info!}}Progress: {{!input!}}{:.2f}% {}'.format(
+ status['progress'], pbar
+ )
self.console.write(s)
s = '{!info!}Download Folder: {!input!}%s' % status['download_location']
@@ -431,7 +432,7 @@ class Command(BaseCommand):
up_color = colors.state_color['Seeding']
down_color = colors.state_color['Downloading']
- s = '%s%s' % (
+ s = '{}{}'.format(
colors.state_color[status['state']],
'[' + status['state'][0] + ']',
)
@@ -456,7 +457,7 @@ class Command(BaseCommand):
)
if status['download_payload_rate'] > 0:
- dl_info += ' @ %s%s' % (
+ dl_info += ' @ {}{}'.format(
down_color,
fspeed(status['download_payload_rate'], shortform=True),
)
@@ -466,7 +467,7 @@ class Command(BaseCommand):
status['total_uploaded'], status['total_payload_upload']
)
if status['upload_payload_rate'] > 0:
- ul_info += ' @ %s%s' % (
+ ul_info += ' @ {}{}'.format(
up_color,
fspeed(status['upload_payload_rate'], shortform=True),
)
diff --git a/deluge/ui/console/cmdline/commands/manage.py b/deluge/ui/console/cmdline/commands/manage.py
index 714e3dd55..e5ea9b255 100644
--- a/deluge/ui/console/cmdline/commands/manage.py
+++ b/deluge/ui/console/cmdline/commands/manage.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -67,7 +66,7 @@ class Command(BaseCommand):
self.console.write('{!info!}ID: {!input!}%s' % torrentid)
for k, v in data.items():
if k != 'name':
- self.console.write('{!info!}%s: {!input!}%s' % (k, v))
+ self.console.write(f'{{!info!}}{k}: {{!input!}}{v}')
def on_torrents_status_fail(reason):
self.console.write('{!error!}Failed to get torrent data.')
@@ -104,9 +103,7 @@ class Command(BaseCommand):
self.console.write('{!success!}Torrent option successfully updated.')
deferred.callback(True)
- self.console.write(
- 'Setting %s to %s for torrents %s..' % (key, val, torrent_ids)
- )
+ self.console.write(f'Setting {key} to {val} for torrents {torrent_ids}..')
client.core.set_torrent_options(torrent_ids, {key: val}).addCallback(
on_set_config
)
diff --git a/deluge/ui/console/cmdline/commands/move.py b/deluge/ui/console/cmdline/commands/move.py
index 40f39508d..67ee0af1d 100644
--- a/deluge/ui/console/cmdline/commands/move.py
+++ b/deluge/ui/console/cmdline/commands/move.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -50,7 +49,7 @@ class Command(BaseCommand):
names.append(self.console.get_torrent_name(tid))
def on_move(res):
- msg = 'Moved "%s" to %s' % (', '.join(names), options.path)
+ msg = 'Moved "{}" to {}'.format(', '.join(names), options.path)
self.console.write(msg)
log.info(msg)
diff --git a/deluge/ui/console/cmdline/commands/pause.py b/deluge/ui/console/cmdline/commands/pause.py
index de11a4c19..133424267 100644
--- a/deluge/ui/console/cmdline/commands/pause.py
+++ b/deluge/ui/console/cmdline/commands/pause.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/plugin.py b/deluge/ui/console/cmdline/commands/plugin.py
index 0dcb8062e..c424cb201 100644
--- a/deluge/ui/console/cmdline/commands/plugin.py
+++ b/deluge/ui/console/cmdline/commands/plugin.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/console/cmdline/commands/quit.py b/deluge/ui/console/cmdline/commands/quit.py
index 5daf77262..4459dfc70 100644
--- a/deluge/ui/console/cmdline/commands/quit.py
+++ b/deluge/ui/console/cmdline/commands/quit.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/recheck.py b/deluge/ui/console/cmdline/commands/recheck.py
index 7012c92bf..046cb0b1e 100644
--- a/deluge/ui/console/cmdline/commands/recheck.py
+++ b/deluge/ui/console/cmdline/commands/recheck.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/console/cmdline/commands/resume.py b/deluge/ui/console/cmdline/commands/resume.py
index ed2ae0aa6..27b852894 100644
--- a/deluge/ui/console/cmdline/commands/resume.py
+++ b/deluge/ui/console/cmdline/commands/resume.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/cmdline/commands/rm.py b/deluge/ui/console/cmdline/commands/rm.py
index bf1f9a02a..4a3fd008a 100644
--- a/deluge/ui/console/cmdline/commands/rm.py
+++ b/deluge/ui/console/cmdline/commands/rm.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -72,7 +71,7 @@ class Command(BaseCommand):
'Error(s) occurred when trying to delete torrent(s).'
)
for t_id, e_msg in errors:
- self.console.write('Error removing torrent %s : %s' % (t_id, e_msg))
+ self.console.write(f'Error removing torrent {t_id} : {e_msg}')
log.info('Removing %d torrents', len(torrent_ids))
d = client.core.remove_torrents(torrent_ids, options.remove_data)
diff --git a/deluge/ui/console/cmdline/commands/status.py b/deluge/ui/console/cmdline/commands/status.py
index 84cf21e94..2ca1cda2f 100644
--- a/deluge/ui/console/cmdline/commands/status.py
+++ b/deluge/ui/console/cmdline/commands/status.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
diff --git a/deluge/ui/console/cmdline/commands/update_tracker.py b/deluge/ui/console/cmdline/commands/update_tracker.py
index bee933d2f..c05569d7b 100644
--- a/deluge/ui/console/cmdline/commands/update_tracker.py
+++ b/deluge/ui/console/cmdline/commands/update_tracker.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/console.py b/deluge/ui/console/console.py
index 494ead972..8ef87e8de 100644
--- a/deluge/ui/console/console.py
+++ b/deluge/ui/console/console.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -51,7 +50,7 @@ def load_commands(command_dir):
return dict(commands)
-class LogStream(object):
+class LogStream:
out = sys.stdout
def write(self, data):
@@ -66,9 +65,7 @@ class Console(UI):
cmd_description = """Console or command-line user interface"""
def __init__(self, *args, **kwargs):
- super(Console, self).__init__(
- 'console', *args, log_stream=LogStream(), **kwargs
- )
+ super().__init__('console', *args, log_stream=LogStream(), **kwargs)
group = self.parser.add_argument_group(
_('Console Options'),
@@ -148,7 +145,7 @@ class Console(UI):
self.console_parser.subcommand = False
self.parser.subcommand = False if i == -1 else True
- super(Console, self).start(self.console_parser)
+ super().start(self.console_parser)
from deluge.ui.console.main import ConsoleUI # import here because (see top)
def run(options):
diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py
index aee61fd32..31d1db177 100644
--- a/deluge/ui/console/main.py
+++ b/deluge/ui/console/main.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -65,7 +64,7 @@ DEFAULT_CONSOLE_PREFS = {
}
-class MockConsoleLog(object):
+class MockConsoleLog:
def write(self, data):
pass
@@ -284,7 +283,7 @@ deluge-console.exe "add -p c:\\mytorrents c:\\new.torrent"
@overrides(TermResizeHandler)
def on_terminal_size(self, *args):
- rows, cols = super(ConsoleUI, self).on_terminal_size(args)
+ rows, cols = super().on_terminal_size(args)
for mode in self.modes:
self.modes[mode].on_resize(rows, cols)
@@ -709,7 +708,7 @@ class EventLog(component.Component):
if not t_name:
return
- self.write('%s: {!info!}%s ({!cyan!}%s{!info!})' % (state, t_name, torrent_id))
+ self.write(f'{state}: {{!info!}}{t_name} ({{!cyan!}}{torrent_id}{{!info!}})')
def on_torrent_finished_event(self, torrent_id):
if component.get('TorrentList').config['ring_bell']:
@@ -737,7 +736,7 @@ class EventLog(component.Component):
except KeyError:
pass
- self.write('ConfigValueChanged: {!input!}%s: %s%s' % (key, color, value))
+ self.write(f'ConfigValueChanged: {{!input!}}{key}: {color}{value}')
def write(self, s):
current_time = time.localtime()
diff --git a/deluge/ui/console/modes/add_util.py b/deluge/ui/console/modes/add_util.py
index 3f7c73428..9d29a1f4f 100644
--- a/deluge/ui/console/modes/add_util.py
+++ b/deluge/ui/console/modes/add_util.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
diff --git a/deluge/ui/console/modes/addtorrents.py b/deluge/ui/console/modes/addtorrents.py
index 6d68e6c42..0486099a9 100644
--- a/deluge/ui/console/modes/addtorrents.py
+++ b/deluge/ui/console/modes/addtorrents.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Arek Stefański <asmageddon@gmail.com>
#
@@ -369,7 +368,7 @@ class AddTorrents(BaseMode):
def fail_cb(msg, t_file, ress):
log.debug('failed to add torrent: %s: %s', t_file, msg)
ress['fail'] += 1
- ress['fmsg'].append('{!input!} * %s: {!error!}%s' % (t_file, msg))
+ ress['fmsg'].append(f'{{!input!}} * {t_file}: {{!error!}}{msg}')
if (ress['succ'] + ress['fail']) >= ress['total']:
report_add_status(
component.get('TorrentList'),
diff --git a/deluge/ui/console/modes/basemode.py b/deluge/ui/console/modes/basemode.py
index 4adf0f2b0..92c699e10 100644
--- a/deluge/ui/console/modes/basemode.py
+++ b/deluge/ui/console/modes/basemode.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -34,7 +33,7 @@ except ImportError:
log = logging.getLogger(__name__)
-class InputKeyHandler(object):
+class InputKeyHandler:
def __init__(self):
self._input_result = None
@@ -60,7 +59,7 @@ class InputKeyHandler(object):
return util.ReadState.IGNORED
-class TermResizeHandler(object):
+class TermResizeHandler:
def __init__(self):
try:
signal.signal(signal.SIGWINCH, self.on_terminal_size)
@@ -78,7 +77,7 @@ class TermResizeHandler(object):
return rows, cols
-class CursesStdIO(object):
+class CursesStdIO:
"""
fake fd to be registered as a reader with the twisted reactor.
Curses classes needing input should extend this
diff --git a/deluge/ui/console/modes/cmdline.py b/deluge/ui/console/modes/cmdline.py
index 680bbdc5a..7b0ff2dfc 100644
--- a/deluge/ui/console/modes/cmdline.py
+++ b/deluge/ui/console/modes/cmdline.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -11,7 +10,6 @@
import logging
import os
import re
-from io import open
import deluge.component as component
import deluge.configmanager
@@ -136,18 +134,18 @@ class CmdLine(BaseMode, Commander):
self._hf_lines = [0, 0]
if self.console_config['cmdline']['save_command_history']:
try:
- with open(self.history_file[0], 'r', encoding='utf8') as _file:
+ with open(self.history_file[0], encoding='utf8') as _file:
lines1 = _file.read().splitlines()
self._hf_lines[0] = len(lines1)
- except IOError:
+ except OSError:
lines1 = []
self._hf_lines[0] = 0
try:
- with open(self.history_file[1], 'r', encoding='utf8') as _file:
+ with open(self.history_file[1], encoding='utf8') as _file:
lines2 = _file.read().splitlines()
self._hf_lines[1] = len(lines2)
- except IOError:
+ except OSError:
lines2 = []
self._hf_lines[1] = 0
@@ -823,21 +821,21 @@ class CmdLine(BaseMode, Commander):
# Let's avoid listing all torrents twice if there's no pattern
if not empty and torrent_id.startswith(line):
# Highlight the matching part
- text = '{!info!}%s{!input!}%s - "%s"' % (
+ text = '{{!info!}}{}{{!input!}}{} - "{}"'.format(
torrent_id[:line_len],
torrent_id[line_len:],
torrent_name,
)
possible_matches.append(text)
if torrent_name.startswith(line):
- text = '{!info!}%s{!input!}%s ({!cyan!}%s{!input!})' % (
+ text = '{{!info!}}{}{{!input!}}{} ({{!cyan!}}{}{{!input!}})'.format(
escaped_name[:line_len],
escaped_name[line_len:],
torrent_id,
)
possible_matches.append(text)
elif torrent_name.lower().startswith(line.lower()):
- text = '{!info!}%s{!input!}%s ({!cyan!}%s{!input!})' % (
+ text = '{{!info!}}{}{{!input!}}{} ({{!cyan!}}{}{{!input!}})'.format(
escaped_name[:line_len],
escaped_name[line_len:],
torrent_id,
diff --git a/deluge/ui/console/modes/connectionmanager.py b/deluge/ui/console/modes/connectionmanager.py
index 755694260..d85c1f861 100644
--- a/deluge/ui/console/modes/connectionmanager.py
+++ b/deluge/ui/console/modes/connectionmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -126,7 +125,7 @@ class ConnectionManager(BaseMode, PopupsHandler):
try:
self.hostlist.add_host(hostname, port, username, password)
except ValueError as ex:
- self.report_message(_('Error adding host'), '%s: %s' % (hostname, ex))
+ self.report_message(_('Error adding host'), f'{hostname}: {ex}')
else:
self.update_select_host_popup()
diff --git a/deluge/ui/console/modes/eventview.py b/deluge/ui/console/modes/eventview.py
index b2949b71a..6526023fb 100644
--- a/deluge/ui/console/modes/eventview.py
+++ b/deluge/ui/console/modes/eventview.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
diff --git a/deluge/ui/console/modes/preferences/preference_panes.py b/deluge/ui/console/modes/preferences/preference_panes.py
index 1aaa66fdc..4471580eb 100644
--- a/deluge/ui/console/modes/preferences/preference_panes.py
+++ b/deluge/ui/console/modes/preferences/preference_panes.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
diff --git a/deluge/ui/console/modes/preferences/preferences.py b/deluge/ui/console/modes/preferences/preferences.py
index 397ab687a..2c95323c6 100644
--- a/deluge/ui/console/modes/preferences/preferences.py
+++ b/deluge/ui/console/modes/preferences/preferences.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -72,7 +71,7 @@ arrow to edit the other value, and escape to get back to the check box.
"""
-class ZONE(object):
+class ZONE:
length = 3
CATEGORIES, PREFRENCES, ACTIONS = list(range(length))
diff --git a/deluge/ui/console/modes/torrentdetail.py b/deluge/ui/console/modes/torrentdetail.py
index bcc22eb35..eab9dfef1 100644
--- a/deluge/ui/console/modes/torrentdetail.py
+++ b/deluge/ui/console/modes/torrentdetail.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -423,9 +422,9 @@ class TorrentDetail(BaseMode, PopupsHandler):
attr = 'bold'
if attr:
- color_string = '{!%s,%s,%s!}' % (fg, bg, attr)
+ color_string = f'{{!{fg},{bg},{attr}!}}'
else:
- color_string = '{!%s,%s!}' % (fg, bg)
+ color_string = f'{{!{fg},{bg}!}}'
# actually draw the dir/file string
if fl[3] and fl[4]: # this is an expanded directory
@@ -437,7 +436,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
r = format_row(
[
- '%s%s %s' % (' ' * depth, xchar, fl[0]),
+ '{}{} {}'.format(' ' * depth, xchar, fl[0]),
fsize(fl[2]),
fl[5],
format_priority(fl[6]),
@@ -445,7 +444,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
self.column_widths,
)
- self.add_string(off, '%s%s' % (color_string, r), trim=False)
+ self.add_string(off, f'{color_string}{r}', trim=False)
off += 1
if fl[3] and fl[4]:
@@ -500,7 +499,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
download_color = colors.state_color['Downloading']
def add_field(name, row, pre_color='{!info!}', post_color='{!input!}'):
- s = '%s%s: %s%s' % (
+ s = '{}{}: {}{}'.format(
pre_color,
torrent_data_fields[name]['name'],
post_color,
@@ -521,7 +520,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
if status['progress'] != 100.0:
s += '/%s' % fsize(status['total_wanted'])
if status['download_payload_rate'] > 0:
- s += ' {!yellow!}@ %s%s' % (
+ s += ' {{!yellow!}}@ {}{}'.format(
download_color,
fsize(status['download_payload_rate']),
)
@@ -532,7 +531,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
# Print UL info and ratio
s = add_field('uploaded', 0, download_color)
if status['upload_payload_rate'] > 0:
- s += ' {!yellow!}@ %s%s' % (
+ s += ' {{!yellow!}}@ {}{}'.format(
colors.state_color['Seeding'],
fsize(status['upload_payload_rate']),
)
@@ -540,13 +539,13 @@ class TorrentDetail(BaseMode, PopupsHandler):
row = self.add_string(row, s)
# Seed/peer info
- s = '{!info!}%s:{!green!} %s {!input!}(%s)' % (
+ s = '{{!info!}}{}:{{!green!}} {} {{!input!}}({})'.format(
torrent_data_fields['seeds']['name'],
status['num_seeds'],
status['total_seeds'],
)
row = self.add_string(row, s)
- s = '{!info!}%s:{!red!} %s {!input!}(%s)' % (
+ s = '{{!info!}}{}:{{!red!}} {} {{!input!}}({})'.format(
torrent_data_fields['peers']['name'],
status['num_peers'],
status['total_peers'],
@@ -555,7 +554,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
# Tracker
tracker_color = '{!green!}' if status['message'] == 'OK' else '{!red!}'
- s = '{!info!}%s: {!magenta!}%s{!input!} says "%s%s{!input!}"' % (
+ s = '{{!info!}}{}: {{!magenta!}}{}{{!input!}} says "{}{}{{!input!}}"'.format(
torrent_data_fields['tracker']['name'],
status['tracker_host'],
tracker_color,
@@ -564,13 +563,13 @@ class TorrentDetail(BaseMode, PopupsHandler):
row = self.add_string(row, s)
# Pieces and availability
- s = '{!info!}%s: {!yellow!}%s {!input!}x {!yellow!}%s' % (
+ s = '{{!info!}}{}: {{!yellow!}}{} {{!input!}}x {{!yellow!}}{}'.format(
torrent_data_fields['pieces']['name'],
status['num_pieces'],
fsize(status['piece_length']),
)
if status['distributed_copies']:
- s += '{!info!}%s: {!input!}%s' % (
+ s += '{{!info!}}{}: {{!input!}}{}'.format(
torrent_data_fields['seed_rank']['name'],
status['seed_rank'],
)
@@ -876,7 +875,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
idx += 1
continue
if num == idx:
- return '%s%s/' % (path, element[0])
+ return f'{path}{element[0]}/'
if element[4]:
i = self._get_full_folder_path(
num, element[3], path + element[0] + '/', idx + 1
@@ -921,7 +920,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
self.popup.close(None, call_cb=False)
return
old_fname = self._get_full_folder_path(self.current_file_idx)
- new_fname = '%s/%s/' % (
+ new_fname = '{}/{}/'.format(
old_fname.strip('/').rpartition('/')[0],
result['new_foldername']['value'],
)
@@ -947,7 +946,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
):
self.popup.close(None, call_cb=False)
return
- fname = '%s/%s' % (
+ fname = '{}/{}'.format(
self.full_names[idx].rpartition('/')[0],
result['new_filename']['value'],
)
diff --git a/deluge/ui/console/modes/torrentlist/__init__.py b/deluge/ui/console/modes/torrentlist/__init__.py
index 7b16b9d88..48c60ce5a 100644
--- a/deluge/ui/console/modes/torrentlist/__init__.py
+++ b/deluge/ui/console/modes/torrentlist/__init__.py
@@ -1,4 +1,4 @@
-class ACTION(object):
+class ACTION:
PAUSE = 'pause'
RESUME = 'resume'
REANNOUNCE = 'update_tracker'
diff --git a/deluge/ui/console/modes/torrentlist/add_torrents_popup.py b/deluge/ui/console/modes/torrentlist/add_torrents_popup.py
index ae7370883..3ff9ab78d 100644
--- a/deluge/ui/console/modes/torrentlist/add_torrents_popup.py
+++ b/deluge/ui/console/modes/torrentlist/add_torrents_popup.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -38,7 +37,7 @@ def show_torrent_add_popup(torrentlist):
def fail_cb(msg, url):
log.debug('failed to add torrent: %s: %s', url, msg)
- error_msg = '{!input!} * %s: {!error!}%s' % (url, msg)
+ error_msg = f'{{!input!}} * {url}: {{!error!}}{msg}'
report_add_status(torrentlist, 0, 1, [error_msg])
def success_cb(tid, url):
diff --git a/deluge/ui/console/modes/torrentlist/filtersidebar.py b/deluge/ui/console/modes/torrentlist/filtersidebar.py
index 114365e04..982e2457a 100644
--- a/deluge/ui/console/modes/torrentlist/filtersidebar.py
+++ b/deluge/ui/console/modes/torrentlist/filtersidebar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
diff --git a/deluge/ui/console/modes/torrentlist/queue_mode.py b/deluge/ui/console/modes/torrentlist/queue_mode.py
index f101cea69..33af0135d 100644
--- a/deluge/ui/console/modes/torrentlist/queue_mode.py
+++ b/deluge/ui/console/modes/torrentlist/queue_mode.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -36,7 +35,7 @@ Change queue position of selected torrents
"""
-class QueueMode(object):
+class QueueMode:
def __init__(self, torrentslist, torrent_ids):
self.torrentslist = torrentslist
self.torrentview = torrentslist.torrentview
diff --git a/deluge/ui/console/modes/torrentlist/search_mode.py b/deluge/ui/console/modes/torrentlist/search_mode.py
index ffe75ee4c..6f79628fb 100644
--- a/deluge/ui/console/modes/torrentlist/search_mode.py
+++ b/deluge/ui/console/modes/torrentlist/search_mode.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -46,7 +45,7 @@ SEARCH_FORMAT = {
class SearchMode(InputKeyHandler):
def __init__(self, torrentlist):
- super(SearchMode, self).__init__()
+ super().__init__()
self.torrentlist = torrentlist
self.torrentview = torrentlist.torrentview
self.search_state = SEARCH_EMPTY
diff --git a/deluge/ui/console/modes/torrentlist/torrentactions.py b/deluge/ui/console/modes/torrentlist/torrentactions.py
index 9ec397538..6450118c6 100644
--- a/deluge/ui/console/modes/torrentlist/torrentactions.py
+++ b/deluge/ui/console/modes/torrentlist/torrentactions.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -44,7 +43,7 @@ def action_remove(mode=None, torrent_ids=None, **kwargs):
if errors:
error_msgs = ''
for t_id, e_msg in errors:
- error_msgs += 'Error removing torrent %s : %s\n' % (t_id, e_msg)
+ error_msgs += f'Error removing torrent {t_id} : {e_msg}\n'
mode.report_message(
'Error(s) occured when trying to delete torrent(s).', error_msgs
)
@@ -75,7 +74,7 @@ def action_remove(mode=None, torrent_ids=None, **kwargs):
show_max = 6
for i, (name, state) in enumerate(status):
color = colors.state_color[state]
- rem_msg += '\n %s* {!input!}%s' % (color, name)
+ rem_msg += f'\n {color}* {{!input!}}{name}'
if i == show_max - 1:
if i < len(status) - 1:
rem_msg += '\n {!red!}And %i more' % (len(status) - show_max)
diff --git a/deluge/ui/console/modes/torrentlist/torrentlist.py b/deluge/ui/console/modes/torrentlist/torrentlist.py
index 522986c89..d3c32ec0e 100644
--- a/deluge/ui/console/modes/torrentlist/torrentlist.py
+++ b/deluge/ui/console/modes/torrentlist/torrentlist.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -177,7 +176,7 @@ class TorrentList(BaseMode, PopupsHandler):
@overrides(BaseMode)
def resume(self):
- super(TorrentList, self).resume()
+ super().resume()
@overrides(BaseMode)
def on_resize(self, rows, cols):
@@ -220,7 +219,9 @@ class TorrentList(BaseMode, PopupsHandler):
# Update the status bars
statusbar_args = {'scr': self.stdscr, 'bottombar_help': True}
if self.torrentview.curr_filter is not None:
- statusbar_args['topbar'] = '%s {!filterstatus!}Current filter: %s' % (
+ statusbar_args[
+ 'topbar'
+ ] = '{} {{!filterstatus!}}Current filter: {}'.format(
self.statusbars.topbar,
self.torrentview.curr_filter,
)
diff --git a/deluge/ui/console/modes/torrentlist/torrentview.py b/deluge/ui/console/modes/torrentlist/torrentview.py
index 2668d3aaa..fbd029983 100644
--- a/deluge/ui/console/modes/torrentlist/torrentview.py
+++ b/deluge/ui/console/modes/torrentlist/torrentview.py
@@ -1,4 +1,3 @@
-# -*- 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.
@@ -88,7 +87,7 @@ for col_i, col_name in enumerate(torrentviewcolumns.column_pref_names):
class TorrentView(InputKeyHandler):
def __init__(self, torrentlist, config):
- super(TorrentView, self).__init__()
+ super().__init__()
self.torrentlist = torrentlist
self.config = config
self.filter_dict = {}
@@ -329,7 +328,7 @@ class TorrentView(InputKeyHandler):
self.torrentlist.add_string(
currow + self.torrentlist_offset,
- '%s%s' % (colorstr, row[0]),
+ f'{colorstr}{row[0]}',
trim=False,
scr=self.torrentlist.torrentview_panel,
)
diff --git a/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py b/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py
index 86494cbf4..586a56978 100644
--- a/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py
+++ b/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
diff --git a/deluge/ui/console/parser.py b/deluge/ui/console/parser.py
index b39f2a878..c0686b156 100644
--- a/deluge/ui/console/parser.py
+++ b/deluge/ui/console/parser.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -27,7 +26,7 @@ class ConsoleBaseParser(argparse.ArgumentParser):
# Handle epilog manually to keep the text formatting
epilog = self.epilog
self.epilog = ''
- help_str = super(ConsoleBaseParser, self).format_help()
+ help_str = super().format_help()
if epilog is not None:
help_str += epilog
self.epilog = epilog
@@ -49,7 +48,7 @@ class ConsoleCommandParser(ConsoleBaseParser):
for cmd_line in cmd_lines:
cmds = shlex.split(cmd_line)
- cmd_options = super(ConsoleCommandParser, self).parse_args(args=cmds)
+ cmd_options = super().parse_args(args=cmds)
cmd_options.command = cmds[0]
command_options.append(cmd_options)
@@ -94,7 +93,7 @@ class ConsoleCommandParser(ConsoleBaseParser):
options = self.base_parser.parse_args(args=args)
options.parsed_cmds = []
else:
- options = super(ConsoleCommandParser, self).parse_args(args=args)
+ options = super().parse_args(args=args)
options.parsed_cmds = [options]
if not hasattr(options, 'remaining'):
@@ -105,7 +104,7 @@ class ConsoleCommandParser(ConsoleBaseParser):
class OptionParser(ConsoleBaseParser):
def __init__(self, **kwargs):
- super(OptionParser, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.formatter = ConsoleColorFormatter()
def exit(self, status=0, msg=None):
@@ -137,5 +136,5 @@ class OptionParser(ConsoleBaseParser):
def format_help(self):
"""Return help formatted with colors."""
- help_str = super(OptionParser, self).format_help()
+ help_str = super().format_help()
return self.formatter.format_colors(help_str)
diff --git a/deluge/ui/console/utils/colors.py b/deluge/ui/console/utils/colors.py
index 5c35a8327..67996e19c 100644
--- a/deluge/ui/console/utils/colors.py
+++ b/deluge/ui/console/utils/colors.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -269,7 +268,7 @@ def parse_color_string(string):
last_color_attr = color_pair
attrs = attrs[2:] # Remove colors
except KeyError:
- raise BadColorString('Bad color value in tag: %s,%s' % (fg, bg))
+ raise BadColorString(f'Bad color value in tag: {fg},{bg}')
# Check for additional attributes and OR them to the color_pair
color_pair = apply_attrs(color_pair, attrs)
last_color_attr = color_pair
@@ -290,7 +289,7 @@ def parse_color_string(string):
return ret
-class ConsoleColorFormatter(object):
+class ConsoleColorFormatter:
"""
Format help in a way suited to deluge CmdLine mode - colors, format, indentation...
"""
diff --git a/deluge/ui/console/utils/column.py b/deluge/ui/console/utils/column.py
index f59a549d9..ecbe04ba3 100644
--- a/deluge/ui/console/utils/column.py
+++ b/deluge/ui/console/utils/column.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
diff --git a/deluge/ui/console/utils/common.py b/deluge/ui/console/utils/common.py
index b0dbe0ec4..fdc88c402 100644
--- a/deluge/ui/console/utils/common.py
+++ b/deluge/ui/console/utils/common.py
@@ -1,4 +1,3 @@
-# -*- 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.
diff --git a/deluge/ui/console/utils/curses_util.py b/deluge/ui/console/utils/curses_util.py
index 0d94d0c51..50b044402 100644
--- a/deluge/ui/console/utils/curses_util.py
+++ b/deluge/ui/console/utils/curses_util.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -37,7 +36,7 @@ def is_int_chr(c):
return c > 47 and c < 58
-class Curser(object):
+class Curser:
INVISIBLE = 0
NORMAL = 1
VERY_VISIBLE = 2
@@ -57,7 +56,7 @@ def safe_curs_set(visibility):
pass
-class ReadState(object):
+class ReadState:
IGNORED = 0
READ = 1
CHANGED = 2
diff --git a/deluge/ui/console/utils/format_utils.py b/deluge/ui/console/utils/format_utils.py
index 441d06dea..6c9596729 100644
--- a/deluge/ui/console/utils/format_utils.py
+++ b/deluge/ui/console/utils/format_utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -96,7 +95,7 @@ def f_seedrank_dash(seed_rank, seeding_time):
def ftotal_sized(first, second):
- return '%s (%s)' % (
+ return '{} ({})'.format(
deluge.common.fsize(first, shortform=True),
deluge.common.fsize(second, shortform=True),
)
@@ -157,7 +156,7 @@ def format_column(col, lim):
if size >= lim - 1:
return trim_string(col, lim, dbls > 0)
else:
- return '%s%s' % (col, ' ' * (lim - size))
+ return '{}{}'.format(col, ' ' * (lim - size))
def format_row(row, column_widths):
@@ -211,7 +210,7 @@ def wrap_string(string, width, min_lines=0, strip_colors=True):
mtc = mtchs.popleft() - offset
clr = clrs.popleft()
end_pos += len(clr)
- s = '%s%s%s' % (s[:mtc], clr, s[mtc:])
+ s = f'{s[:mtc]}{clr}{s[mtc:]}'
return s
for s in s1:
@@ -288,7 +287,7 @@ def wrap_string(string, width, min_lines=0, strip_colors=True):
last_color_string = ''
for i, line in enumerate(ret):
if i != 0:
- ret[i] = '%s%s' % (last_color_string, ret[i])
+ ret[i] = f'{last_color_string}{ret[i]}'
colors = re.findall('\\{![^!]+!\\}', line)
if colors:
@@ -311,9 +310,9 @@ def pad_string(string, length, character=' ', side='right'):
w = strwidth(string)
diff = length - w
if side == 'left':
- return '%s%s' % (character * diff, string)
+ return f'{character * diff}{string}'
elif side == 'right':
- return '%s%s' % (string, character * diff)
+ return f'{string}{character * diff}'
def delete_alt_backspace(input_text, input_cursor, sep_chars=' *?!._~-#$^;\'"/'):
diff --git a/deluge/ui/console/widgets/fields.py b/deluge/ui/console/widgets/fields.py
index 86a06109e..d8d892d52 100644
--- a/deluge/ui/console/widgets/fields.py
+++ b/deluge/ui/console/widgets/fields.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
@@ -32,7 +31,7 @@ log = logging.getLogger(__name__)
class BaseField(InputKeyHandler):
def __init__(self, parent=None, name=None, selectable=True, **kwargs):
- super(BaseField, self).__init__()
+ super().__init__()
self.name = name
self.parent = parent
self.fmt_keys = {}
@@ -71,7 +70,7 @@ class BaseField(InputKeyHandler):
def build_fmt_string(self, focused, active, value_key='msg', **kwargs):
color_key, font_key = self.get_fmt_keys(focused, active, **kwargs)
- return '{!%%(%s)s,%%(%s)s!}%%(%s)s{!%%(%s)s!}' % (
+ return '{{!%({})s,%({})s!}}%({})s{{!%({})s!}}'.format(
color_key,
font_key,
value_key,
@@ -173,7 +172,7 @@ class InfoField(NoInputField):
NoInputField.__init__(self, parent=parent, name=name, **kwargs)
self.label = label
self.value = value
- self.txt = '%s %s' % (label, value)
+ self.txt = f'{label} {value}'
@overrides(BaseField)
def render(self, screen, row, col=0, **kwargs):
@@ -184,9 +183,9 @@ class InfoField(NoInputField):
def set_value(self, v):
self.value = v
if isinstance(v, float):
- self.txt = '%s %.2f' % (self.label, self.value)
+ self.txt = f'{self.label} {self.value:.2f}'
else:
- self.txt = '%s %s' % (self.label, self.value)
+ self.txt = f'{self.label} {self.value}'
class CheckedInput(InputField):
@@ -199,7 +198,7 @@ class CheckedInput(InputField):
checked_char='X',
unchecked_char=' ',
checkbox_format='[%s] ',
- **kwargs
+ **kwargs,
):
InputField.__init__(self, parent, name, message, **kwargs)
self.set_value(checked)
@@ -228,9 +227,7 @@ class CheckedInput(InputField):
@overrides(BaseField)
def get_fmt_keys(self, focused, active, **kwargs):
- color_key, font_key = super(CheckedInput, self).get_fmt_keys(
- focused, active, **kwargs
- )
+ color_key, font_key = super().get_fmt_keys(focused, active, **kwargs)
if self.checked:
color_key += '_checked'
font_key += '_checked'
@@ -281,7 +278,7 @@ class CheckedPlusInput(CheckedInput):
child_always_visible=False,
show_usage_hints=True,
msg_fmt='%s ',
- **kwargs
+ **kwargs,
):
CheckedInput.__init__(self, parent, name, message, **kwargs)
self.child = child
@@ -369,7 +366,7 @@ class IntSpinInput(InputField):
incr_large=10,
strict_validation=False,
fmt='%d',
- **kwargs
+ **kwargs,
):
InputField.__init__(self, parent, name, message, **kwargs)
self.convert_func = int
@@ -615,7 +612,7 @@ class SelectInput(InputField):
active_index,
active_default=False,
require_select_action=True,
- **kwargs
+ **kwargs,
):
InputField.__init__(self, parent, name, message, **kwargs)
self.opts = opts
@@ -664,9 +661,7 @@ class SelectInput(InputField):
@overrides(BaseField)
def get_fmt_keys(self, focused, active, selected=False, **kwargs):
- color_key, font_key = super(SelectInput, self).get_fmt_keys(
- focused, active, **kwargs
- )
+ color_key, font_key = super().get_fmt_keys(focused, active, **kwargs)
if selected:
color_key += '_selected'
font_key += '_selected'
@@ -736,7 +731,7 @@ class TextInput(InputField):
value,
complete=False,
activate_input=False,
- **kwargs
+ **kwargs,
):
InputField.__init__(self, parent, name, message, **kwargs)
self.move_func = move_func
@@ -812,7 +807,7 @@ class TextInput(InputField):
focused=True,
col=0,
cursor_offset=0,
- **kwargs
+ **kwargs,
):
if not self.value and not active and len(self.default_value) != 0:
self.value = self.default_value
@@ -1078,7 +1073,7 @@ class ComboInput(InputField):
choice[1],
selectable=True,
selected=choice[0] == self.get_value(),
- **args
+ **args,
)
self.parent.push_popup(select_popup)
return util.ReadState.CHANGED
@@ -1146,7 +1141,7 @@ class TextArea(TextField):
for i, line in enumerate(lines):
self.parent.add_string(
row + i,
- '%s%s' % (color, line),
+ f'{color}{line}',
scr=screen,
col=col,
pad=False,
@@ -1173,7 +1168,7 @@ class DividerField(NoInputField):
selectable=False,
fill_width=True,
value_fmt='%s',
- **kwargs
+ **kwargs,
):
NoInputField.__init__(
self, parent=parent, name=name, selectable=selectable, **kwargs
diff --git a/deluge/ui/console/widgets/inputpane.py b/deluge/ui/console/widgets/inputpane.py
index d79d63df0..d8d217501 100644
--- a/deluge/ui/console/widgets/inputpane.py
+++ b/deluge/ui/console/widgets/inputpane.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
diff --git a/deluge/ui/console/widgets/popup.py b/deluge/ui/console/widgets/popup.py
index d73dd1a23..4b0d0274e 100644
--- a/deluge/ui/console/widgets/popup.py
+++ b/deluge/ui/console/widgets/popup.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -23,7 +22,7 @@ except ImportError:
log = logging.getLogger(__name__)
-class ALIGN(object):
+class ALIGN:
TOP_LEFT = 1
TOP_CENTER = 2
TOP_RIGHT = 3
@@ -36,7 +35,7 @@ class ALIGN(object):
DEFAULT = MIDDLE_CENTER
-class PopupsHandler(object):
+class PopupsHandler:
def __init__(self):
self._popups = []
diff --git a/deluge/ui/console/widgets/sidebar.py b/deluge/ui/console/widgets/sidebar.py
index 73f350a7f..4015a1375 100644
--- a/deluge/ui/console/widgets/sidebar.py
+++ b/deluge/ui/console/widgets/sidebar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
diff --git a/deluge/ui/console/widgets/statusbars.py b/deluge/ui/console/widgets/statusbars.py
index f9bd8ba52..57128eabf 100644
--- a/deluge/ui/console/widgets/statusbars.py
+++ b/deluge/ui/console/widgets/statusbars.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/console/widgets/window.py b/deluge/ui/console/widgets/window.py
index 1b68346ea..77aff8817 100644
--- a/deluge/ui/console/widgets/window.py
+++ b/deluge/ui/console/widgets/window.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
@@ -22,7 +21,7 @@ except ImportError:
log = logging.getLogger(__name__)
-class BaseWindow(object):
+class BaseWindow:
"""
BaseWindow creates a curses screen to be used for showing panels and popup dialogs
"""
diff --git a/deluge/ui/coreconfig.py b/deluge/ui/coreconfig.py
index f5483e562..1e2927b5e 100644
--- a/deluge/ui/coreconfig.py
+++ b/deluge/ui/coreconfig.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/countries.py b/deluge/ui/countries.py
index b21c8b911..eb94df6d9 100644
--- a/deluge/ui/countries.py
+++ b/deluge/ui/countries.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# This file is public domain.
#
diff --git a/deluge/ui/gtk3/__init__.py b/deluge/ui/gtk3/__init__.py
index 82bcea1d4..8db2773e4 100644
--- a/deluge/ui/gtk3/__init__.py
+++ b/deluge/ui/gtk3/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -23,7 +22,7 @@ class Gtk(UI):
cmd_description = """GTK-based graphical user interface"""
def __init__(self, *args, **kwargs):
- super(Gtk, self).__init__(
+ super().__init__(
'gtk', *args, description='Starts the Deluge GTK+ interface', **kwargs
)
@@ -40,7 +39,7 @@ class Gtk(UI):
)
def start(self):
- super(Gtk, self).start()
+ super().start()
import deluge.common
from .gtkui import GtkUI
diff --git a/deluge/ui/gtk3/aboutdialog.py b/deluge/ui/gtk3/aboutdialog.py
index 2165cbc28..989dd70f7 100644
--- a/deluge/ui/gtk3/aboutdialog.py
+++ b/deluge/ui/gtk3/aboutdialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Marcos Mobley ('markybob') <markybob@gmail.com>
#
@@ -16,7 +15,7 @@ from deluge.ui.client import client
from .common import get_deluge_icon, get_pixbuf
-class AboutDialog(object):
+class AboutDialog:
def __init__(self):
self.about = Gtk.AboutDialog()
self.about.set_transient_for(component.get('MainWindow').window)
diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py
index f4df0d29e..1c94a1e08 100644
--- a/deluge/ui/gtk3/addtorrentdialog.py
+++ b/deluge/ui/gtk3/addtorrentdialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
@@ -773,7 +772,7 @@ class AddTorrentDialog(component.Component):
else:
ErrorDialog(
_('Invalid URL'),
- '%s %s' % (url, _('is not a valid URL.')),
+ '{} {}'.format(url, _('is not a valid URL.')),
self.dialog,
).run()
@@ -815,7 +814,7 @@ class AddTorrentDialog(component.Component):
dialog.destroy()
ErrorDialog(
_('Download Failed'),
- '%s %s' % (_('Failed to download:'), url),
+ '{} {}'.format(_('Failed to download:'), url),
details=result.getErrorMessage(),
parent=self.dialog,
).run()
diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py
index 455a4da2e..6deca2337 100644
--- a/deluge/ui/gtk3/common.py
+++ b/deluge/ui/gtk3/common.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Marcos Mobley ('markybob') <markybob@gmail.com>
#
@@ -234,7 +233,7 @@ def associate_magnet_links(overwrite=False):
try:
hkey = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'Magnet')
- except WindowsError:
+ except OSError:
overwrite = True
else:
winreg.CloseKey(hkey)
@@ -243,7 +242,7 @@ def associate_magnet_links(overwrite=False):
deluge_exe = os.path.join(os.path.dirname(sys.executable), 'deluge.exe')
try:
magnet_key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, 'Magnet')
- except WindowsError:
+ except OSError:
# Could not create for all users, falling back to current user
magnet_key = winreg.CreateKey(
winreg.HKEY_CURRENT_USER, 'Software\\Classes\\Magnet'
@@ -252,14 +251,12 @@ def associate_magnet_links(overwrite=False):
winreg.SetValue(magnet_key, '', winreg.REG_SZ, 'URL:Magnet Protocol')
winreg.SetValueEx(magnet_key, 'URL Protocol', 0, winreg.REG_SZ, '')
winreg.SetValueEx(magnet_key, 'BrowserFlags', 0, winreg.REG_DWORD, 0x8)
- winreg.SetValue(
- magnet_key, 'DefaultIcon', winreg.REG_SZ, '{},0'.format(deluge_exe)
- )
+ winreg.SetValue(magnet_key, 'DefaultIcon', winreg.REG_SZ, f'{deluge_exe},0')
winreg.SetValue(
magnet_key,
r'shell\open\command',
winreg.REG_SZ,
- '"{}" "%1"'.format(deluge_exe),
+ f'"{deluge_exe}" "%1"',
)
winreg.CloseKey(magnet_key)
@@ -315,7 +312,7 @@ def save_pickled_state_file(filename, state):
if os.path.isfile(filepath):
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
shutil.copy2(filepath, filepath_bak)
- except IOError as ex:
+ except OSError as ex:
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
else:
log.info('Saving the %s at: %s', filename, filepath)
@@ -326,7 +323,7 @@ def save_pickled_state_file(filename, state):
_file.flush()
os.fsync(_file.fileno())
shutil.move(filepath_tmp, filepath)
- except (IOError, EOFError, pickle.PicklingError) as ex:
+ except (OSError, EOFError, pickle.PicklingError) as ex:
log.error('Unable to save %s: %s', filename, ex)
if os.path.isfile(filepath_bak):
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
@@ -352,7 +349,7 @@ def load_pickled_state_file(filename):
try:
with open(_filepath, 'rb') as _file:
state = pickle.load(_file, encoding='utf8')
- except (IOError, pickle.UnpicklingError) as ex:
+ except (OSError, pickle.UnpicklingError) as ex:
log.warning('Unable to load %s: %s', _filepath, ex)
else:
log.info('Successfully loaded %s: %s', filename, _filepath)
diff --git a/deluge/ui/gtk3/connectionmanager.py b/deluge/ui/gtk3/connectionmanager.py
index 89718e0e0..0834ae7e4 100644
--- a/deluge/ui/gtk3/connectionmanager.py
+++ b/deluge/ui/gtk3/connectionmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/gtk3/createtorrentdialog.py b/deluge/ui/gtk3/createtorrentdialog.py
index 4108f629a..e9f16906c 100644
--- a/deluge/ui/gtk3/createtorrentdialog.py
+++ b/deluge/ui/gtk3/createtorrentdialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -29,7 +28,7 @@ from .torrentview_data_funcs import cell_data_size
log = logging.getLogger(__name__)
-class CreateTorrentDialog(object):
+class CreateTorrentDialog:
def __init__(self):
pass
diff --git a/deluge/ui/gtk3/details_tab.py b/deluge/ui/gtk3/details_tab.py
index 2dde17aa6..04a5eabfe 100644
--- a/deluge/ui/gtk3/details_tab.py
+++ b/deluge/ui/gtk3/details_tab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -21,7 +20,7 @@ log = logging.getLogger(__name__)
class DetailsTab(Tab):
def __init__(self):
- super(DetailsTab, self).__init__('Details', 'details_tab', 'details_tab_label')
+ super().__init__('Details', 'details_tab', 'details_tab_label')
self.add_tab_widget('summary_name', None, ('name',))
self.add_tab_widget('summary_total_size', fsize, ('total_size',))
@@ -63,7 +62,7 @@ class DetailsTab(Tab):
txt = xml_escape(self.widget_status_as_fstr(widget, status))
if decode_bytes(widget.obj.get_text()) != txt:
if 'comment' in widget.status_keys and is_url(txt):
- widget.obj.set_markup('<a href="%s">%s</a>' % (txt, txt))
+ widget.obj.set_markup(f'<a href="{txt}">{txt}</a>')
else:
widget.obj.set_markup(txt)
diff --git a/deluge/ui/gtk3/dialogs.py b/deluge/ui/gtk3/dialogs.py
index 5bb332b03..6a2ae8629 100644
--- a/deluge/ui/gtk3/dialogs.py
+++ b/deluge/ui/gtk3/dialogs.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -32,7 +31,7 @@ class BaseDialog(Gtk.Dialog):
:param parent: gtkWindow, the parent window, if None it will default to the
MainWindow
"""
- super(BaseDialog, self).__init__(
+ super().__init__(
title=header,
parent=parent if parent else component.get('MainWindow').window,
flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
@@ -101,7 +100,7 @@ class YesNoDialog(BaseDialog):
:param text: see `:class:BaseDialog`
:param parent: see `:class:BaseDialog`
"""
- super(YesNoDialog, self).__init__(
+ super().__init__(
header,
text,
'dialog-question',
@@ -125,7 +124,7 @@ class InformationDialog(BaseDialog):
:param text: see `:class:BaseDialog`
:param parent: see `:class:BaseDialog`
"""
- super(InformationDialog, self).__init__(
+ super().__init__(
header,
text,
'dialog-information',
@@ -152,7 +151,7 @@ class ErrorDialog(BaseDialog):
:param traceback: show the traceback information in the details area
:type traceback: bool
"""
- super(ErrorDialog, self).__init__(
+ super().__init__(
header, text, 'dialog-error', (_('_Close'), Gtk.ResponseType.CLOSE), parent
)
@@ -196,7 +195,7 @@ class AuthenticationDialog(BaseDialog):
:param err_msg: the error message we got back from the server
:type err_msg: string
"""
- super(AuthenticationDialog, self).__init__(
+ super().__init__(
_('Authenticate'),
err_msg,
'dialog-password',
@@ -253,7 +252,7 @@ class AccountDialog(BaseDialog):
parent=None,
):
if username:
- super(AccountDialog, self).__init__(
+ super().__init__(
_('Edit Account'),
_('Edit existing account'),
'dialog-information',
@@ -266,7 +265,7 @@ class AccountDialog(BaseDialog):
parent,
)
else:
- super(AccountDialog, self).__init__(
+ super().__init__(
_('New Account'),
_('Create a new account'),
'dialog-information',
@@ -357,7 +356,7 @@ class OtherDialog(BaseDialog):
if not icon:
icon = 'dialog-information'
- super(OtherDialog, self).__init__(
+ super().__init__(
header,
text,
icon,
@@ -419,7 +418,7 @@ class PasswordDialog(BaseDialog):
:param password_msg: the error message we got back from the server
:type password_msg: string
"""
- super(PasswordDialog, self).__init__(
+ super().__init__(
header=_('Password Protected'),
text=password_msg,
icon='dialog-password',
diff --git a/deluge/ui/gtk3/edittrackersdialog.py b/deluge/ui/gtk3/edittrackersdialog.py
index 5e4b0e5e6..32ce2e76b 100644
--- a/deluge/ui/gtk3/edittrackersdialog.py
+++ b/deluge/ui/gtk3/edittrackersdialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -75,7 +74,7 @@ def trackers_tiers_from_text(text_str=''):
return trackers
-class EditTrackersDialog(object):
+class EditTrackersDialog:
def __init__(self, torrent_id, parent=None):
self.torrent_id = torrent_id
self.builder = Gtk.Builder()
@@ -190,7 +189,7 @@ class EditTrackersDialog(object):
self.old_trackers = list(status['trackers'])
for tracker in self.old_trackers:
self.add_tracker(tracker['tier'], tracker['url'])
- self.treeview.set_cursor((0))
+ self.treeview.set_cursor(0)
self.dialog.show()
def add_tracker(self, tier, url):
diff --git a/deluge/ui/gtk3/files_tab.py b/deluge/ui/gtk3/files_tab.py
index 61e0b9089..c8d8c0286 100644
--- a/deluge/ui/gtk3/files_tab.py
+++ b/deluge/ui/gtk3/files_tab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -82,7 +81,7 @@ def cell_progress(column, cell, model, row, data):
class FilesTab(Tab):
def __init__(self):
- super(FilesTab, self).__init__('Files', 'files_tab', 'files_tab_label')
+ super().__init__('Files', 'files_tab', 'files_tab_label')
self.listview = self.main_builder.get_object('files_listview')
# filename, size, progress string, progress value, priority, file index, icon id
diff --git a/deluge/ui/gtk3/filtertreeview.py b/deluge/ui/gtk3/filtertreeview.py
index 5b9c1e2fb..74474416d 100644
--- a/deluge/ui/gtk3/filtertreeview.py
+++ b/deluge/ui/gtk3/filtertreeview.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
# 2008 Andrew Resch <andrewresch@gmail.com>
@@ -88,7 +87,7 @@ class FilterTreeView(component.Component):
self.treeview.set_level_indentation(-21)
# Force theme to use expander-size so we don't cut out entries due to indentation hack.
provider = Gtk.CssProvider()
- provider.load_from_data('* {-GtkTreeView-expander-size: 9;}'.encode())
+ provider.load_from_data(b'* {-GtkTreeView-expander-size: 9;}')
context = self.treeview.get_style_context()
context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py
index 6c4972ba7..abbca263e 100644
--- a/deluge/ui/gtk3/gtkui.py
+++ b/deluge/ui/gtk3/gtkui.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -138,7 +137,7 @@ DEFAULT_PREFS = {
}
-class GtkUI(object):
+class GtkUI:
def __init__(self, args):
# Setup gtkbuilder/glade translation
setup_translation()
diff --git a/deluge/ui/gtk3/ipcinterface.py b/deluge/ui/gtk3/ipcinterface.py
index ac176479d..0ef28d8c0 100644
--- a/deluge/ui/gtk3/ipcinterface.py
+++ b/deluge/ui/gtk3/ipcinterface.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/gtk3/listview.py b/deluge/ui/gtk3/listview.py
index d828e5d86..f262e0ba3 100644
--- a/deluge/ui/gtk3/listview.py
+++ b/deluge/ui/gtk3/listview.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -18,7 +17,7 @@ from .common import cmp, load_pickled_state_file, save_pickled_state_file
log = logging.getLogger(__name__)
-class ListViewColumnState(object):
+class ListViewColumnState:
"""Class used for saving/loading column state."""
def __init__(self, name, position, width, visible, sort, sort_order):
@@ -30,13 +29,13 @@ class ListViewColumnState(object):
self.sort_order = sort_order
-class ListView(object):
+class ListView:
"""ListView is used to make custom GtkTreeViews. It supports the adding
and removing of columns, creating a menu for a column toggle list and
support for 'status_field's which are used while updating the columns data.
"""
- class ListViewColumn(object):
+ class ListViewColumn:
"""Holds information regarding a column in the ListView"""
def __init__(self, name, column_indices):
@@ -64,7 +63,7 @@ class ListView(object):
self.pixbuf_index = 0
self.data_func = None
- class TreeviewColumn(Gtk.TreeViewColumn, object):
+ class TreeviewColumn(Gtk.TreeViewColumn):
"""
TreeViewColumn does not signal right-click events, and we need them
This subclass is equivalent to TreeViewColumn, but it signals these events
diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py
index 43a419cb4..3da81c509 100644
--- a/deluge/ui/gtk3/mainwindow.py
+++ b/deluge/ui/gtk3/mainwindow.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -43,7 +42,7 @@ if windowing('X11'):
log = logging.getLogger(__name__)
-class _GtkBuilderSignalsHolder(object):
+class _GtkBuilderSignalsHolder:
def connect_signals(self, mapping_or_class):
if isinstance(mapping_or_class, dict):
diff --git a/deluge/ui/gtk3/menubar.py b/deluge/ui/gtk3/menubar.py
index 77b1d3a10..53d46ea97 100644
--- a/deluge/ui/gtk3/menubar.py
+++ b/deluge/ui/gtk3/menubar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
diff --git a/deluge/ui/gtk3/menubar_osx.py b/deluge/ui/gtk3/menubar_osx.py
index 096c5ffd4..53150fbf3 100644
--- a/deluge/ui/gtk3/menubar_osx.py
+++ b/deluge/ui/gtk3/menubar_osx.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/gtk3/new_release_dialog.py b/deluge/ui/gtk3/new_release_dialog.py
index a36b6f26d..a635bd2cd 100644
--- a/deluge/ui/gtk3/new_release_dialog.py
+++ b/deluge/ui/gtk3/new_release_dialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -15,7 +14,7 @@ from deluge.configmanager import ConfigManager
from deluge.ui.client import client
-class NewReleaseDialog(object):
+class NewReleaseDialog:
def __init__(self):
pass
diff --git a/deluge/ui/gtk3/options_tab.py b/deluge/ui/gtk3/options_tab.py
index e592ad53e..48733d129 100644
--- a/deluge/ui/gtk3/options_tab.py
+++ b/deluge/ui/gtk3/options_tab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
# 2017 Calum Lind <calumlind+deluge@gmail.com>
@@ -19,7 +18,7 @@ from .torrentdetails import Tab
class OptionsTab(Tab):
def __init__(self):
- super(OptionsTab, self).__init__('Options', 'options_tab', 'options_tab_label')
+ super().__init__('Options', 'options_tab', 'options_tab_label')
self.prev_torrent_ids = None
self.prev_status = None
diff --git a/deluge/ui/gtk3/path_chooser.py b/deluge/ui/gtk3/path_chooser.py
index 952196916..805819660 100644
--- a/deluge/ui/gtk3/path_chooser.py
+++ b/deluge/ui/gtk3/path_chooser.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 Bro <bro.development@gmail.com>
#
@@ -123,7 +122,7 @@ class PathChoosersHandler(component.Component):
class PathChooser(PathChooserComboBox):
def __init__(self, paths_config_key=None, parent=None):
self.paths_config_key = paths_config_key
- super(PathChooser, self).__init__(parent=parent)
+ super().__init__(parent=parent)
self.chooser_handler = PathChoosersHandler()
self.chooser_handler.register_chooser(self)
self.set_auto_completer_func(self.on_completion)
diff --git a/deluge/ui/gtk3/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py
index 755ae5fe1..0eb13b2c3 100755
--- a/deluge/ui/gtk3/path_combo_chooser.py
+++ b/deluge/ui/gtk3/path_combo_chooser.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 Bro <bro.development@gmail.com>
#
@@ -62,7 +61,7 @@ def path_without_trailing_path_sep(path):
return path
-class ValueList(object):
+class ValueList:
paths_without_trailing_path_sep = False
@@ -174,7 +173,7 @@ class ValueList(object):
"""
for i, row in enumerate(self.tree_store):
if row[0] == value:
- self.treeview.set_cursor((i))
+ self.treeview.set_cursor(i)
return
# The value was not found
if select_first:
@@ -372,7 +371,7 @@ class StoredValuesList(ValueList):
"""
# This is left click
if event.button != 3:
- super(StoredValuesList, self).on_treeview_mouse_button_press_event(
+ super().on_treeview_mouse_button_press_event(
treeview, event, double_click=True
)
return False
@@ -410,9 +409,7 @@ class StoredValuesList(ValueList):
PathChooserPopup.popup(self)
def on_stored_values_treeview_key_press_event(self, widget, event):
- super(StoredValuesList, self).on_value_list_treeview_key_press_event(
- widget, event
- )
+ super().on_value_list_treeview_key_press_event(widget, event)
# Prevent the default event handler to move the cursor in the list
if key_is_up_or_down(event.keyval):
return True
@@ -477,9 +474,9 @@ class CompletionList(ValueList):
] = self.on_completion_treeview_motion_notify_event
# Add super class signal handler
- self.signal_handlers['on_completion_treeview_mouse_button_press_event'] = super(
- CompletionList, self
- ).on_treeview_mouse_button_press_event
+ self.signal_handlers[
+ 'on_completion_treeview_mouse_button_press_event'
+ ] = super().on_treeview_mouse_button_press_event
def reduce_values(self, prefix):
"""
@@ -497,9 +494,7 @@ class CompletionList(ValueList):
self.add_values(matching_values, clear=True)
def on_completion_treeview_key_press_event(self, widget, event):
- ret = super(CompletionList, self).on_value_list_treeview_key_press_event(
- widget, event
- )
+ ret = super().on_value_list_treeview_key_press_event(widget, event)
if ret:
return ret
keyval = event.keyval
@@ -527,7 +522,7 @@ class CompletionList(ValueList):
self.handle_list_scroll(path=path[0], _next=None)
-class PathChooserPopup(object):
+class PathChooserPopup:
"""This creates the popop window for the ComboEntry."""
def __init__(self, min_visible_rows, max_visible_rows, popup_alignment_widget):
@@ -981,7 +976,7 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
return True
-class PathAutoCompleter(object):
+class PathAutoCompleter:
def __init__(self, builder, path_entry, max_visible_rows):
self.completion_popup = PathCompletionPopup(
builder, path_entry, max_visible_rows
@@ -1462,7 +1457,7 @@ class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject):
)
return True
elif is_ascii_value(keyval, 's'):
- super(PathChooserComboBox, self).add_current_value_to_saved_list()
+ super().add_current_value_to_saved_list()
return True
elif is_ascii_value(keyval, 'd'):
# Set the default value in the text entry
@@ -1692,7 +1687,7 @@ if __name__ == '__main__':
box1 = Gtk.Box.new(Gtk.Orientation.VERTICAL, spacing=0)
def get_resource2(filename):
- return '%s/glade/%s' % (os.path.abspath(os.path.dirname(sys.argv[0])), filename)
+ return f'{os.path.abspath(os.path.dirname(sys.argv[0]))}/glade/{filename}'
# Override get_resource which fetches from deluge install
# get_resource = get_resource2
diff --git a/deluge/ui/gtk3/peers_tab.py b/deluge/ui/gtk3/peers_tab.py
index afd4774be..b458f7a7d 100644
--- a/deluge/ui/gtk3/peers_tab.py
+++ b/deluge/ui/gtk3/peers_tab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -45,7 +44,7 @@ log = logging.getLogger(__name__)
class PeersTab(Tab):
def __init__(self):
- super(PeersTab, self).__init__('Peers', 'peers_tab', 'peers_tab_label')
+ super().__init__('Peers', 'peers_tab', 'peers_tab_label')
self.peer_menu = self.main_builder.get_object('menu_peer_tab')
component.get('MainWindow').connect_signals(self)
@@ -305,7 +304,7 @@ class PeersTab(Tab):
ip_int = int(
binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16
)
- peer_ip = '[%s]:%s' % (ip, peer['ip'].split(':')[-1])
+ peer_ip = '[{}]:{}'.format(ip, peer['ip'].split(':')[-1])
if peer['seed']:
icon = self.seed_pixbuf
diff --git a/deluge/ui/gtk3/piecesbar.py b/deluge/ui/gtk3/piecesbar.py
index 6f0b98052..368d598bc 100644
--- a/deluge/ui/gtk3/piecesbar.py
+++ b/deluge/ui/gtk3/piecesbar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
#
@@ -32,7 +31,7 @@ class PiecesBar(DrawingArea):
__gsignals__ = {'draw': 'override'}
def __init__(self):
- super(PiecesBar, self).__init__()
+ super().__init__()
# Get progress bar styles, in order to keep font consistency
pb = ProgressBar()
pb_style = pb.get_style_context()
diff --git a/deluge/ui/gtk3/pluginmanager.py b/deluge/ui/gtk3/pluginmanager.py
index 017798ab9..63353c0df 100644
--- a/deluge/ui/gtk3/pluginmanager.py
+++ b/deluge/ui/gtk3/pluginmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/gtk3/preferences.py b/deluge/ui/gtk3/preferences.py
index ee6d23dfd..50d35d586 100644
--- a/deluge/ui/gtk3/preferences.py
+++ b/deluge/ui/gtk3/preferences.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
diff --git a/deluge/ui/gtk3/queuedtorrents.py b/deluge/ui/gtk3/queuedtorrents.py
index f2aa851b8..6fdecec76 100644
--- a/deluge/ui/gtk3/queuedtorrents.py
+++ b/deluge/ui/gtk3/queuedtorrents.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/gtk3/removetorrentdialog.py b/deluge/ui/gtk3/removetorrentdialog.py
index cc0cffedc..06fca7704 100644
--- a/deluge/ui/gtk3/removetorrentdialog.py
+++ b/deluge/ui/gtk3/removetorrentdialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -19,7 +18,7 @@ from deluge.ui.client import client
log = logging.getLogger(__name__)
-class RemoveTorrentDialog(object):
+class RemoveTorrentDialog:
"""
This class is used to create and show a Remove Torrent Dialog.
diff --git a/deluge/ui/gtk3/sidebar.py b/deluge/ui/gtk3/sidebar.py
index 7cf637761..5a2b15466 100644
--- a/deluge/ui/gtk3/sidebar.py
+++ b/deluge/ui/gtk3/sidebar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
diff --git a/deluge/ui/gtk3/status_tab.py b/deluge/ui/gtk3/status_tab.py
index c1fe9ccba..6a9010b6f 100644
--- a/deluge/ui/gtk3/status_tab.py
+++ b/deluge/ui/gtk3/status_tab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -30,7 +29,7 @@ log = logging.getLogger(__name__)
class StatusTab(Tab):
def __init__(self):
- super(StatusTab, self).__init__('Status', 'status_tab', 'status_tab_label')
+ super().__init__('Status', 'status_tab', 'status_tab_label')
self.config = ConfigManager('gtk3ui.conf')
diff --git a/deluge/ui/gtk3/statusbar.py b/deluge/ui/gtk3/statusbar.py
index fda235eeb..3001a49ee 100644
--- a/deluge/ui/gtk3/statusbar.py
+++ b/deluge/ui/gtk3/statusbar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -23,7 +22,7 @@ from .dialogs import OtherDialog
log = logging.getLogger(__name__)
-class StatusBarItem(object):
+class StatusBarItem:
def __init__(
self,
image=None,
@@ -410,7 +409,7 @@ class StatusBar(component.Component):
if self.max_connections_global < 0:
label_string = '%s' % self.num_connections
else:
- label_string = '%s <small>(%s)</small>' % (
+ label_string = '{} <small>({})</small>'.format(
self.num_connections,
self.max_connections_global,
)
diff --git a/deluge/ui/gtk3/systemtray.py b/deluge/ui/gtk3/systemtray.py
index ef497747d..f65fde590 100644
--- a/deluge/ui/gtk3/systemtray.py
+++ b/deluge/ui/gtk3/systemtray.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -236,13 +235,13 @@ class SystemTray(component.Component):
if max_download_speed == -1:
max_download_speed = _('Unlimited')
else:
- max_download_speed = '%s %s' % (max_download_speed, _('K/s'))
+ max_download_speed = '{} {}'.format(max_download_speed, _('K/s'))
if max_upload_speed == -1:
max_upload_speed = _('Unlimited')
else:
- max_upload_speed = '%s %s' % (max_upload_speed, _('K/s'))
+ max_upload_speed = '{} {}'.format(max_upload_speed, _('K/s'))
- msg = '%s\n%s: %s (%s)\n%s: %s (%s)' % (
+ msg = '{}\n{}: {} ({})\n{}: {} ({})'.format(
_('Deluge'),
_('Down'),
self.download_rate,
diff --git a/deluge/ui/gtk3/tab_data_funcs.py b/deluge/ui/gtk3/tab_data_funcs.py
index e0fb74587..a78994f69 100644
--- a/deluge/ui/gtk3/tab_data_funcs.py
+++ b/deluge/ui/gtk3/tab_data_funcs.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -12,7 +11,7 @@ from deluge.ui.common import TRACKER_STATUS_TRANSLATION
def ftotal_sized(first, second):
- return '%s (%s)' % (fsize(first, shortform=True), fsize(second, shortform=True))
+ return f'{fsize(first, shortform=True)} ({fsize(second, shortform=True)})'
def fratio(value):
@@ -22,7 +21,7 @@ def fratio(value):
def fpcnt(value, state, message):
state_i18n = _(state)
if state not in ('Error', 'Seeding') and value < 100:
- percent = '{:.2f}'.format(value).rstrip('0').rstrip('.')
+ percent = f'{value:.2f}'.rstrip('0').rstrip('.')
return _('{state} {percent}%').format(state=state_i18n, percent=percent)
elif state == 'Error':
return _('{state}: {err_msg}').format(state=state_i18n, err_msg=message)
@@ -32,7 +31,7 @@ def fpcnt(value, state, message):
def fspeed_max(value, max_value=-1):
value = fspeed(value, shortform=True)
- return '%s (%s %s)' % (value, max_value, _('K/s')) if max_value > -1 else value
+ return '{} ({} {})'.format(value, max_value, _('K/s')) if max_value > -1 else value
def fdate_or_never(value):
@@ -71,7 +70,7 @@ def fseed_rank_or_dash(seed_rank, seeding_time):
def fpieces_num_size(num_pieces, piece_size):
- return '%s (%s)' % (num_pieces, fsize(piece_size, precision=0))
+ return f'{num_pieces} ({fsize(piece_size, precision=0)})'
def fcount(value):
diff --git a/deluge/ui/gtk3/toolbar.py b/deluge/ui/gtk3/toolbar.py
index 600fce738..1b6952e74 100644
--- a/deluge/ui/gtk3/toolbar.py
+++ b/deluge/ui/gtk3/toolbar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/gtk3/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py
index 888ae5e38..08c37a1de 100644
--- a/deluge/ui/gtk3/torrentdetails.py
+++ b/deluge/ui/gtk3/torrentdetails.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
@@ -31,7 +30,7 @@ log = logging.getLogger(__name__)
TabWidget = namedtuple('TabWidget', ('obj', 'func', 'status_keys'))
-class Tab(object):
+class Tab:
def __init__(self, name=None, child_widget=None, tab_label=None):
self._name = name
self.is_visible = True
diff --git a/deluge/ui/gtk3/torrentview.py b/deluge/ui/gtk3/torrentview.py
index 3bc8bbacd..16de16ea7 100644
--- a/deluge/ui/gtk3/torrentview.py
+++ b/deluge/ui/gtk3/torrentview.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -105,7 +104,7 @@ def progress_sort(model, iter1, iter2, sort_column_id):
return cmp(progress1, progress2)
-class SearchBox(object):
+class SearchBox:
def __init__(self, torrentview):
self.torrentview = torrentview
mainwindow = component.get('MainWindow')
diff --git a/deluge/ui/gtk3/torrentview_data_funcs.py b/deluge/ui/gtk3/torrentview_data_funcs.py
index 91d4663bc..7f1fc606c 100644
--- a/deluge/ui/gtk3/torrentview_data_funcs.py
+++ b/deluge/ui/gtk3/torrentview_data_funcs.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -160,7 +159,7 @@ def cell_data_speed(cell, model, row, data):
if speed > 0:
speed_str = common.fspeed(speed, shortform=True)
cell.set_property(
- 'markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))
+ 'markup', '{} <small>{}</small>'.format(*tuple(speed_str.split()))
)
else:
cell.set_property('text', '')
@@ -187,7 +186,7 @@ def cell_data_speed_limit(cell, model, row, data, cache_key):
if speed > 0:
speed_str = common.fspeed(speed * 1024, shortform=True)
cell.set_property(
- 'markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))
+ 'markup', '{} <small>{}</small>'.format(*tuple(speed_str.split()))
)
else:
cell.set_property('text', '')
diff --git a/deluge/ui/gtk3/trackers_tab.py b/deluge/ui/gtk3/trackers_tab.py
index 6accf1d67..d671471b0 100644
--- a/deluge/ui/gtk3/trackers_tab.py
+++ b/deluge/ui/gtk3/trackers_tab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
#
@@ -20,9 +19,7 @@ log = logging.getLogger(__name__)
class TrackersTab(Tab):
def __init__(self):
- super(TrackersTab, self).__init__(
- 'Trackers', 'trackers_tab', 'trackers_tab_label'
- )
+ super().__init__('Trackers', 'trackers_tab', 'trackers_tab_label')
self.add_tab_widget('summary_next_announce', ftime, ('next_announce',))
self.add_tab_widget('summary_tracker', None, ('tracker_host',))
diff --git a/deluge/ui/hostlist.py b/deluge/ui/hostlist.py
index 5d0e68c7a..7e2f397d0 100644
--- a/deluge/ui/hostlist.py
+++ b/deluge/ui/hostlist.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) Calum Lind 2017 <calumlind+deluge@gmail.com>
#
@@ -85,7 +84,7 @@ def migrate_config_2_to_3(config):
return config
-class HostList(object):
+class HostList:
"""This class contains methods for adding, removing and looking up hosts in hostlist.conf."""
def __init__(self):
diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py
index b89d04dfc..a79144e0c 100644
--- a/deluge/ui/sessionproxy.py
+++ b/deluge/ui/sessionproxy.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 Andrew Resch <andrewresch@gmail.com>
#
diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py
index a1bcd78b5..a771a0ecf 100644
--- a/deluge/ui/tracker_icons.py
+++ b/deluge/ui/tracker_icons.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
#
@@ -30,7 +29,7 @@ except ImportError:
log = logging.getLogger(__name__)
-class TrackerIcon(object):
+class TrackerIcon:
"""
Represents a tracker's icon
"""
@@ -290,7 +289,7 @@ class TrackerIcons(Component):
:returns: a Deferred which callbacks a list of available favicons (url, type)
:rtype: Deferred
"""
- with open(page, 'r') as _file:
+ with open(page) as _file:
parser = FaviconParser()
for line in _file:
parser.feed(line)
@@ -374,7 +373,7 @@ class TrackerIcons(Component):
try:
with Image.open(icon_name):
pass
- except IOError as ex:
+ except OSError as ex:
raise InvalidIconError(ex)
else:
if not os.path.getsize(icon_name):
diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py
index 3c75f2acd..cb92d1e07 100644
--- a/deluge/ui/ui.py
+++ b/deluge/ui/ui.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
#
@@ -25,7 +24,7 @@ except ImportError:
return
-class UI(object):
+class UI:
"""
Base class for UI implementations.
diff --git a/deluge/ui/ui_entry.py b/deluge/ui/ui_entry.py
index eae56bf6a..e185fda33 100644
--- a/deluge/ui/ui_entry.py
+++ b/deluge/ui/ui_entry.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
@@ -98,7 +97,7 @@ def start_ui():
# If the UI is set as default, indicate this in help by prefixing with a star.
subactions = subparsers._get_subactions()
prefix = '*' if ui == default_ui else ' '
- subactions[-1].metavar = '%s %s' % (prefix, ui)
+ subactions[-1].metavar = f'{prefix} {ui}'
# Insert a default UI subcommand unless one of the ambiguous_args are specified
parser.set_default_subparser(default_ui, abort_opts=AMBIGUOUS_CMD_ARGS)
@@ -113,7 +112,7 @@ def start_ui():
try:
ui = ui_entrypoints[selected_ui](
- prog='%s %s' % (os.path.basename(sys.argv[0]), selected_ui), ui_args=ui_args
+ prog=f'{os.path.basename(sys.argv[0])} {selected_ui}', ui_args=ui_args
)
except KeyError:
log.error(
diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py
index 9c8158a52..eacbbf526 100644
--- a/deluge/ui/web/auth.py
+++ b/deluge/ui/web/auth.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
#
@@ -62,7 +61,7 @@ class Auth(JSONComponent):
"""
def __init__(self, config):
- super(Auth, self).__init__('Auth')
+ super().__init__('Auth')
self.worker = LoopingCall(self._clean_sessions)
self.config = config
diff --git a/deluge/ui/web/common.py b/deluge/ui/web/common.py
index a8c223d19..32c29c8c0 100644
--- a/deluge/ui/web/common.py
+++ b/deluge/ui/web/common.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
#
diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py
index 822f65483..aa15d5ac6 100644
--- a/deluge/ui/web/json_api.py
+++ b/deluge/ui/web/json_api.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2010 Damien Churchill <damoxc@gmail.com>
#
@@ -37,7 +36,7 @@ log = logging.getLogger(__name__)
class JSONComponent(component.Component):
def __init__(self, name, interval=1, depend=None):
- super(JSONComponent, self).__init__(name, interval, depend)
+ super().__init__(name, interval, depend)
self._json = component.get('JSON')
self._json.register_object(self, name)
@@ -144,7 +143,7 @@ class JSON(resource.Resource, component.Component):
params = request_data['params']
request_id = request_data['id']
except KeyError as ex:
- message = 'Invalid JSON request, missing param %s in %s' % (
+ message = 'Invalid JSON request, missing param {} in {}'.format(
ex,
request_data,
)
@@ -165,7 +164,7 @@ class JSON(resource.Resource, component.Component):
except Exception as ex:
log.error('Error calling method `%s`: %s', method, ex)
log.exception(ex)
- error = {'message': '%s: %s' % (ex.__class__.__name__, str(ex)), 'code': 3}
+ error = {'message': f'{ex.__class__.__name__}: {str(ex)}', 'code': 3}
return request_id, result, error
@@ -182,7 +181,7 @@ class JSON(resource.Resource, component.Component):
"""
log.error(reason)
response['error'] = {
- 'message': '%s: %s' % (reason.__class__.__name__, str(reason)),
+ 'message': f'{reason.__class__.__name__}: {str(reason)}',
'code': 4,
}
return self._send_response(request, response)
@@ -219,7 +218,7 @@ class JSON(resource.Resource, component.Component):
'id': None,
'error': {
'code': 5,
- 'message': '%s: %s' % (reason.__class__.__name__, str(reason)),
+ 'message': f'{reason.__class__.__name__}: {str(reason)}',
},
}
return self._send_response(request, response)
@@ -286,7 +285,7 @@ class JSON(resource.Resource, component.Component):
FILES_KEYS = ['files', 'file_progress', 'file_priorities']
-class EventQueue(object):
+class EventQueue:
"""
This class subscribes to events from the core and stores them until all
the subscribed listeners have received the events.
@@ -379,7 +378,7 @@ class WebApi(JSONComponent):
XSS_VULN_KEYS = ['name', 'message', 'comment', 'tracker_status', 'peers']
def __init__(self):
- super(WebApi, self).__init__('Web', depend=['SessionProxy'])
+ super().__init__('Web', depend=['SessionProxy'])
self.hostlist = HostList()
self.core_config = CoreConfig()
self.event_queue = EventQueue()
@@ -1004,7 +1003,7 @@ class WebUtils(JSONComponent):
"""
def __init__(self):
- super(WebUtils, self).__init__('WebUtils')
+ super().__init__('WebUtils')
@export
def get_languages(self):
diff --git a/deluge/ui/web/pluginmanager.py b/deluge/ui/web/pluginmanager.py
index 153d4977a..2da5b6177 100644
--- a/deluge/ui/web/pluginmanager.py
+++ b/deluge/ui/web/pluginmanager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
#
@@ -72,22 +71,20 @@ class PluginManager(PluginManagerBase, component.Component):
scripts = component.get('Scripts')
for script in info['scripts']:
- scripts.remove_script(
- '%s/%s' % (name.lower(), os.path.basename(script).lower())
- )
+ scripts.remove_script(f'{name.lower()}/{os.path.basename(script).lower()}')
for script in info['debug_scripts']:
scripts.remove_script(
- '%s/%s' % (name.lower(), os.path.basename(script).lower()), 'debug'
+ f'{name.lower()}/{os.path.basename(script).lower()}', 'debug'
)
scripts.remove_script(
- '%s/%s' % (name.lower(), os.path.basename(script).lower()), 'dev'
+ f'{name.lower()}/{os.path.basename(script).lower()}', 'dev'
)
- super(PluginManager, self).disable_plugin(name)
+ super().disable_plugin(name)
def enable_plugin(self, name):
- super(PluginManager, self).enable_plugin(name)
+ super().enable_plugin(name)
# Get the plugin instance
try:
@@ -103,17 +100,15 @@ class PluginManager(PluginManagerBase, component.Component):
scripts = component.get('Scripts')
for script in info['scripts']:
log.debug('adding script %s for %s', name, os.path.basename(script))
- scripts.add_script(
- '%s/%s' % (name.lower(), os.path.basename(script)), script
- )
+ scripts.add_script(f'{name.lower()}/{os.path.basename(script)}', script)
for script in info['debug_scripts']:
log.debug('adding debug script %s for %s', name, os.path.basename(script))
scripts.add_script(
- '%s/%s' % (name.lower(), os.path.basename(script)), script, 'debug'
+ f'{name.lower()}/{os.path.basename(script)}', script, 'debug'
)
scripts.add_script(
- '%s/%s' % (name.lower(), os.path.basename(script)), script, 'dev'
+ f'{name.lower()}/{os.path.basename(script)}', script, 'dev'
)
def start(self):
@@ -149,11 +144,10 @@ class PluginManager(PluginManagerBase, component.Component):
info = gather_info(plugin)
info['name'] = name
info['scripts'] = [
- 'js/%s/%s' % (name.lower(), os.path.basename(s)) for s in info['scripts']
+ f'js/{name.lower()}/{os.path.basename(s)}' for s in info['scripts']
]
info['debug_scripts'] = [
- 'js/%s/%s' % (name.lower(), os.path.basename(s))
- for s in info['debug_scripts']
+ f'js/{name.lower()}/{os.path.basename(s)}' for s in info['debug_scripts']
]
del info['script_directories']
return info
diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py
index 3f079aefb..f391a78d2 100644
--- a/deluge/ui/web/server.py
+++ b/deluge/ui/web/server.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2010 Damien Churchill <damoxc@gmail.com>
#
@@ -373,7 +372,7 @@ class ScriptResource(resource.Resource, component.Component):
order_file = os.path.join(root, '.order')
if os.path.isfile(order_file):
- with open(order_file, 'r') as _file:
+ with open(order_file) as _file:
for line in _file:
if line.startswith('+ '):
order_filename = line.split()[1]
diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py
index 0cefa13b4..f855bd06c 100644
--- a/deluge/ui/web/web.py
+++ b/deluge/ui/web/web.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
#
@@ -22,7 +21,7 @@ class Web(UI):
cmd_description = """Web-based user interface (http://localhost:8112)"""
def __init__(self, *args, **kwargs):
- super(Web, self).__init__(
+ super().__init__(
'web', *args, description='Starts the Deluge Web interface', **kwargs
)
self.__server = None
@@ -65,7 +64,7 @@ class Web(UI):
return self.__server
def start(self):
- super(Web, self).start()
+ super().start()
from deluge.ui.web import server
diff --git a/docs/source/conf.py b/docs/source/conf.py
index c04a20452..f04653e03 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Deluge documentation build configuration file
#
@@ -219,7 +218,7 @@ latex_documents = [
# Autodoc section
# ---------------
-class Mock(object):
+class Mock:
__all__ = []
diff --git a/docs/source/devguide/how-to/update-1.3-plugin.md b/docs/source/devguide/how-to/update-1.3-plugin.md
index 9c086902b..9ce6ae14c 100644
--- a/docs/source/devguide/how-to/update-1.3-plugin.md
+++ b/docs/source/devguide/how-to/update-1.3-plugin.md
@@ -11,7 +11,7 @@ compatible with 2.0 and this guide aims to helps with that process.
### Python version matching
-Ensure your code is Python >=3.5 compatible.
+Ensure your code is Python >=3.6 compatible.
In `1.3-stable` the plugins that were built with a specific version of Python
would only be loaded if the system Python also matched.
diff --git a/gen_web_gettext.py b/gen_web_gettext.py
index c299e429f..80186e938 100755
--- a/gen_web_gettext.py
+++ b/gen_web_gettext.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2012 Damien Churchill <damoxc@gmail.com>
#
@@ -117,4 +116,4 @@ if __name__ == '__main__':
print('Possible missed text for translation markup:')
for text, filenames in missed_markup.iteritems():
for filename_lineno in filenames:
- print('{0:<58} {1}'.format(':'.join(filename_lineno), text))
+ print('{:<58} {}'.format(':'.join(filename_lineno), text))
diff --git a/generate_pot.py b/generate_pot.py
index 47d3b9f99..efbdc7824 100755
--- a/generate_pot.py
+++ b/generate_pot.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2013 Calum Lind <calumlind@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -89,7 +88,7 @@ with open(INFILES_LIST, 'w') as f:
call(xgettext_cmd + ['--language=Python', '-j'])
# Replace YEAR and PACKAGE in the copyright message
-with open(POT_FILEPATH, 'r') as f:
+with open(POT_FILEPATH) as f:
lines = f.readlines()
with open(POT_FILEPATH, 'w') as f:
for line in lines:
diff --git a/minify_web_js.py b/minify_web_js.py
index b91a96329..614794a97 100755
--- a/minify_web_js.py
+++ b/minify_web_js.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Calum Lind <calumlind@gmail.com>
# Copyright (C) 2010 Damien Churchill <damoxc@gmail.com>
@@ -70,7 +69,7 @@ def source_files_list(source_dir):
order_file = os.path.join(root, '.order')
if os.path.isfile(order_file):
- with open(order_file, 'r') as _file:
+ with open(order_file) as _file:
for line in _file:
if line.startswith('+ '):
order_filename = line.split()[1]
@@ -97,7 +96,7 @@ def minify_file(file_debug, file_minified):
return minify_closure(file_debug, file_minified)
elif minify:
with open(file_minified, 'w') as file_out:
- with open(file_debug, 'r') as file_in:
+ with open(file_debug) as file_in:
file_out.write(minify(file_in.read()))
return True
diff --git a/msgfmt.py b/msgfmt.py
index 4d0b83911..0d5367c3b 100755
--- a/msgfmt.py
+++ b/msgfmt.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
# Written by Martin v. Lwis <loewis@informatik.hu-berlin.de>
# Plural forms support added by alexander smishlajev <alex@tycobka.lv>
"""
@@ -122,11 +121,9 @@ def make(filename, outfile):
outfile = os.path.splitext(infile)[0] + '.mo'
try:
- import io
-
- with io.open(infile, encoding='utf8') as _file:
+ with open(infile, encoding='utf8') as _file:
lines = _file.readlines()
- except IOError as msg:
+ except OSError as msg:
print(msg, file=sys.stderr)
sys.exit(1)
@@ -194,7 +191,7 @@ def make(filename, outfile):
try:
with open(outfile, 'wb') as _file:
_file.write(output)
- except IOError as msg:
+ except OSError as msg:
print(msg, file=sys.stderr)
diff --git a/packaging/source/make_release.py b/packaging/source/make_release.py
index 38fc3d566..277d1cedc 100755
--- a/packaging/source/make_release.py
+++ b/packaging/source/make_release.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright 2014 Calum Lind <calumlind@gmail.com>
#
@@ -46,7 +45,7 @@ else:
# Calculate shasum and add to sha256sums.txt
with open(tarxz_path, 'rb') as _file:
- sha256sum = '%s %s' % (
+ sha256sum = '{} {}'.format(
sha256(_file.read()).hexdigest(),
os.path.basename(tarxz_path),
)
diff --git a/packaging/win32/deluge-bbfreeze.py b/packaging/win32/deluge-bbfreeze.py
index 5cd3e35a7..340a643fd 100644
--- a/packaging/win32/deluge-bbfreeze.py
+++ b/packaging/win32/deluge-bbfreeze.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2015 Calum Lind <calumlind@gmail.com>
# Copyright (C) 2010 Damien Churchill <damoxc@gmail.com>
@@ -11,7 +10,6 @@
# See LICENSE for more details.
#
# isort:skip_file
-from __future__ import print_function
import glob
import os
@@ -27,7 +25,7 @@ from win32verstamp import stamp
import deluge.common
-class VersionInfo(object):
+class VersionInfo:
def __init__(
self,
version,
diff --git a/setup.py b/setup.py
index 181d74cd8..a939ebd29 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
@@ -28,7 +27,7 @@ try:
from sphinx.setup_command import BuildDoc
except ImportError:
- class BuildDoc(object):
+ class BuildDoc:
pass
@@ -80,7 +79,7 @@ class CleanDocs(Command):
def run(self):
docs_build = 'docs/build'
- print('Deleting {}'.format(docs_build))
+ print(f'Deleting {docs_build}')
try:
rmtree(docs_build)
except OSError:
@@ -158,7 +157,7 @@ class CleanWebUI(Command):
for js_src_dir in BuildWebUI.JS_SRC_DIRS:
for file_type in ('.js', '-debug.js'):
js_file = os.path.join(js_basedir, js_src_dir + file_type)
- print('Deleting {}'.format(js_file))
+ print(f'Deleting {js_file}')
try:
os.remove(js_file)
except OSError:
@@ -166,7 +165,7 @@ class CleanWebUI(Command):
# Remove generated gettext.js
js_file = os.path.join(js_basedir, 'gettext.js')
- print('Deleting {}'.format(js_file))
+ print(f'Deleting {js_file}')
try:
os.remove(js_file)
except OSError:
@@ -390,7 +389,7 @@ class Build(_build):
try:
from deluge._libtorrent import LT_VERSION
- print('Info: Found libtorrent ({}) installed.'.format(LT_VERSION))
+ print(f'Info: Found libtorrent ({LT_VERSION}) installed.')
except ImportError as ex:
print('Warning: libtorrent (libtorrent-rasterbar) not found: %s' % ex)
@@ -455,7 +454,7 @@ if not windows_check() and not osx_check():
for icon_path in glob.glob('deluge/ui/data/icons/hicolor/*x*'):
size = os.path.basename(icon_path)
icons = glob.glob(os.path.join(icon_path, 'apps', 'deluge*.png'))
- _data_files.append(('share/icons/hicolor/{}/apps'.format(size), icons))
+ _data_files.append((f'share/icons/hicolor/{size}/apps', icons))
_data_files.extend(
[
(
@@ -590,7 +589,7 @@ setup(
'Operating System :: POSIX',
'Topic :: Internet',
],
- python_requires='>=3.5',
+ python_requires='>=3.6',
license='GPLv3+',
cmdclass=cmdclass,
setup_requires=setup_requires,
diff --git a/version.py b/version.py
index 28d071093..26098605d 100755
--- a/version.py
+++ b/version.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
# Authors: Douglas Creager <dcreager@dcreager.net>
# Calum Lind <calumlind@gmail.com>
#
@@ -56,9 +55,9 @@ def call_git_describe(prefix='', suffix=''):
def get_version(prefix='deluge-', suffix='.dev0'):
try:
- with open(VERSION_FILE, 'r') as f:
+ with open(VERSION_FILE) as f:
release_version = f.readline().strip()
- except IOError:
+ except OSError:
release_version = None
version = call_git_describe(prefix, suffix)