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
This commit is contained in:
parent
16895b4a49
commit
ec0bcc11f5
|
@ -41,3 +41,9 @@ repos:
|
|||
args: [--fix=auto]
|
||||
- id: trailing-whitespace
|
||||
name: Fix Trailing whitespace
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.29.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py36-plus]
|
||||
stages: [manual]
|
||||
|
|
|
@ -7,7 +7,7 @@ All modules will require the [common](#common) section dependencies.
|
|||
|
||||
## Prerequisite
|
||||
|
||||
- [Python] _>= 3.5_
|
||||
- [Python] _>= 3.6_
|
||||
|
||||
## Build
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -32,5 +31,5 @@ LT_VERSION = lt.__version__
|
|||
|
||||
if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
|
||||
raise LibtorrentImportError(
|
||||
'Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION)
|
||||
f'Deluge {get_version()} requires libtorrent >= {REQUIRED_VERSION}'
|
||||
)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -93,7 +92,7 @@ def _get_version_detail():
|
|||
except ImportError:
|
||||
pass
|
||||
version_str += 'Python: %s\n' % platform.python_version()
|
||||
version_str += 'OS: %s %s\n' % (platform.system(), common.get_os_version())
|
||||
version_str += f'OS: {platform.system()} {common.get_os_version()}\n'
|
||||
return version_str
|
||||
|
||||
|
||||
|
@ -135,7 +134,7 @@ class DelugeTextHelpFormatter(argparse.RawDescriptionHelpFormatter):
|
|||
default = action.dest.upper()
|
||||
args_string = self._format_args(action, default)
|
||||
opt = ', '.join(action.option_strings)
|
||||
parts.append('%s %s' % (opt, args_string))
|
||||
parts.append(f'{opt} {args_string}')
|
||||
return ', '.join(parts)
|
||||
|
||||
|
||||
|
@ -163,7 +162,7 @@ class ArgParserBase(argparse.ArgumentParser):
|
|||
self.log_stream = kwargs['log_stream']
|
||||
del kwargs['log_stream']
|
||||
|
||||
super(ArgParserBase, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.common_setup = False
|
||||
self.process_arg_group = False
|
||||
|
@ -244,7 +243,7 @@ class ArgParserBase(argparse.ArgumentParser):
|
|||
argparse.Namespace: The parsed arguments.
|
||||
|
||||
"""
|
||||
options = super(ArgParserBase, self).parse_args(args=args)
|
||||
options = super().parse_args(args=args)
|
||||
return self._handle_ui_options(options)
|
||||
|
||||
def parse_known_ui_args(self, args, withhold=None):
|
||||
|
@ -260,7 +259,7 @@ class ArgParserBase(argparse.ArgumentParser):
|
|||
"""
|
||||
if withhold:
|
||||
args = [a for a in args if a not in withhold]
|
||||
options, remaining = super(ArgParserBase, self).parse_known_args(args=args)
|
||||
options, remaining = super().parse_known_args(args=args)
|
||||
options.remaining = remaining
|
||||
# Handle common and process group options
|
||||
return self._handle_ui_options(options)
|
||||
|
|
|
@ -84,7 +84,7 @@ def bdecode(x):
|
|||
return r
|
||||
|
||||
|
||||
class Bencached(object):
|
||||
class Bencached:
|
||||
|
||||
__slots__ = ['bencoded']
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -24,7 +23,7 @@ import tarfile
|
|||
import time
|
||||
from contextlib import closing
|
||||
from datetime import datetime
|
||||
from io import BytesIO, open
|
||||
from io import BytesIO
|
||||
from urllib.parse import unquote_plus, urljoin
|
||||
from urllib.request import pathname2url
|
||||
|
||||
|
@ -135,14 +134,14 @@ def get_default_download_dir():
|
|||
|
||||
try:
|
||||
user_dirs_path = os.path.join(xdg_config_home, 'user-dirs.dirs')
|
||||
with open(user_dirs_path, 'r', encoding='utf8') as _file:
|
||||
with open(user_dirs_path, encoding='utf8') as _file:
|
||||
for line in _file:
|
||||
if not line.startswith('#') and line.startswith('XDG_DOWNLOAD_DIR'):
|
||||
download_dir = os.path.expandvars(
|
||||
line.partition('=')[2].rstrip().strip('"')
|
||||
)
|
||||
break
|
||||
except IOError:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if not download_dir:
|
||||
|
@ -540,9 +539,9 @@ def fpeer(num_peers, total_peers):
|
|||
|
||||
"""
|
||||
if total_peers > -1:
|
||||
return '{:d} ({:d})'.format(num_peers, total_peers)
|
||||
return f'{num_peers:d} ({total_peers:d})'
|
||||
else:
|
||||
return '{:d}'.format(num_peers)
|
||||
return f'{num_peers:d}'
|
||||
|
||||
|
||||
def ftime(secs):
|
||||
|
@ -568,17 +567,17 @@ def ftime(secs):
|
|||
if secs <= 0:
|
||||
time_str = ''
|
||||
elif secs < 60:
|
||||
time_str = '{}s'.format(secs)
|
||||
time_str = f'{secs}s'
|
||||
elif secs < 3600:
|
||||
time_str = '{}m {}s'.format(secs // 60, secs % 60)
|
||||
time_str = f'{secs // 60}m {secs % 60}s'
|
||||
elif secs < 86400:
|
||||
time_str = '{}h {}m'.format(secs // 3600, secs // 60 % 60)
|
||||
time_str = f'{secs // 3600}h {secs // 60 % 60}m'
|
||||
elif secs < 604800:
|
||||
time_str = '{}d {}h'.format(secs // 86400, secs // 3600 % 24)
|
||||
time_str = f'{secs // 86400}d {secs // 3600 % 24}h'
|
||||
elif secs < 31449600:
|
||||
time_str = '{}w {}d'.format(secs // 604800, secs // 86400 % 7)
|
||||
time_str = f'{secs // 604800}w {secs // 86400 % 7}d'
|
||||
else:
|
||||
time_str = '{}y {}w'.format(secs // 31449600, secs // 604800 % 52)
|
||||
time_str = f'{secs // 31449600}y {secs // 604800 % 52}w'
|
||||
|
||||
return time_str
|
||||
|
||||
|
@ -934,7 +933,7 @@ def is_ipv4(ip):
|
|||
return socket.inet_aton(ip)
|
||||
else:
|
||||
return socket.inet_pton(socket.AF_INET, ip)
|
||||
except socket.error:
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
|
@ -960,7 +959,7 @@ def is_ipv6(ip):
|
|||
|
||||
try:
|
||||
return socket.inet_pton(socket.AF_INET6, ip)
|
||||
except (socket.error, AttributeError):
|
||||
except (OSError, AttributeError):
|
||||
if windows_check():
|
||||
log.warning('Unable to verify IPv6 Address on Windows.')
|
||||
return True
|
||||
|
@ -1048,7 +1047,7 @@ def utf8_encode_structure(data):
|
|||
|
||||
|
||||
@functools.total_ordering
|
||||
class VersionSplit(object):
|
||||
class VersionSplit:
|
||||
"""
|
||||
Used for comparing version numbers.
|
||||
|
||||
|
@ -1246,7 +1245,7 @@ def set_env_variable(name, value):
|
|||
)
|
||||
|
||||
# Update the copy maintained by msvcrt (used by gtk+ runtime)
|
||||
result = cdll.msvcrt._wputenv('%s=%s' % (name, value))
|
||||
result = cdll.msvcrt._wputenv(f'{name}={value}')
|
||||
if result != 0:
|
||||
log.info("Failed to set Env Var '%s' (msvcrt._putenv)", name)
|
||||
else:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -24,13 +23,13 @@ class ComponentAlreadyRegistered(Exception):
|
|||
|
||||
class ComponentException(Exception):
|
||||
def __init__(self, message, tb):
|
||||
super(ComponentException, self).__init__(message)
|
||||
super().__init__(message)
|
||||
self.message = message
|
||||
self.tb = tb
|
||||
|
||||
def __str__(self):
|
||||
s = super(ComponentException, self).__str__()
|
||||
return '%s\n%s' % (s, ''.join(self.tb))
|
||||
s = super().__str__()
|
||||
return '{}\n{}'.format(s, ''.join(self.tb))
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
|
@ -42,7 +41,7 @@ class ComponentException(Exception):
|
|||
return not self.__eq__(other)
|
||||
|
||||
|
||||
class Component(object):
|
||||
class Component:
|
||||
"""Component objects are singletons managed by the :class:`ComponentRegistry`.
|
||||
|
||||
When a new Component object is instantiated, it will be automatically
|
||||
|
@ -247,7 +246,7 @@ class Component(object):
|
|||
pass
|
||||
|
||||
|
||||
class ComponentRegistry(object):
|
||||
class ComponentRegistry:
|
||||
"""The ComponentRegistry holds a list of currently registered :class:`Component` objects.
|
||||
|
||||
It is used to manage the Components by starting, stopping, pausing and shutting them down.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -45,7 +44,6 @@ import os
|
|||
import pickle
|
||||
import shutil
|
||||
from codecs import getwriter
|
||||
from io import open
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from deluge.common import JSON_FORMAT, get_default_config_dir
|
||||
|
@ -102,7 +100,7 @@ def find_json_objects(text, decoder=json.JSONDecoder()):
|
|||
return objects
|
||||
|
||||
|
||||
class Config(object):
|
||||
class Config:
|
||||
"""This class is used to access/create/modify config files.
|
||||
|
||||
Args:
|
||||
|
@ -396,9 +394,9 @@ class Config(object):
|
|||
filename = self.__config_file
|
||||
|
||||
try:
|
||||
with open(filename, 'r', encoding='utf8') as _file:
|
||||
with open(filename, encoding='utf8') as _file:
|
||||
data = _file.read()
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.warning('Unable to open config file %s: %s', filename, ex)
|
||||
return
|
||||
|
||||
|
@ -451,7 +449,7 @@ class Config(object):
|
|||
# Check to see if the current config differs from the one on disk
|
||||
# We will only write a new config file if there is a difference
|
||||
try:
|
||||
with open(filename, 'r', encoding='utf8') as _file:
|
||||
with open(filename, encoding='utf8') as _file:
|
||||
data = _file.read()
|
||||
objects = find_json_objects(data)
|
||||
start, end = objects[0]
|
||||
|
@ -463,7 +461,7 @@ class Config(object):
|
|||
if self._save_timer and self._save_timer.active():
|
||||
self._save_timer.cancel()
|
||||
return True
|
||||
except (IOError, IndexError) as ex:
|
||||
except (OSError, IndexError) as ex:
|
||||
log.warning('Unable to open config file: %s because: %s', filename, ex)
|
||||
|
||||
# Save the new config and make sure it's written to disk
|
||||
|
@ -477,7 +475,7 @@ class Config(object):
|
|||
json.dump(self.__config, getwriter('utf8')(_file), **JSON_FORMAT)
|
||||
_file.flush()
|
||||
os.fsync(_file.fileno())
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.error('Error writing new config file: %s', ex)
|
||||
return False
|
||||
|
||||
|
@ -488,7 +486,7 @@ class Config(object):
|
|||
try:
|
||||
log.debug('Backing up old config file to %s.bak', filename)
|
||||
shutil.move(filename, filename + '.bak')
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.warning('Unable to backup old config: %s', ex)
|
||||
|
||||
# The new config file has been written successfully, so let's move it over
|
||||
|
@ -496,7 +494,7 @@ class Config(object):
|
|||
try:
|
||||
log.debug('Moving new config file %s to %s', filename_tmp, filename)
|
||||
shutil.move(filename_tmp, filename)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.error('Error moving new config file: %s', ex)
|
||||
return False
|
||||
else:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -17,7 +16,7 @@ from deluge.config import Config
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class _ConfigManager(object):
|
||||
class _ConfigManager:
|
||||
def __init__(self):
|
||||
log.debug('ConfigManager started..')
|
||||
self.config_files = {}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
@ -11,7 +10,6 @@
|
|||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from io import open
|
||||
|
||||
import deluge.component as component
|
||||
import deluge.configmanager as configmanager
|
||||
|
@ -37,7 +35,7 @@ AUTH_LEVELS_MAPPING = {
|
|||
AUTH_LEVELS_MAPPING_REVERSE = {v: k for k, v in AUTH_LEVELS_MAPPING.items()}
|
||||
|
||||
|
||||
class Account(object):
|
||||
class Account:
|
||||
__slots__ = ('username', 'password', 'authlevel')
|
||||
|
||||
def __init__(self, username, password, authlevel):
|
||||
|
@ -54,10 +52,10 @@ class Account(object):
|
|||
}
|
||||
|
||||
def __repr__(self):
|
||||
return '<Account username="%(username)s" authlevel=%(authlevel)s>' % {
|
||||
'username': self.username,
|
||||
'authlevel': self.authlevel,
|
||||
}
|
||||
return '<Account username="{username}" authlevel={authlevel}>'.format(
|
||||
username=self.username,
|
||||
authlevel=self.authlevel,
|
||||
)
|
||||
|
||||
|
||||
class AuthManager(component.Component):
|
||||
|
@ -182,7 +180,7 @@ class AuthManager(component.Component):
|
|||
if os.path.isfile(filepath):
|
||||
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
|
||||
shutil.copy2(filepath, filepath_bak)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
|
||||
else:
|
||||
log.info('Saving the %s at: %s', filename, filepath)
|
||||
|
@ -196,7 +194,7 @@ class AuthManager(component.Component):
|
|||
_file.flush()
|
||||
os.fsync(_file.fileno())
|
||||
shutil.move(filepath_tmp, filepath)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.error('Unable to save %s: %s', filename, ex)
|
||||
if os.path.isfile(filepath_bak):
|
||||
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
|
||||
|
@ -225,9 +223,9 @@ class AuthManager(component.Component):
|
|||
for _filepath in (auth_file, auth_file_bak):
|
||||
log.info('Opening %s for load: %s', filename, _filepath)
|
||||
try:
|
||||
with open(_filepath, 'r', encoding='utf8') as _file:
|
||||
with open(_filepath, encoding='utf8') as _file:
|
||||
file_data = _file.readlines()
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.warning('Unable to load %s: %s', _filepath, ex)
|
||||
file_data = []
|
||||
else:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
@ -112,7 +111,7 @@ class Core(component.Component):
|
|||
component.Component.__init__(self, 'Core')
|
||||
|
||||
# Start the libtorrent session.
|
||||
user_agent = 'Deluge/{} libtorrent/{}'.format(DELUGE_VER, LT_VERSION)
|
||||
user_agent = f'Deluge/{DELUGE_VER} libtorrent/{LT_VERSION}'
|
||||
peer_id = self._create_peer_id(DELUGE_VER)
|
||||
log.debug('Starting session (peer_id: %s, user_agent: %s)', peer_id, user_agent)
|
||||
settings_pack = {
|
||||
|
@ -293,7 +292,7 @@ class Core(component.Component):
|
|||
if os.path.isfile(filepath):
|
||||
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
|
||||
shutil.copy2(filepath, filepath_bak)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
|
||||
else:
|
||||
log.info('Saving the %s at: %s', filename, filepath)
|
||||
|
@ -303,7 +302,7 @@ class Core(component.Component):
|
|||
_file.flush()
|
||||
os.fsync(_file.fileno())
|
||||
shutil.move(filepath_tmp, filepath)
|
||||
except (IOError, EOFError) as ex:
|
||||
except (OSError, EOFError) as ex:
|
||||
log.error('Unable to save %s: %s', filename, ex)
|
||||
if os.path.isfile(filepath_bak):
|
||||
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
|
||||
|
@ -325,7 +324,7 @@ class Core(component.Component):
|
|||
try:
|
||||
with open(_filepath, 'rb') as _file:
|
||||
state = lt.bdecode(_file.read())
|
||||
except (IOError, EOFError, RuntimeError) as ex:
|
||||
except (OSError, EOFError, RuntimeError) as ex:
|
||||
log.warning('Unable to load %s: %s', _filepath, ex)
|
||||
else:
|
||||
log.info('Successfully loaded %s: %s', filename, _filepath)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -42,8 +41,8 @@ def is_daemon_running(pid_file):
|
|||
|
||||
try:
|
||||
with open(pid_file) as _file:
|
||||
pid, port = [int(x) for x in _file.readline().strip().split(';')]
|
||||
except (EnvironmentError, ValueError):
|
||||
pid, port = (int(x) for x in _file.readline().strip().split(';'))
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
|
||||
if is_process_running(pid):
|
||||
|
@ -51,7 +50,7 @@ def is_daemon_running(pid_file):
|
|||
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
_socket.connect(('127.0.0.1', port))
|
||||
except socket.error:
|
||||
except OSError:
|
||||
# Can't connect, so pid is not a deluged process.
|
||||
return False
|
||||
else:
|
||||
|
@ -60,7 +59,7 @@ def is_daemon_running(pid_file):
|
|||
return True
|
||||
|
||||
|
||||
class Daemon(object):
|
||||
class Daemon:
|
||||
"""The Deluge Daemon class"""
|
||||
|
||||
def __init__(
|
||||
|
@ -154,7 +153,7 @@ class Daemon(object):
|
|||
pid = os.getpid()
|
||||
log.debug('Storing pid %s & port %s in: %s', pid, self.port, self.pid_file)
|
||||
with open(self.pid_file, 'w') as _file:
|
||||
_file.write('%s;%s\n' % (pid, self.port))
|
||||
_file.write(f'{pid};{self.port}\n')
|
||||
|
||||
component.start()
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008-2010 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -218,7 +217,7 @@ class PreferencesManager(component.Component):
|
|||
self.config['listen_use_sys_port'],
|
||||
)
|
||||
interfaces = [
|
||||
'%s:%s' % (interface, port)
|
||||
f'{interface}:{port}'
|
||||
for port in range(listen_ports[0], listen_ports[1] + 1)
|
||||
]
|
||||
self.core.apply_session_settings(
|
||||
|
@ -393,7 +392,7 @@ class PreferencesManager(component.Component):
|
|||
+ quote_plus(':'.join(self.config['enabled_plugins']))
|
||||
)
|
||||
urlopen(url)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.debug('Network error while trying to send info: %s', ex)
|
||||
else:
|
||||
self.config['info_sent'] = now
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008,2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -65,7 +64,7 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
|
|||
if func.__doc__:
|
||||
if func.__doc__.endswith(' '):
|
||||
indent = func.__doc__.split('\n')[-1]
|
||||
func.__doc__ += '\n{}'.format(indent)
|
||||
func.__doc__ += f'\n{indent}'
|
||||
else:
|
||||
func.__doc__ += '\n\n'
|
||||
func.__doc__ += rpc_text
|
||||
|
@ -110,7 +109,7 @@ def format_request(call):
|
|||
|
||||
class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||
def __init__(self):
|
||||
super(DelugeRPCProtocol, self).__init__()
|
||||
super().__init__()
|
||||
# namedtuple subclass with auth_level, username for the connected session.
|
||||
self.AuthLevel = namedtuple('SessionAuthlevel', 'auth_level, username')
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -148,7 +147,7 @@ class TorrentOptions(dict):
|
|||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(TorrentOptions, self).__init__()
|
||||
super().__init__()
|
||||
config = ConfigManager('core.conf').config
|
||||
options_conf_map = {
|
||||
'add_paused': 'add_paused',
|
||||
|
@ -178,14 +177,14 @@ class TorrentOptions(dict):
|
|||
self['seed_mode'] = False
|
||||
|
||||
|
||||
class TorrentError(object):
|
||||
class TorrentError:
|
||||
def __init__(self, error_message, was_paused=False, restart_to_resume=False):
|
||||
self.error_message = error_message
|
||||
self.was_paused = was_paused
|
||||
self.restart_to_resume = restart_to_resume
|
||||
|
||||
|
||||
class Torrent(object):
|
||||
class Torrent:
|
||||
"""Torrent holds information about torrents added to the libtorrent session.
|
||||
|
||||
Args:
|
||||
|
@ -825,7 +824,7 @@ class Torrent(object):
|
|||
'client': client,
|
||||
'country': country,
|
||||
'down_speed': peer.payload_down_speed,
|
||||
'ip': '%s:%s' % (peer.ip[0], peer.ip[1]),
|
||||
'ip': f'{peer.ip[0]}:{peer.ip[1]}',
|
||||
'progress': peer.progress,
|
||||
'seed': peer.flags & peer.seed,
|
||||
'up_speed': peer.payload_up_speed,
|
||||
|
@ -897,7 +896,7 @@ class Torrent(object):
|
|||
# Check if hostname is an IP address and just return it if that's the case
|
||||
try:
|
||||
socket.inet_aton(host)
|
||||
except socket.error:
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
# This is an IP address because an exception wasn't raised
|
||||
|
@ -1292,7 +1291,7 @@ class Torrent(object):
|
|||
try:
|
||||
with open(filepath, 'wb') as save_file:
|
||||
save_file.write(filedump)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.error('Unable to save torrent file to: %s', ex)
|
||||
|
||||
filepath = os.path.join(get_config_dir(), 'state', self.torrent_id + '.torrent')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -819,8 +818,8 @@ class TorrentManager(component.Component):
|
|||
try:
|
||||
with open(filepath, 'rb') as _file:
|
||||
state = pickle.load(_file, encoding='utf8')
|
||||
except (IOError, EOFError, pickle.UnpicklingError) as ex:
|
||||
message = 'Unable to load {}: {}'.format(filepath, ex)
|
||||
except (OSError, EOFError, pickle.UnpicklingError) as ex:
|
||||
message = f'Unable to load {filepath}: {ex}'
|
||||
log.error(message)
|
||||
if not filepath.endswith('.bak'):
|
||||
self.archive_state(message)
|
||||
|
@ -1076,7 +1075,7 @@ class TorrentManager(component.Component):
|
|||
try:
|
||||
with open(_filepath, 'rb') as _file:
|
||||
resume_data = lt.bdecode(_file.read())
|
||||
except (IOError, EOFError, RuntimeError) as ex:
|
||||
except (OSError, EOFError, RuntimeError) as ex:
|
||||
if self.torrents:
|
||||
log.warning('Unable to load %s: %s', _filepath, ex)
|
||||
resume_data = None
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
@ -125,7 +124,7 @@ def _overrides(stack, method, explicit_base_classes=None):
|
|||
% (
|
||||
method.__name__,
|
||||
cls,
|
||||
'File: %s:%s' % (stack[1][1], stack[1][2]),
|
||||
f'File: {stack[1][1]}:{stack[1][2]}',
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -135,7 +134,7 @@ def _overrides(stack, method, explicit_base_classes=None):
|
|||
% (
|
||||
method.__name__,
|
||||
check_classes,
|
||||
'File: %s:%s' % (stack[1][1], stack[1][2]),
|
||||
f'File: {stack[1][1]}:{stack[1][2]}',
|
||||
)
|
||||
)
|
||||
return method
|
||||
|
@ -152,7 +151,7 @@ def deprecated(func):
|
|||
def depr_func(*args, **kwargs):
|
||||
warnings.simplefilter('always', DeprecationWarning) # Turn off filter
|
||||
warnings.warn(
|
||||
'Call to deprecated function {}.'.format(func.__name__),
|
||||
f'Call to deprecated function {func.__name__}.',
|
||||
category=DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
@ -11,13 +10,13 @@
|
|||
|
||||
class DelugeError(Exception):
|
||||
def __new__(cls, *args, **kwargs):
|
||||
inst = super(DelugeError, cls).__new__(cls, *args, **kwargs)
|
||||
inst = super().__new__(cls, *args, **kwargs)
|
||||
inst._args = args
|
||||
inst._kwargs = kwargs
|
||||
return inst
|
||||
|
||||
def __init__(self, message=None):
|
||||
super(DelugeError, self).__init__(message)
|
||||
super().__init__(message)
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
|
@ -42,12 +41,12 @@ class InvalidPathError(DelugeError):
|
|||
|
||||
class WrappedException(DelugeError):
|
||||
def __init__(self, message, exception_type, traceback):
|
||||
super(WrappedException, self).__init__(message)
|
||||
super().__init__(message)
|
||||
self.type = exception_type
|
||||
self.traceback = traceback
|
||||
|
||||
def __str__(self):
|
||||
return '%s\n%s' % (self.message, self.traceback)
|
||||
return f'{self.message}\n{self.traceback}'
|
||||
|
||||
|
||||
class _ClientSideRecreateError(DelugeError):
|
||||
|
@ -61,7 +60,7 @@ class IncompatibleClient(_ClientSideRecreateError):
|
|||
'Your deluge client is not compatible with the daemon. '
|
||||
'Please upgrade your client to %(daemon_version)s'
|
||||
) % {'daemon_version': self.daemon_version}
|
||||
super(IncompatibleClient, self).__init__(message=msg)
|
||||
super().__init__(message=msg)
|
||||
|
||||
|
||||
class NotAuthorizedError(_ClientSideRecreateError):
|
||||
|
@ -70,14 +69,14 @@ class NotAuthorizedError(_ClientSideRecreateError):
|
|||
'current_level': current_level,
|
||||
'required_level': required_level,
|
||||
}
|
||||
super(NotAuthorizedError, self).__init__(message=msg)
|
||||
super().__init__(message=msg)
|
||||
self.current_level = current_level
|
||||
self.required_level = required_level
|
||||
|
||||
|
||||
class _UsernameBasedPasstroughError(_ClientSideRecreateError):
|
||||
def __init__(self, message, username):
|
||||
super(_UsernameBasedPasstroughError, self).__init__(message)
|
||||
super().__init__(message)
|
||||
self.username = username
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -23,7 +22,7 @@ class DelugeEventMetaClass(type):
|
|||
"""
|
||||
|
||||
def __init__(cls, name, bases, dct): # pylint: disable=bad-mcs-method-argument
|
||||
super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
|
||||
super().__init__(name, bases, dct)
|
||||
if name != 'DelugeEvent':
|
||||
known_events[name] = cls
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -38,11 +37,11 @@ class CompressionDecoderProtocol(client._GzipProtocol):
|
|||
"""A compression decoder protocol for CompressionDecoder."""
|
||||
|
||||
def __init__(self, protocol, response):
|
||||
super(CompressionDecoderProtocol, self).__init__(protocol, response)
|
||||
super().__init__(protocol, response)
|
||||
self._zlibDecompress = zlib.decompressobj(32 + zlib.MAX_WBITS)
|
||||
|
||||
|
||||
class BodyHandler(HTTPClientParser, object):
|
||||
class BodyHandler(HTTPClientParser):
|
||||
"""An HTTP parser that saves the response to a file."""
|
||||
|
||||
def __init__(self, request, finished, length, agent, encoding=None):
|
||||
|
@ -54,7 +53,7 @@ class BodyHandler(HTTPClientParser, object):
|
|||
length (int): The length of the response.
|
||||
agent (t.w.i.IAgent): The agent from which the request was sent.
|
||||
"""
|
||||
super(BodyHandler, self).__init__(request, finished)
|
||||
super().__init__(request, finished)
|
||||
self.agent = agent
|
||||
self.finished = finished
|
||||
self.total_length = length
|
||||
|
@ -74,12 +73,12 @@ class BodyHandler(HTTPClientParser, object):
|
|||
with open(self.agent.filename, 'wb') as _file:
|
||||
_file.write(self.data)
|
||||
self.finished.callback(self.agent.filename)
|
||||
self.state = u'DONE'
|
||||
self.state = 'DONE'
|
||||
HTTPClientParser.connectionLost(self, reason)
|
||||
|
||||
|
||||
@implementer(IAgent)
|
||||
class HTTPDownloaderAgent(object):
|
||||
class HTTPDownloaderAgent:
|
||||
"""A File Downloader Agent."""
|
||||
|
||||
def __init__(
|
||||
|
@ -144,7 +143,7 @@ class HTTPDownloaderAgent(object):
|
|||
fileext = os.path.splitext(new_file_name)[1]
|
||||
while os.path.isfile(new_file_name):
|
||||
# Increment filename if already exists
|
||||
new_file_name = '%s-%s%s' % (fileroot, count, fileext)
|
||||
new_file_name = f'{fileroot}-{count}{fileext}'
|
||||
count += 1
|
||||
|
||||
self.filename = new_file_name
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This file is public domain.
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -77,7 +76,7 @@ def set_language(lang):
|
|||
translation = gettext.translation(
|
||||
'deluge', localedir=get_translations_path(), languages=[lang]
|
||||
)
|
||||
except IOError:
|
||||
except OSError:
|
||||
log.warning('Unable to find translation (.mo) to set language: %s', lang)
|
||||
else:
|
||||
translation.install()
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
@ -37,7 +36,7 @@ MAX_LOGGER_NAME_LENGTH = 10
|
|||
|
||||
class Logging(LoggingLoggerClass):
|
||||
def __init__(self, logger_name):
|
||||
super(Logging, self).__init__(logger_name)
|
||||
super().__init__(logger_name)
|
||||
|
||||
# This makes module name padding increase to the biggest module name
|
||||
# so that logs keep readability.
|
||||
|
@ -238,7 +237,7 @@ def tweak_logging_levels():
|
|||
log.warning(
|
||||
'logging.conf found! tweaking logging levels from %s', logging_config_file
|
||||
)
|
||||
with open(logging_config_file, 'r') as _file:
|
||||
with open(logging_config_file) as _file:
|
||||
for line in _file:
|
||||
if line.strip().startswith('#'):
|
||||
continue
|
||||
|
@ -309,7 +308,7 @@ Triggering code:
|
|||
"""
|
||||
|
||||
|
||||
class _BackwardsCompatibleLOG(object):
|
||||
class _BackwardsCompatibleLOG:
|
||||
def __getattribute__(self, name):
|
||||
import warnings
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -30,7 +29,7 @@ class InvalidPieceSize(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class TorrentMetadata(object):
|
||||
class TorrentMetadata:
|
||||
"""This class is used to create .torrent files.
|
||||
|
||||
Examples:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Original file from BitTorrent-5.3-GPL.tar.gz
|
||||
# Copyright (C) Bram Cohen
|
||||
|
@ -42,7 +41,7 @@ def dummy(*v):
|
|||
pass
|
||||
|
||||
|
||||
class RemoteFileProgress(object):
|
||||
class RemoteFileProgress:
|
||||
def __init__(self, session_id):
|
||||
self.session_id = session_id
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2013 Bro <bro.development@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -45,7 +44,7 @@ git repository to have an idea of what needs to be changed.
|
|||
"""
|
||||
|
||||
|
||||
class PluginManagerBase(object):
|
||||
class PluginManagerBase:
|
||||
"""PluginManagerBase is a base class for PluginManagers to inherit"""
|
||||
|
||||
def __init__(self, config_file, entry_name):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||
#
|
||||
|
@ -20,7 +19,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class Gtk3UIPlugin(PluginInitBase):
|
||||
|
@ -28,7 +27,7 @@ class Gtk3UIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(Gtk3UIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -36,4 +35,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
@ -150,7 +149,7 @@ class Core(CorePluginBase):
|
|||
try:
|
||||
with open(filename, file_mode) as _file:
|
||||
filedump = _file.read()
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.warning('Unable to open %s: %s', filename, ex)
|
||||
raise ex
|
||||
|
||||
|
@ -167,9 +166,9 @@ class Core(CorePluginBase):
|
|||
log.debug('Attempting to open %s for splitting magnets.', filename)
|
||||
magnets = []
|
||||
try:
|
||||
with open(filename, 'r') as _file:
|
||||
with open(filename) as _file:
|
||||
magnets = list(filter(len, _file.read().splitlines()))
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.warning('Unable to open %s: %s', filename, ex)
|
||||
|
||||
if len(magnets) < 2:
|
||||
|
@ -194,7 +193,7 @@ class Core(CorePluginBase):
|
|||
try:
|
||||
with open(mname, 'w') as _mfile:
|
||||
_mfile.write(magnet)
|
||||
except IOError as ex:
|
||||
except OSError as ex:
|
||||
log.warning('Unable to open %s: %s', mname, ex)
|
||||
return magnets
|
||||
|
||||
|
@ -269,7 +268,7 @@ class Core(CorePluginBase):
|
|||
|
||||
try:
|
||||
filedump = self.load_torrent(filepath, magnet)
|
||||
except (IOError, EOFError) as ex:
|
||||
except (OSError, EOFError) as ex:
|
||||
# If torrent is invalid, keep track of it so can try again on the next pass.
|
||||
# This catches torrent files that may not be fully saved to disk at load time.
|
||||
log.debug('Torrent is invalid: %s', ex)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||
#
|
||||
|
@ -39,7 +38,7 @@ class IncompatibleOption(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class OptionsDialog(object):
|
||||
class OptionsDialog:
|
||||
spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio']
|
||||
spin_int_ids = ['max_upload_slots', 'max_connections']
|
||||
chk_ids = [
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -15,7 +14,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -23,7 +22,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -31,4 +30,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
@ -71,7 +70,7 @@ class BadIP(Exception):
|
|||
_message = None
|
||||
|
||||
def __init__(self, message):
|
||||
super(BadIP, self).__init__(message)
|
||||
super().__init__(message)
|
||||
|
||||
def __set_message(self, message):
|
||||
self._message = message
|
||||
|
@ -83,7 +82,7 @@ class BadIP(Exception):
|
|||
del __get_message, __set_message
|
||||
|
||||
|
||||
class IP(object):
|
||||
class IP:
|
||||
__slots__ = ('q1', 'q2', 'q3', 'q4', '_long')
|
||||
|
||||
def __init__(self, q1, q2, q3, q4):
|
||||
|
@ -106,7 +105,7 @@ class IP(object):
|
|||
@classmethod
|
||||
def parse(cls, ip):
|
||||
try:
|
||||
q1, q2, q3, q4 = [int(q) for q in ip.split('.')]
|
||||
q1, q2, q3, q4 = (int(q) for q in ip.split('.'))
|
||||
except ValueError:
|
||||
raise BadIP(_('The IP address "%s" is badly formed' % ip))
|
||||
if q1 < 0 or q2 < 0 or q3 < 0 or q4 < 0:
|
||||
|
@ -166,7 +165,7 @@ class IP(object):
|
|||
return self.long == other.long
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s long=%s address="%s">' % (
|
||||
return '<{} long={} address="{}">'.format(
|
||||
self.__class__.__name__,
|
||||
self.long,
|
||||
self.address,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Steve 'Tarka' Smith (tarka@internode.on.net)
|
||||
#
|
||||
|
@ -21,14 +20,14 @@ class PGException(Exception):
|
|||
|
||||
# Incrementally reads PeerGuardian blocklists v1 and v2.
|
||||
# See http://wiki.phoenixlabs.org/wiki/P2B_Format
|
||||
class PGReader(object):
|
||||
class PGReader:
|
||||
def __init__(self, filename):
|
||||
log.debug('PGReader loading: %s', filename)
|
||||
|
||||
try:
|
||||
with gzip.open(filename, 'rb') as _file:
|
||||
self.fd = _file
|
||||
except IOError:
|
||||
except OSError:
|
||||
log.debug('Blocklist: PGReader: Incorrect file type or list is corrupt')
|
||||
|
||||
# 4 bytes, should be 0xffffffff
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
@ -21,7 +20,7 @@ class ReaderParseError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class BaseReader(object):
|
||||
class BaseReader:
|
||||
"""Base reader for blocklist files"""
|
||||
|
||||
def __init__(self, _file):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
#
|
||||
|
@ -15,7 +14,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -23,7 +22,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -31,4 +30,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
#
|
||||
|
@ -39,7 +38,7 @@ EVENT_MAP = {
|
|||
EVENTS = ['complete', 'added', 'removed']
|
||||
|
||||
|
||||
class ExecutePreferences(object):
|
||||
class ExecutePreferences:
|
||||
def __init__(self, plugin):
|
||||
self.plugin = plugin
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -39,7 +38,7 @@ if windows_check():
|
|||
|
||||
try:
|
||||
hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\7-Zip')
|
||||
except WindowsError:
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
win_7z_path = os.path.join(winreg.QueryValueEx(hkey, 'Path')[0], '7z.exe')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
@ -18,7 +17,7 @@ from ..common import get_resource
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LabelConfig(object):
|
||||
class LabelConfig:
|
||||
"""
|
||||
there used to be some options here...
|
||||
"""
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
|
@ -30,7 +29,7 @@ NO_LABEL = 'No Label'
|
|||
|
||||
|
||||
# menu
|
||||
class LabelSidebarMenu(object):
|
||||
class LabelSidebarMenu:
|
||||
def __init__(self):
|
||||
|
||||
self.treeview = component.get('FilterTreeView')
|
||||
|
@ -105,7 +104,7 @@ class LabelSidebarMenu(object):
|
|||
|
||||
|
||||
# dialogs:
|
||||
class AddDialog(object):
|
||||
class AddDialog:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
@ -127,7 +126,7 @@ class AddDialog(object):
|
|||
self.dialog.destroy()
|
||||
|
||||
|
||||
class OptionsDialog(object):
|
||||
class OptionsDialog:
|
||||
spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio']
|
||||
spin_int_ids = ['max_upload_slots', 'max_connections']
|
||||
chk_ids = [
|
||||
|
@ -172,7 +171,7 @@ class OptionsDialog(object):
|
|||
self.builder.connect_signals(self)
|
||||
# Show the label name in the header label
|
||||
self.builder.get_object('label_header').set_markup(
|
||||
'<b>%s:</b> %s' % (_('Label Options'), self.label)
|
||||
'<b>{}:</b> {}'.format(_('Label Options'), self.label)
|
||||
)
|
||||
|
||||
for chk_id, group in self.sensitive_groups:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
|
@ -20,7 +19,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -28,7 +27,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -36,4 +35,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
|
@ -28,7 +27,7 @@ def get_resource(filename):
|
|||
return resource_filename(__package__, os.path.join('data', filename))
|
||||
|
||||
|
||||
class CustomNotifications(object):
|
||||
class CustomNotifications:
|
||||
def __init__(self, plugin_name=None):
|
||||
self.custom_notifications = {'email': {}, 'popup': {}, 'blink': {}, 'sound': {}}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: sw=4 ts=4 fenc=utf-8 et
|
||||
# ==============================================================================
|
||||
# Copyright © 2009-2010 UfSoft.org - Pedro Algarvio <pedro@algarvio.me>
|
||||
|
@ -68,14 +67,14 @@ class TestEmailNotifications(component.Component):
|
|||
|
||||
def custom_email_message_provider(self, *evt_args, **evt_kwargs):
|
||||
log.debug('Running custom email message provider: %s %s', evt_args, evt_kwargs)
|
||||
subject = '%s Email Subject: %s' % (self.events[0].__class__.__name__, self.n)
|
||||
message = '%s Email Message: %s' % (self.events[0].__class__.__name__, self.n)
|
||||
subject = f'{self.events[0].__class__.__name__} Email Subject: {self.n}'
|
||||
message = f'{self.events[0].__class__.__name__} Email Message: {self.n}'
|
||||
return subject, message
|
||||
|
||||
def custom_popup_message_provider(self, *evt_args, **evt_kwargs):
|
||||
log.debug('Running custom popup message provider: %s %s', evt_args, evt_kwargs)
|
||||
title = '%s Popup Title: %s' % (self.events[0].__class__.__name__, self.n)
|
||||
message = '%s Popup Message: %s' % (self.events[0].__class__.__name__, self.n)
|
||||
title = f'{self.events[0].__class__.__name__} Popup Title: {self.n}'
|
||||
message = f'{self.events[0].__class__.__name__} Popup Message: {self.n}'
|
||||
return title, message
|
||||
|
||||
def custom_blink_message_provider(self, *evt_args, **evt_kwargs):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
@ -28,7 +27,7 @@ DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|||
|
||||
class SchedulerSelectWidget(Gtk.DrawingArea):
|
||||
def __init__(self, hover):
|
||||
super(SchedulerSelectWidget, self).__init__()
|
||||
super().__init__()
|
||||
self.set_events(
|
||||
Gdk.EventMask.BUTTON_PRESS_MASK
|
||||
| Gdk.EventMask.BUTTON_RELEASE_MASK
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||
# Copyright (C) 2008 Damien Churchill <damoxc@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||
# Copyright (C) 2008 Damien Churchill <damoxc@gmail.com>
|
||||
|
@ -60,7 +59,7 @@ def change_opacity(color, opactiy):
|
|||
return tuple(color)
|
||||
|
||||
|
||||
class Graph(object):
|
||||
class Graph:
|
||||
def __init__(self):
|
||||
self.width = 100
|
||||
self.height = 100
|
||||
|
@ -176,7 +175,7 @@ class Graph(object):
|
|||
te = self.ctx.text_extents(text)
|
||||
return math.ceil(te[4] - te[0])
|
||||
|
||||
y_tick_width = max((space_required(text) for text in y_tick_text))
|
||||
y_tick_width = max(space_required(text) for text in y_tick_text)
|
||||
|
||||
top = font_extents[2] / 2
|
||||
# bounds(left, top, right, bottom)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
@ -83,7 +82,7 @@ def text_to_rgba(color):
|
|||
|
||||
class GraphsTab(Tab):
|
||||
def __init__(self, colors):
|
||||
super(GraphsTab, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
builder = Gtk.Builder()
|
||||
builder.add_from_file(get_resource('tabs.ui'))
|
||||
|
@ -268,7 +267,7 @@ class GtkUI(Gtk3PluginBase):
|
|||
for graph, colors in self.config['colors'].items():
|
||||
gtkconf[graph] = {}
|
||||
for value, color in colors.items():
|
||||
color_btn = self.builder.get_object('%s_%s_color' % (graph, value))
|
||||
color_btn = self.builder.get_object(f'{graph}_{value}_color')
|
||||
try:
|
||||
gtkconf[graph][value] = color_btn.get_color().to_string()
|
||||
except Exception:
|
||||
|
@ -283,7 +282,7 @@ class GtkUI(Gtk3PluginBase):
|
|||
for graph, colors in self.config['colors'].items():
|
||||
for value, color in colors.items():
|
||||
try:
|
||||
color_btn = self.builder.get_object('%s_%s_color' % (graph, value))
|
||||
color_btn = self.builder.get_object(f'{graph}_{value}_color')
|
||||
color_btn.set_rgba(text_to_rgba(color))
|
||||
except Exception as ex:
|
||||
log.debug('Unable to set %s %s %s: %s', graph, value, color, ex)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
||||
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||
|
@ -88,7 +87,7 @@ class StatsTestCase(BaseTestCase):
|
|||
TorrentDetails()
|
||||
Preferences()
|
||||
|
||||
class FakeFile(object):
|
||||
class FakeFile:
|
||||
def __init__(self):
|
||||
self.data = []
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
@ -20,7 +19,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -28,7 +27,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -36,4 +35,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
#
|
||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
|||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
|||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
|||
from webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
super().__init__(plugin_name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue