summaryrefslogtreecommitdiffstats
path: root/deluge/ui
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 /deluge/ui
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
Diffstat (limited to 'deluge/ui')
-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
106 files changed, 211 insertions, 334 deletions
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