diff --git a/.pylintrc b/.pylintrc index becbe3f28d..75fa0e6e42 100644 --- a/.pylintrc +++ b/.pylintrc @@ -289,7 +289,7 @@ callbacks=cb_,_cb # List of qualified module names which can have objects that can redefine # builtins. -redefining-builtins-modules=six.moves,future.builtins,future_builtins +redefining-builtins-modules= [TYPECHECK] @@ -359,11 +359,6 @@ known-standard-library= # Force import order to recognize a module as part of a third party library. known-third-party=enchant -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - [DESIGN] diff --git a/CHANGELOG.md b/CHANGELOG.md index 928ee76dd2..251b681026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog -## 2.0.6 (WIP) +## 2.1.0 (WIP) + +- Removed Python 2 support. ## 2.0.5 (2021-12-15) diff --git a/DEPENDS.md b/DEPENDS.md index 0844718c4d..0760695667 100644 --- a/DEPENDS.md +++ b/DEPENDS.md @@ -23,7 +23,6 @@ All modules will require the [common](#common) section dependencies. - [rencode] _>= 1.0.2_ - Encoding library. - [PyXDG] - Access freedesktop.org standards for \*nix. - [xdg-utils] - Provides xdg-open for \*nix. -- [six] - [zope.interface] - [chardet] - Optional: Encoding detection. - [setproctitle] - Optional: Renaming processes. @@ -81,14 +80,12 @@ All modules will require the [common](#common) section dependencies. [distro]: https://github.com/nir0s/distro [pywin32]: https://github.com/mhammond/pywin32 [certifi]: https://pypi.org/project/certifi/ -[py2-ipaddress]: https://pypi.org/project/py2-ipaddress/ [dbus-python]: https://pypi.org/project/dbus-python/ [setproctitle]: https://pypi.org/project/setproctitle/ [gtkosxapplication]: https://github.com/jralls/gtk-mac-integration [chardet]: https://chardet.github.io/ [rencode]: https://github.com/aresch/rencode [pyxdg]: https://www.freedesktop.org/wiki/Software/pyxdg/ -[six]: https://pythonhosted.org/six/ [xdg-utils]: https://www.freedesktop.org/wiki/Software/xdg-utils/ [gtk+]: https://www.gtk.org/ [pycairo]: https://cairographics.org/pycairo/ diff --git a/deluge/_libtorrent.py b/deluge/_libtorrent.py index 0020184e59..86025b56a6 100644 --- a/deluge/_libtorrent.py +++ b/deluge/_libtorrent.py @@ -15,8 +15,6 @@ >>> from deluge._libtorrent import lt """ -from __future__ import unicode_literals - from deluge.common import VersionSplit, get_version from deluge.error import LibtorrentImportError diff --git a/deluge/argparserbase.py b/deluge/argparserbase.py index 547c1c71c5..a27ba1aaf8 100644 --- a/deluge/argparserbase.py +++ b/deluge/argparserbase.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import argparse import logging import os diff --git a/deluge/bencode.py b/deluge/bencode.py index 0c2674b9b4..f065783e98 100644 --- a/deluge/bencode.py +++ b/deluge/bencode.py @@ -9,13 +9,7 @@ # License. # Written by Petru Paler -# Updated by Calum Lind to support both Python 2 and Python 3. - -from __future__ import unicode_literals - -from sys import version_info - -PY2 = version_info.major == 2 +# Updated by Calum Lind to support Python 3. class BTFailure(Exception): @@ -146,10 +140,6 @@ def encode_dict(x, r): encode_func[bool] = encode_bool encode_func[str] = encode_string encode_func[bytes] = encode_bytes -if PY2: - encode_func[long] = encode_int # noqa: F821 - encode_func[str] = encode_bytes - encode_func[unicode] = encode_string # noqa: F821 def bencode(x): diff --git a/deluge/common.py b/deluge/common.py index a0e3fdd3b2..0bb085813d 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -8,8 +8,6 @@ # """Common functions for various parts of Deluge to use.""" -from __future__ import division, print_function, unicode_literals - import base64 import binascii import functools @@ -27,6 +25,8 @@ from contextlib import closing from datetime import datetime from io import BytesIO, open +from urllib.parse import unquote_plus, urljoin +from urllib.request import pathname2url import pkg_resources @@ -38,14 +38,6 @@ except ImportError: chardet = None -try: - from urllib.parse import unquote_plus, urljoin - from urllib.request import pathname2url -except ImportError: - # PY2 fallback - from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports - from urlparse import urljoin # pylint: disable=ungrouped-imports - # Windows workaround for HTTPS requests requiring certificate authority bundle. # see: https://twistedmatrix.com/trac/ticket/9209 if platform.system() in ('Windows', 'Microsoft'): @@ -84,8 +76,6 @@ DBUS_FM_ID = 'org.freedesktop.FileManager1' DBUS_FM_PATH = '/org/freedesktop/FileManager1' -PY2 = sys.version_info.major == 2 - def get_version(): """The program version from the egg metadata. @@ -111,10 +101,8 @@ def get_default_config_dir(filename=None): def save_config_path(resource): app_data_path = os.environ.get('APPDATA') if not app_data_path: - try: - import winreg - except ImportError: - import _winreg as winreg # For Python 2. + import winreg + hkey = winreg.OpenKey( winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders', @@ -178,8 +166,8 @@ def archive_files(arc_name, filepaths, message=None, rotate=10): from deluge.configmanager import get_config_dir - # Set archive compression to lzma with bz2 fallback. - arc_comp = 'xz' if not PY2 else 'bz2' + # Set archive compression to lzma + arc_comp = 'xz' archive_dir = os.path.join(get_config_dir(), 'archive') timestamp = datetime.now().replace(microsecond=0).isoformat().replace(':', '-') @@ -1239,11 +1227,7 @@ def set_env_variable(name, value): http://sourceforge.net/p/gramps/code/HEAD/tree/branches/maintenance/gramps32/src/TransUtils.py """ # Update Python's copy of the environment variables - try: - os.environ[name] = value - except UnicodeEncodeError: - # Python 2 - os.environ[name] = value.encode('utf8') + os.environ[name] = value if windows_check(): from ctypes import cdll, windll @@ -1271,45 +1255,22 @@ def set_env_variable(name, value): def unicode_argv(): """ Gets sys.argv as list of unicode objects on any platform.""" - if windows_check(): - # Versions 2.x of Python don't support Unicode in sys.argv on - # Windows, with the underlying Windows API instead replacing multi-byte - # characters with '?'. - from ctypes import POINTER, byref, c_int, cdll, windll - from ctypes.wintypes import LPCWSTR, LPWSTR - - get_cmd_linew = cdll.kernel32.GetCommandLineW - get_cmd_linew.argtypes = [] - get_cmd_linew.restype = LPCWSTR - - cmdline_to_argvw = windll.shell32.CommandLineToArgvW - cmdline_to_argvw.argtypes = [LPCWSTR, POINTER(c_int)] - cmdline_to_argvw.restype = POINTER(LPWSTR) - - cmd = get_cmd_linew() - argc = c_int(0) - argv = cmdline_to_argvw(cmd, byref(argc)) - if argc.value > 0: - # Remove Python executable and commands if present - start = argc.value - len(sys.argv) - return [argv[i] for i in range(start, argc.value)] - else: - # On other platforms, we have to find the likely encoding of the args and decode - # First check if sys.stdout or stdin have encoding set - encoding = getattr(sys.stdout, 'encoding') or getattr(sys.stdin, 'encoding') - # If that fails, check what the locale is set to - encoding = encoding or locale.getpreferredencoding() - # As a last resort, just default to utf-8 - encoding = encoding or 'utf-8' - - arg_list = [] - for arg in sys.argv: - try: - arg_list.append(arg.decode(encoding)) - except AttributeError: - arg_list.append(arg) + # On platforms other than Windows, we have to find the likely encoding of the args and decode + # First check if sys.stdout or stdin have encoding set + encoding = getattr(sys.stdout, 'encoding') or getattr(sys.stdin, 'encoding') + # If that fails, check what the locale is set to + encoding = encoding or locale.getpreferredencoding() + # As a last resort, just default to utf-8 + encoding = encoding or 'utf-8' + + arg_list = [] + for arg in sys.argv: + try: + arg_list.append(arg.decode(encoding)) + except AttributeError: + arg_list.append(arg) - return arg_list + return arg_list def run_profiled(func, *args, **kwargs): diff --git a/deluge/component.py b/deluge/component.py index b7b7ab3e4b..bbbd33b6fc 100644 --- a/deluge/component.py +++ b/deluge/component.py @@ -7,13 +7,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import traceback from collections import defaultdict -from six import string_types from twisted.internet import reactor from twisted.internet.defer import DeferredList, fail, maybeDeferred, succeed from twisted.internet.task import LoopingCall, deferLater @@ -325,7 +322,7 @@ def start(self, names=None): # Start all the components if names is empty if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] def on_depends_started(result, name): @@ -359,7 +356,7 @@ def stop(self, names=None): """ if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] def on_dependents_stopped(result, name): @@ -399,7 +396,7 @@ def pause(self, names=None): """ if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] deferreds = [] @@ -425,7 +422,7 @@ def resume(self, names=None): """ if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] deferreds = [] diff --git a/deluge/config.py b/deluge/config.py index 80b30faf58..0900e7a363 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -39,18 +39,15 @@ version as this will be done internally. """ -from __future__ import unicode_literals - import json import logging import os +import pickle import shutil from codecs import getwriter from io import open from tempfile import NamedTemporaryFile -import six.moves.cPickle as pickle # noqa: N813 - from deluge.common import JSON_FORMAT, get_default_config_dir log = logging.getLogger(__name__) diff --git a/deluge/configmanager.py b/deluge/configmanager.py index bbb0389a50..dcd71916a5 100644 --- a/deluge/configmanager.py +++ b/deluge/configmanager.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py index 2fe42224dd..9d5c18ccbb 100644 --- a/deluge/core/alertmanager.py +++ b/deluge/core/alertmanager.py @@ -15,10 +15,8 @@ `:mod:EventManager` for similar functionality. """ -from __future__ import unicode_literals - import logging -import types +from types import SimpleNamespace from twisted.internet import reactor @@ -28,14 +26,6 @@ log = logging.getLogger(__name__) -try: - SimpleNamespace = types.SimpleNamespace # Python 3.3+ -except AttributeError: - - class SimpleNamespace(object): # Python 2.7 - def __init__(self, **attr): - self.__dict__.update(attr) - class AlertManager(component.Component): """AlertManager fetches and processes libtorrent alerts""" diff --git a/deluge/core/authmanager.py b/deluge/core/authmanager.py index 713373e99a..ecb4948b9a 100644 --- a/deluge/core/authmanager.py +++ b/deluge/core/authmanager.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import shutil diff --git a/deluge/core/core.py b/deluge/core/core.py index 881f0065dc..acd3a0b473 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import glob import logging import os @@ -17,8 +15,8 @@ import tempfile import threading from base64 import b64decode, b64encode +from urllib.request import URLError, urlopen -from six import string_types from twisted.internet import defer, reactor, task from twisted.web.client import Agent, readBody @@ -56,12 +54,6 @@ ) from deluge.httpdownloader import download_file -try: - from urllib.request import URLError, urlopen -except ImportError: - # PY2 fallback - from urllib2 import URLError, urlopen - log = logging.getLogger(__name__) DEPR_SESSION_STATUS_KEYS = { @@ -666,7 +658,7 @@ def force_reannounce(self, torrent_ids): def pause_torrent(self, torrent_id): """Pauses a torrent""" log.debug('Pausing: %s', torrent_id) - if not isinstance(torrent_id, string_types): + if not isinstance(torrent_id, str): self.pause_torrents(torrent_id) else: self.torrentmanager[torrent_id].pause() @@ -717,7 +709,7 @@ def is_session_paused(self): def resume_torrent(self, torrent_id): """Resumes a torrent""" log.debug('Resuming: %s', torrent_id) - if not isinstance(torrent_id, string_types): + if not isinstance(torrent_id, str): self.resume_torrents(torrent_id) else: self.torrentmanager[torrent_id].resume() @@ -901,7 +893,7 @@ def set_torrent_options(self, torrent_ids, options): if 'owner' in options and not self.authmanager.has_account(options['owner']): raise DelugeError('Username "%s" is not known.' % options['owner']) - if isinstance(torrent_ids, string_types): + if isinstance(torrent_ids, str): torrent_ids = [torrent_ids] for torrent_id in torrent_ids: diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py index 3c2ac643b5..2695589281 100644 --- a/deluge/core/daemon.py +++ b/deluge/core/daemon.py @@ -8,8 +8,6 @@ # """The Deluge daemon""" -from __future__ import unicode_literals - import logging import os import socket diff --git a/deluge/core/daemon_entry.py b/deluge/core/daemon_entry.py index 8b3746c438..33304fd083 100644 --- a/deluge/core/daemon_entry.py +++ b/deluge/core/daemon_entry.py @@ -7,8 +7,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import os import sys from logging import DEBUG, FileHandler, getLogger diff --git a/deluge/core/eventmanager.py b/deluge/core/eventmanager.py index 5ba2989f9a..da60ac7e33 100644 --- a/deluge/core/eventmanager.py +++ b/deluge/core/eventmanager.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index 90589ef1fc..c4f3420975 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -7,12 +7,8 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging -from six import string_types - import deluge.component as component from deluge.common import TORRENT_STATE @@ -136,7 +132,7 @@ def filter_torrent_ids(self, filter_dict): # Sanitize input: filter-value must be a list of strings for key, value in filter_dict.items(): - if isinstance(value, string_types): + if isinstance(value, str): filter_dict[key] = [value] # Optimized filter for id diff --git a/deluge/core/pluginmanager.py b/deluge/core/pluginmanager.py index 7d2f3a1e88..74b7d0039e 100644 --- a/deluge/core/pluginmanager.py +++ b/deluge/core/pluginmanager.py @@ -9,8 +9,6 @@ """PluginManager for Core""" -from __future__ import unicode_literals - import logging from twisted.internet import defer diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index c250130c01..f3d1041037 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -8,13 +8,13 @@ # -from __future__ import unicode_literals - import logging import os import platform import random import threading +from urllib.parse import quote_plus +from urllib.request import urlopen from twisted.internet.task import LoopingCall @@ -29,13 +29,6 @@ except ImportError: GeoIP = None -try: - from urllib.parse import quote_plus - from urllib.request import urlopen -except ImportError: - from urllib import quote_plus - from urllib2 import urlopen - log = logging.getLogger(__name__) DEFAULT_PREFS = { diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 4fa94c3876..db570d1758 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -8,8 +8,6 @@ # """RPCServer Module""" -from __future__ import unicode_literals - import logging import os import sys diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index ede5200f04..ee36693387 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -14,11 +14,10 @@ """ -from __future__ import division, unicode_literals - import logging import os import socket +from urllib.parse import urlparse from twisted.internet.defer import Deferred, DeferredList @@ -34,18 +33,6 @@ TorrentTrackerStatusEvent, ) -try: - from urllib.parse import urlparse -except ImportError: - # PY2 fallback - from urlparse import urlparse # pylint: disable=ungrouped-imports - -try: - from future_builtins import zip -except ImportError: - # Ignore on Py3. - pass - log = logging.getLogger(__name__) LT_TORRENT_STATE_MAP = { diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 365f372330..84d147a499 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -8,17 +8,15 @@ # """TorrentManager handles Torrent objects""" -from __future__ import unicode_literals - import datetime import logging import operator import os +import pickle import time from collections import namedtuple from tempfile import gettempdir -import six.moves.cPickle as pickle # noqa: N813 from twisted.internet import defer, error, reactor, threads from twisted.internet.defer import Deferred, DeferredList from twisted.internet.task import LoopingCall @@ -26,7 +24,6 @@ import deluge.component as component from deluge._libtorrent import LT_VERSION, lt from deluge.common import ( - PY2, VersionSplit, archive_files, decode_bytes, @@ -821,10 +818,7 @@ def open_state(self): try: with open(filepath, 'rb') as _file: - if PY2: - state = pickle.load(_file) - else: - state = pickle.load(_file, encoding='utf8') + state = pickle.load(_file, encoding='utf8') except (IOError, EOFError, pickle.UnpicklingError) as ex: message = 'Unable to load {}: {}'.format(filepath, ex) log.error(message) diff --git a/deluge/crypto_utils.py b/deluge/crypto_utils.py index 978eb0410d..840a245338 100644 --- a/deluge/crypto_utils.py +++ b/deluge/crypto_utils.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, print_function, unicode_literals - import os import stat @@ -105,9 +103,7 @@ def generate_ssl_keys(): """ This method generates a new SSL key/cert. """ - from deluge.common import PY2 - - digest = 'sha256' if not PY2 else b'sha256' + digest = 'sha256' # Generate key pair pkey = crypto.PKey() diff --git a/deluge/decorators.py b/deluge/decorators.py index a601bf7e0f..0c66572f0b 100644 --- a/deluge/decorators.py +++ b/deluge/decorators.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import inspect import re import warnings diff --git a/deluge/error.py b/deluge/error.py index 46e8e0cf1f..ba85294526 100644 --- a/deluge/error.py +++ b/deluge/error.py @@ -9,9 +9,6 @@ # -from __future__ import unicode_literals - - class DelugeError(Exception): def __new__(cls, *args, **kwargs): inst = super(DelugeError, cls).__new__(cls, *args, **kwargs) diff --git a/deluge/event.py b/deluge/event.py index c5d5ff910d..a907070604 100644 --- a/deluge/event.py +++ b/deluge/event.py @@ -14,10 +14,6 @@ and subsequently emitted to the clients. """ -from __future__ import unicode_literals - -import six - known_events = {} @@ -32,7 +28,7 @@ def __init__(cls, name, bases, dct): # pylint: disable=bad-mcs-method-argument known_events[name] = cls -class DelugeEvent(six.with_metaclass(DelugeEventMetaClass, object)): +class DelugeEvent(metaclass=DelugeEventMetaClass): """ The base class for all events. diff --git a/deluge/httpdownloader.py b/deluge/httpdownloader.py index f0fe09ec01..da7bf3a164 100644 --- a/deluge/httpdownloader.py +++ b/deluge/httpdownloader.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import cgi import logging import os.path diff --git a/deluge/i18n/languages.py b/deluge/i18n/languages.py index 49dc530266..5f7defc80c 100644 --- a/deluge/i18n/languages.py +++ b/deluge/i18n/languages.py @@ -3,8 +3,6 @@ # This file is public domain. # -from __future__ import unicode_literals - # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' diff --git a/deluge/i18n/util.py b/deluge/i18n/util.py index 6ed4b97da0..897f412f2d 100644 --- a/deluge/i18n/util.py +++ b/deluge/i18n/util.py @@ -7,8 +7,7 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - +import builtins import ctypes import gettext import locale @@ -17,8 +16,6 @@ import sys from glob import glob -from six.moves import builtins - import deluge.common from .languages import LANGUAGES @@ -113,10 +110,7 @@ def setup_translation(): gettext.bindtextdomain(I18N_DOMAIN, translations_path) gettext.textdomain(I18N_DOMAIN) - # Workaround for Python 2 unicode gettext (keyword removed in Py3). - kwargs = {} if not deluge.common.PY2 else {'unicode': True} - - gettext.install(I18N_DOMAIN, translations_path, names=['ngettext'], **kwargs) + gettext.install(I18N_DOMAIN, translations_path, names=['ngettext']) builtins.__dict__['_n'] = builtins.__dict__['ngettext'] def load_libintl(libintls): diff --git a/deluge/log.py b/deluge/log.py index 99838529f6..868be45930 100644 --- a/deluge/log.py +++ b/deluge/log.py @@ -9,8 +9,6 @@ # """Logging functions""" -from __future__ import unicode_literals - import inspect import logging import logging.handlers @@ -102,10 +100,7 @@ def findCaller(self, *args, **kwargs): # NOQA: N802 continue rv = (co.co_filename, f.f_lineno, co.co_name, None) break - if common.PY2: - return rv[:-1] - else: - return rv + return rv levels = { diff --git a/deluge/maketorrent.py b/deluge/maketorrent.py index 528638e43e..0a4eb93c93 100644 --- a/deluge/maketorrent.py +++ b/deluge/maketorrent.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import os from hashlib import sha1 as sha diff --git a/deluge/metafile.py b/deluge/metafile.py index 8c28c7e91d..b39da11b1a 100644 --- a/deluge/metafile.py +++ b/deluge/metafile.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import os.path import time diff --git a/deluge/path_chooser_common.py b/deluge/path_chooser_common.py index 0f93feef63..002a6e80a0 100644 --- a/deluge/path_chooser_common.py +++ b/deluge/path_chooser_common.py @@ -8,12 +8,8 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os -from deluge.common import PY2 - def is_hidden(filepath): def has_hidden_attribute(filepath): @@ -54,10 +50,7 @@ def get_completion_paths(args): def get_subdirs(dirname): try: - if PY2: - return os.walk(dirname).__next__[1] - else: - return next(os.walk(dirname))[1] + return next(os.walk(dirname))[1] except StopIteration: # Invalid dirname return [] diff --git a/deluge/pluginmanagerbase.py b/deluge/pluginmanagerbase.py index 2c17445553..da016ed662 100644 --- a/deluge/pluginmanagerbase.py +++ b/deluge/pluginmanagerbase.py @@ -9,8 +9,6 @@ """PluginManagerBase""" -from __future__ import unicode_literals - import logging import os.path diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py b/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py index a409cfcce7..ec98d88488 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/__init__.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/common.py b/deluge/plugins/AutoAdd/deluge_autoadd/common.py index 9b4b1e703f..f6783de42a 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/common.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py index 9a22606107..33f5350f3a 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/core.py @@ -13,8 +13,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import shutil diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py b/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py index 35531419bb..969a1638f4 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/gtkui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/webui.py b/deluge/plugins/AutoAdd/deluge_autoadd/webui.py index 7f36ba6595..41dc4d80e8 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/webui.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/webui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Blocklist/deluge_blocklist/__init__.py b/deluge/plugins/Blocklist/deluge_blocklist/__init__.py index 96ccc02ae4..80775cc1d5 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/__init__.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/__init__.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Blocklist/deluge_blocklist/common.py b/deluge/plugins/Blocklist/deluge_blocklist/common.py index a9299cd2e5..b45de94b0f 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/common.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/common.py @@ -12,13 +12,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from functools import wraps from sys import exc_info -import six from pkg_resources import resource_filename @@ -47,7 +44,7 @@ def wrapper(self, *args, **kwargs): return func(self, *args, **kwargs) except Exception: (value, tb) = exc_info()[1:] - six.reraise(error, value, tb) + raise error(value).with_traceback(tb) from None return wrapper diff --git a/deluge/plugins/Blocklist/deluge_blocklist/core.py b/deluge/plugins/Blocklist/deluge_blocklist/core.py index a096b8ac94..53e36705d4 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/core.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/core.py @@ -8,14 +8,13 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import os import shutil import time from datetime import datetime, timedelta from email.utils import formatdate +from urllib.parse import urljoin from twisted.internet import defer, threads from twisted.internet.task import LoopingCall @@ -32,12 +31,6 @@ from .detect import UnknownFormatError, create_reader, detect_compression, detect_format from .readers import ReaderParseError -try: - from urllib.parse import urljoin -except ImportError: - # PY2 fallback - from urlparse import urljoin # pylint: disable=ungrouped-imports - # TODO: check return values for deferred callbacks # TODO: review class attributes for redundancy diff --git a/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py index 35211b706c..4a0f0a05e0 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py @@ -8,8 +8,6 @@ # # pylint: disable=redefined-builtin -from __future__ import unicode_literals - import bz2 import gzip import zipfile diff --git a/deluge/plugins/Blocklist/deluge_blocklist/detect.py b/deluge/plugins/Blocklist/deluge_blocklist/detect.py index 262d5de4fa..5d7858d687 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/detect.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/detect.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from .decompressers import BZipped2, GZipped, Zipped from .readers import EmuleReader, PeerGuardianReader, SafePeerReader diff --git a/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py b/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py index b6e5d5508e..215c712316 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/gtkui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from datetime import datetime diff --git a/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py b/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py index ba410c2cf4..f5389016f6 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/peerguardian.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import gzip import logging import socket @@ -65,8 +63,5 @@ def __next__(self): return (start, end) - # Python 2 compatibility - next = __next__ - def close(self): self.fd.close() diff --git a/deluge/plugins/Blocklist/deluge_blocklist/readers.py b/deluge/plugins/Blocklist/deluge_blocklist/readers.py index 4079e849eb..6eda027a8a 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/readers.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/readers.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import re diff --git a/deluge/plugins/Blocklist/deluge_blocklist/webui.py b/deluge/plugins/Blocklist/deluge_blocklist/webui.py index 3da43c4511..7d7b0c846a 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/webui.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/webui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Execute/deluge_execute/__init__.py b/deluge/plugins/Execute/deluge_execute/__init__.py index c6d55f4ec3..d515d49111 100644 --- a/deluge/plugins/Execute/deluge_execute/__init__.py +++ b/deluge/plugins/Execute/deluge_execute/__init__.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Execute/deluge_execute/common.py b/deluge/plugins/Execute/deluge_execute/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/Execute/deluge_execute/common.py +++ b/deluge/plugins/Execute/deluge_execute/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Execute/deluge_execute/core.py b/deluge/plugins/Execute/deluge_execute/core.py index f5fa2c2e65..388e47eb75 100644 --- a/deluge/plugins/Execute/deluge_execute/core.py +++ b/deluge/plugins/Execute/deluge_execute/core.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import hashlib import logging import os diff --git a/deluge/plugins/Execute/deluge_execute/gtkui.py b/deluge/plugins/Execute/deluge_execute/gtkui.py index c0c720089f..15d735cbda 100644 --- a/deluge/plugins/Execute/deluge_execute/gtkui.py +++ b/deluge/plugins/Execute/deluge_execute/gtkui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import gi # isort:skip (Required before Gtk import). diff --git a/deluge/plugins/Execute/deluge_execute/webui.py b/deluge/plugins/Execute/deluge_execute/webui.py index 8327001b82..de337e73ce 100644 --- a/deluge/plugins/Execute/deluge_execute/webui.py +++ b/deluge/plugins/Execute/deluge_execute/webui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Extractor/deluge_extractor/__init__.py b/deluge/plugins/Extractor/deluge_extractor/__init__.py index 6db72b63b5..63e88bd479 100644 --- a/deluge/plugins/Extractor/deluge_extractor/__init__.py +++ b/deluge/plugins/Extractor/deluge_extractor/__init__.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Extractor/deluge_extractor/common.py b/deluge/plugins/Extractor/deluge_extractor/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/Extractor/deluge_extractor/common.py +++ b/deluge/plugins/Extractor/deluge_extractor/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Extractor/deluge_extractor/core.py b/deluge/plugins/Extractor/deluge_extractor/core.py index 8fa5bd3da2..54440e4460 100644 --- a/deluge/plugins/Extractor/deluge_extractor/core.py +++ b/deluge/plugins/Extractor/deluge_extractor/core.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import errno import logging import os @@ -37,10 +35,7 @@ 'C:\\Program Files (x86)\\7-Zip\\7z.exe', ] - try: - import winreg - except ImportError: - import _winreg as winreg # For Python 2. + import winreg try: hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\7-Zip') diff --git a/deluge/plugins/Extractor/deluge_extractor/gtkui.py b/deluge/plugins/Extractor/deluge_extractor/gtkui.py index 113b33f6d0..5536a0e28a 100644 --- a/deluge/plugins/Extractor/deluge_extractor/gtkui.py +++ b/deluge/plugins/Extractor/deluge_extractor/gtkui.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import gi # isort:skip (Required before Gtk import). diff --git a/deluge/plugins/Extractor/deluge_extractor/webui.py b/deluge/plugins/Extractor/deluge_extractor/webui.py index feb7b4a835..eaab79a749 100644 --- a/deluge/plugins/Extractor/deluge_extractor/webui.py +++ b/deluge/plugins/Extractor/deluge_extractor/webui.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Label/deluge_label/__init__.py b/deluge/plugins/Label/deluge_label/__init__.py index bc0b0f2430..fea7dcdcda 100644 --- a/deluge/plugins/Label/deluge_label/__init__.py +++ b/deluge/plugins/Label/deluge_label/__init__.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Label/deluge_label/common.py b/deluge/plugins/Label/deluge_label/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/Label/deluge_label/common.py +++ b/deluge/plugins/Label/deluge_label/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Label/deluge_label/core.py b/deluge/plugins/Label/deluge_label/core.py index b16156c917..d4200f618d 100644 --- a/deluge/plugins/Label/deluge_label/core.py +++ b/deluge/plugins/Label/deluge_label/core.py @@ -15,8 +15,6 @@ torrent-label core plugin. adds a status field for tracker. """ -from __future__ import unicode_literals - import logging import re diff --git a/deluge/plugins/Label/deluge_label/gtkui/__init__.py b/deluge/plugins/Label/deluge_label/gtkui/__init__.py index eeaeadcc88..88c470d4d3 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/__init__.py +++ b/deluge/plugins/Label/deluge_label/gtkui/__init__.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge import component # for systray diff --git a/deluge/plugins/Label/deluge_label/gtkui/label_config.py b/deluge/plugins/Label/deluge_label/gtkui/label_config.py index b1bf56de6f..6edf4ddeb2 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/label_config.py +++ b/deluge/plugins/Label/deluge_label/gtkui/label_config.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository.Gtk import Builder diff --git a/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py b/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py index fe0e86bda0..499175bfdc 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py +++ b/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import gi # isort:skip (Required before Gtk import). diff --git a/deluge/plugins/Label/deluge_label/gtkui/submenu.py b/deluge/plugins/Label/deluge_label/gtkui/submenu.py index c5f80e70ca..f41b8457da 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/submenu.py +++ b/deluge/plugins/Label/deluge_label/gtkui/submenu.py @@ -8,8 +8,6 @@ # -from __future__ import unicode_literals - import logging from gi.repository.Gtk import Menu, MenuItem diff --git a/deluge/plugins/Label/deluge_label/test.py b/deluge/plugins/Label/deluge_label/test.py index 5c9ffcd000..00d052bfa0 100644 --- a/deluge/plugins/Label/deluge_label/test.py +++ b/deluge/plugins/Label/deluge_label/test.py @@ -10,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - from deluge.ui.client import sclient sclient.set_core_uri() diff --git a/deluge/plugins/Label/deluge_label/webui.py b/deluge/plugins/Label/deluge_label/webui.py index 58c38e9414..cc044e9323 100644 --- a/deluge/plugins/Label/deluge_label/webui.py +++ b/deluge/plugins/Label/deluge_label/webui.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Notifications/deluge_notifications/__init__.py b/deluge/plugins/Notifications/deluge_notifications/__init__.py index 810e284df1..c3001088f6 100644 --- a/deluge/plugins/Notifications/deluge_notifications/__init__.py +++ b/deluge/plugins/Notifications/deluge_notifications/__init__.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Notifications/deluge_notifications/common.py b/deluge/plugins/Notifications/deluge_notifications/common.py index 6966122ca2..2361862ddc 100644 --- a/deluge/plugins/Notifications/deluge_notifications/common.py +++ b/deluge/plugins/Notifications/deluge_notifications/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path diff --git a/deluge/plugins/Notifications/deluge_notifications/core.py b/deluge/plugins/Notifications/deluge_notifications/core.py index 9eede45767..5f4ab7afef 100644 --- a/deluge/plugins/Notifications/deluge_notifications/core.py +++ b/deluge/plugins/Notifications/deluge_notifications/core.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import smtplib from email.utils import formatdate @@ -119,7 +117,6 @@ def _notify_email(self, subject='', message=''): message = '\r\n'.join((headers + message).splitlines()) try: - # Python 2.6 server = smtplib.SMTP( self.config['smtp_host'], self.config['smtp_port'], timeout=60 ) diff --git a/deluge/plugins/Notifications/deluge_notifications/gtkui.py b/deluge/plugins/Notifications/deluge_notifications/gtkui.py index cb26901a78..96146f9391 100644 --- a/deluge/plugins/Notifications/deluge_notifications/gtkui.py +++ b/deluge/plugins/Notifications/deluge_notifications/gtkui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from os.path import basename diff --git a/deluge/plugins/Notifications/deluge_notifications/test.py b/deluge/plugins/Notifications/deluge_notifications/test.py index 2e6f9755b5..16dbbf18d3 100644 --- a/deluge/plugins/Notifications/deluge_notifications/test.py +++ b/deluge/plugins/Notifications/deluge_notifications/test.py @@ -6,8 +6,6 @@ # License: BSD - Please view the LICENSE file for additional information. # ============================================================================== -from __future__ import unicode_literals - import logging from twisted.internet import task diff --git a/deluge/plugins/Notifications/deluge_notifications/webui.py b/deluge/plugins/Notifications/deluge_notifications/webui.py index d3529c4f95..9ce1b00123 100644 --- a/deluge/plugins/Notifications/deluge_notifications/webui.py +++ b/deluge/plugins/Notifications/deluge_notifications/webui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Scheduler/deluge_scheduler/__init__.py b/deluge/plugins/Scheduler/deluge_scheduler/__init__.py index 6db72b63b5..63e88bd479 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/__init__.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/__init__.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Scheduler/deluge_scheduler/common.py b/deluge/plugins/Scheduler/deluge_scheduler/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/common.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Scheduler/deluge_scheduler/core.py b/deluge/plugins/Scheduler/deluge_scheduler/core.py index 388e4f0f61..008afbcd4e 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/core.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/core.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import time diff --git a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py index 12f5fb63ce..3b768eb488 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/gtkui.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging from gi.repository import Gdk, Gtk diff --git a/deluge/plugins/Scheduler/deluge_scheduler/webui.py b/deluge/plugins/Scheduler/deluge_scheduler/webui.py index 518eaa6aaf..daf5b99550 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/webui.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/webui.py @@ -10,8 +10,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Stats/deluge_stats/__init__.py b/deluge/plugins/Stats/deluge_stats/__init__.py index a40379b9a9..a7ec1b7015 100644 --- a/deluge/plugins/Stats/deluge_stats/__init__.py +++ b/deluge/plugins/Stats/deluge_stats/__init__.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Stats/deluge_stats/common.py b/deluge/plugins/Stats/deluge_stats/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/Stats/deluge_stats/common.py +++ b/deluge/plugins/Stats/deluge_stats/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Stats/deluge_stats/core.py b/deluge/plugins/Stats/deluge_stats/core.py index 5f38b69b45..148a4033ab 100644 --- a/deluge/plugins/Stats/deluge_stats/core.py +++ b/deluge/plugins/Stats/deluge_stats/core.py @@ -10,8 +10,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import time diff --git a/deluge/plugins/Stats/deluge_stats/graph.py b/deluge/plugins/Stats/deluge_stats/graph.py index bc18913b3c..eb54dbd5f7 100644 --- a/deluge/plugins/Stats/deluge_stats/graph.py +++ b/deluge/plugins/Stats/deluge_stats/graph.py @@ -14,8 +14,6 @@ port of old plugin by markybob. """ -from __future__ import division, unicode_literals - import logging import math import time diff --git a/deluge/plugins/Stats/deluge_stats/gtkui.py b/deluge/plugins/Stats/deluge_stats/gtkui.py index 75e30150e3..e207c0471c 100644 --- a/deluge/plugins/Stats/deluge_stats/gtkui.py +++ b/deluge/plugins/Stats/deluge_stats/gtkui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging from gi.repository import Gtk diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py index ab24568773..7b2c2fbff2 100644 --- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py @@ -4,8 +4,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import pytest from twisted.internet import defer from twisted.trial import unittest diff --git a/deluge/plugins/Stats/deluge_stats/webui.py b/deluge/plugins/Stats/deluge_stats/webui.py index 4c11260e50..9e7e6992d4 100644 --- a/deluge/plugins/Stats/deluge_stats/webui.py +++ b/deluge/plugins/Stats/deluge_stats/webui.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/Toggle/deluge_toggle/__init__.py b/deluge/plugins/Toggle/deluge_toggle/__init__.py index e63e4aa4cb..13fa017ef1 100644 --- a/deluge/plugins/Toggle/deluge_toggle/__init__.py +++ b/deluge/plugins/Toggle/deluge_toggle/__init__.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/Toggle/deluge_toggle/common.py b/deluge/plugins/Toggle/deluge_toggle/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/Toggle/deluge_toggle/common.py +++ b/deluge/plugins/Toggle/deluge_toggle/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/Toggle/deluge_toggle/core.py b/deluge/plugins/Toggle/deluge_toggle/core.py index dad52ce619..77727e451a 100644 --- a/deluge/plugins/Toggle/deluge_toggle/core.py +++ b/deluge/plugins/Toggle/deluge_toggle/core.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/plugins/Toggle/deluge_toggle/gtkui.py b/deluge/plugins/Toggle/deluge_toggle/gtkui.py index c54bca46fc..f9d8cf917f 100644 --- a/deluge/plugins/Toggle/deluge_toggle/gtkui.py +++ b/deluge/plugins/Toggle/deluge_toggle/gtkui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/plugins/Toggle/deluge_toggle/webui.py b/deluge/plugins/Toggle/deluge_toggle/webui.py index 8f0fc8c99c..c46af6d652 100644 --- a/deluge/plugins/Toggle/deluge_toggle/webui.py +++ b/deluge/plugins/Toggle/deluge_toggle/webui.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.plugins.pluginbase import WebPluginBase diff --git a/deluge/plugins/WebUi/deluge_webui/__init__.py b/deluge/plugins/WebUi/deluge_webui/__init__.py index a3d29805ae..5b9aec38be 100644 --- a/deluge/plugins/WebUi/deluge_webui/__init__.py +++ b/deluge/plugins/WebUi/deluge_webui/__init__.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.plugins.init import PluginInitBase diff --git a/deluge/plugins/WebUi/deluge_webui/common.py b/deluge/plugins/WebUi/deluge_webui/common.py index 4c9db09d5b..28233e9843 100644 --- a/deluge/plugins/WebUi/deluge_webui/common.py +++ b/deluge/plugins/WebUi/deluge_webui/common.py @@ -12,8 +12,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os.path from pkg_resources import resource_filename diff --git a/deluge/plugins/WebUi/deluge_webui/core.py b/deluge/plugins/WebUi/deluge_webui/core.py index cc3330fc04..bf6b62e37c 100644 --- a/deluge/plugins/WebUi/deluge_webui/core.py +++ b/deluge/plugins/WebUi/deluge_webui/core.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from twisted.internet import defer diff --git a/deluge/plugins/WebUi/deluge_webui/gtkui.py b/deluge/plugins/WebUi/deluge_webui/gtkui.py index ca3a16ea40..8092ff78cf 100644 --- a/deluge/plugins/WebUi/deluge_webui/gtkui.py +++ b/deluge/plugins/WebUi/deluge_webui/gtkui.py @@ -11,8 +11,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository import Gtk diff --git a/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py b/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py index 56e1cc0233..a5fb923155 100644 --- a/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py +++ b/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.trial import unittest import deluge.component as component diff --git a/deluge/plugins/init.py b/deluge/plugins/init.py index addeae9f33..28b1efbc11 100644 --- a/deluge/plugins/init.py +++ b/deluge/plugins/init.py @@ -10,8 +10,6 @@ """ This base class is used in plugin's __init__ for the plugin entry points. """ -from __future__ import unicode_literals - import logging log = logging.getLogger(__name__) diff --git a/deluge/plugins/pluginbase.py b/deluge/plugins/pluginbase.py index e80199df19..6b08c27dc3 100644 --- a/deluge/plugins/pluginbase.py +++ b/deluge/plugins/pluginbase.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/scripts/create_plugin.py b/deluge/scripts/create_plugin.py index 44513ed45d..893d1373e9 100644 --- a/deluge/scripts/create_plugin.py +++ b/deluge/scripts/create_plugin.py @@ -7,8 +7,6 @@ """ -from __future__ import print_function, unicode_literals - import os import sys from argparse import ArgumentParser diff --git a/deluge/scripts/deluge_remote.py b/deluge/scripts/deluge_remote.py index bacc4f88da..174254329f 100644 --- a/deluge/scripts/deluge_remote.py +++ b/deluge/scripts/deluge_remote.py @@ -12,8 +12,6 @@ # # Authour: Garett Harnish -from __future__ import unicode_literals - import logging import sys from optparse import OptionParser diff --git a/deluge/tests/__init__.py b/deluge/tests/__init__.py index d3bf10def8..7b6afa1940 100644 --- a/deluge/tests/__init__.py +++ b/deluge/tests/__init__.py @@ -1,7 +1,5 @@ # Increase open file descriptor limit to allow tests to run # without getting error: what(): epoll: Too many open files -from __future__ import print_function, unicode_literals - from deluge.i18n import setup_translation try: diff --git a/deluge/tests/basetest.py b/deluge/tests/basetest.py index 11ca18e53e..ac65141567 100644 --- a/deluge/tests/basetest.py +++ b/deluge/tests/basetest.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import warnings from twisted.internet.defer import maybeDeferred diff --git a/deluge/tests/common.py b/deluge/tests/common.py index be33f8c583..170a2a2888 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import os import sys import tempfile diff --git a/deluge/tests/common_web.py b/deluge/tests/common_web.py index 706eb8d724..f2b82aad5f 100644 --- a/deluge/tests/common_web.py +++ b/deluge/tests/common_web.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.common import deluge.component as component import deluge.ui.web.auth diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py index 7352e0d323..92ccf0c627 100644 --- a/deluge/tests/daemon_base.py +++ b/deluge/tests/daemon_base.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import os.path import pytest diff --git a/deluge/tests/test_alertmanager.py b/deluge/tests/test_alertmanager.py index f197882cd7..b9dfce5a8c 100644 --- a/deluge/tests/test_alertmanager.py +++ b/deluge/tests/test_alertmanager.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.core.core import Core diff --git a/deluge/tests/test_authmanager.py b/deluge/tests/test_authmanager.py index 91e122f736..31a79a8577 100644 --- a/deluge/tests/test_authmanager.py +++ b/deluge/tests/test_authmanager.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.common import get_localhost_auth from deluge.core.authmanager import AUTH_LEVEL_ADMIN, AuthManager diff --git a/deluge/tests/test_bencode.py b/deluge/tests/test_bencode.py index b49c21f836..420869139c 100644 --- a/deluge/tests/test_bencode.py +++ b/deluge/tests/test_bencode.py @@ -4,8 +4,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.trial import unittest from deluge import bencode diff --git a/deluge/tests/test_client.py b/deluge/tests/test_client.py index ae1e95a714..bccbdd5e0d 100644 --- a/deluge/tests/test_client.py +++ b/deluge/tests/test_client.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.internet import defer import deluge.component as component diff --git a/deluge/tests/test_common.py b/deluge/tests/test_common.py index 4f6aa2fd4a..7459997de0 100644 --- a/deluge/tests/test_common.py +++ b/deluge/tests/test_common.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os import sys import tarfile diff --git a/deluge/tests/test_component.py b/deluge/tests/test_component.py index 26f24ad00d..5bdb165897 100644 --- a/deluge/tests/test_component.py +++ b/deluge/tests/test_component.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.internet import defer, threads from twisted.trial.unittest import SkipTest diff --git a/deluge/tests/test_config.py b/deluge/tests/test_config.py index 0f6df3bb51..a514ebcf55 100644 --- a/deluge/tests/test_config.py +++ b/deluge/tests/test_config.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os from codecs import getwriter diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py index 15fbc1bcf4..5e5815ca03 100644 --- a/deluge/tests/test_core.py +++ b/deluge/tests/test_core.py @@ -5,13 +5,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from base64 import b64encode from hashlib import sha1 as sha import pytest -from six import integer_types from twisted.internet import defer, reactor, task from twisted.internet.error import CannotListenError from twisted.python.failure import Failure @@ -432,8 +429,7 @@ def test_get_session_status_ratio(self): def test_get_free_space(self): space = self.core.get_free_space('.') - # get_free_space returns long on Python 2 (32-bit). - self.assertTrue(isinstance(space, integer_types)) + self.assertTrue(isinstance(space, int)) self.assertTrue(space >= 0) self.assertEqual(self.core.get_free_space('/someinvalidpath'), -1) diff --git a/deluge/tests/test_decorators.py b/deluge/tests/test_decorators.py index 7d4bd98c87..405a4ffc81 100644 --- a/deluge/tests/test_decorators.py +++ b/deluge/tests/test_decorators.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.trial import unittest from deluge.decorators import proxy diff --git a/deluge/tests/test_error.py b/deluge/tests/test_error.py index c552e94220..29f19c4299 100644 --- a/deluge/tests/test_error.py +++ b/deluge/tests/test_error.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.trial import unittest import deluge.error diff --git a/deluge/tests/test_files_tab.py b/deluge/tests/test_files_tab.py index 1ec8e18dec..108c4db0d0 100644 --- a/deluge/tests/test_files_tab.py +++ b/deluge/tests/test_files_tab.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import pytest from twisted.trial import unittest diff --git a/deluge/tests/test_httpdownloader.py b/deluge/tests/test_httpdownloader.py index ad947a4229..649c43cab2 100644 --- a/deluge/tests/test_httpdownloader.py +++ b/deluge/tests/test_httpdownloader.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os import tempfile from email.utils import formatdate diff --git a/deluge/tests/test_json_api.py b/deluge/tests/test_json_api.py index 1da64bf970..0e933e89e6 100644 --- a/deluge/tests/test_json_api.py +++ b/deluge/tests/test_json_api.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import json as json_lib from mock import MagicMock diff --git a/deluge/tests/test_log.py b/deluge/tests/test_log.py index 572693b7c4..d5e1fdb53a 100644 --- a/deluge/tests/test_log.py +++ b/deluge/tests/test_log.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import warnings diff --git a/deluge/tests/test_maketorrent.py b/deluge/tests/test_maketorrent.py index 4e00996538..ffab14b825 100644 --- a/deluge/tests/test_maketorrent.py +++ b/deluge/tests/test_maketorrent.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os import tempfile diff --git a/deluge/tests/test_metafile.py b/deluge/tests/test_metafile.py index fc6507cb8a..d3099c6920 100644 --- a/deluge/tests/test_metafile.py +++ b/deluge/tests/test_metafile.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os import tempfile diff --git a/deluge/tests/test_plugin_metadata.py b/deluge/tests/test_plugin_metadata.py index 436fc2c50d..e7c14b5914 100644 --- a/deluge/tests/test_plugin_metadata.py +++ b/deluge/tests/test_plugin_metadata.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.pluginmanagerbase import PluginManagerBase from . import common diff --git a/deluge/tests/test_rpcserver.py b/deluge/tests/test_rpcserver.py index 02f9af0231..59d84304a2 100644 --- a/deluge/tests/test_rpcserver.py +++ b/deluge/tests/test_rpcserver.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component import deluge.error from deluge.common import get_localhost_auth diff --git a/deluge/tests/test_security.py b/deluge/tests/test_security.py index 4ad66ab51a..6154d32d85 100644 --- a/deluge/tests/test_security.py +++ b/deluge/tests/test_security.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import os import pytest diff --git a/deluge/tests/test_sessionproxy.py b/deluge/tests/test_sessionproxy.py index 03f3cc27ee..88400342bd 100644 --- a/deluge/tests/test_sessionproxy.py +++ b/deluge/tests/test_sessionproxy.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.internet.defer import maybeDeferred, succeed from twisted.internet.task import Clock diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py index 5da817924e..c8372f5c1c 100644 --- a/deluge/tests/test_torrent.py +++ b/deluge/tests/test_torrent.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import os import time from base64 import b64encode diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py index e0ff09efc4..1be5ba3ac3 100644 --- a/deluge/tests/test_torrentmanager.py +++ b/deluge/tests/test_torrentmanager.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os import shutil import warnings @@ -133,8 +131,8 @@ def test_remove_invalid_torrent(self): InvalidTorrentError, self.tm.remove, 'torrentidthatdoesntexist' ) - def test_open_state_from_python2(self): - """Open a Python2 state with a UTF-8 encoded torrent filename.""" + def test_open_state(self): + """Open a state with a UTF-8 encoded torrent filename.""" shutil.copy( common.get_test_data_file('utf8_filename_torrents.state'), os.path.join(self.config_dir, 'state', 'torrents.state'), diff --git a/deluge/tests/test_torrentview.py b/deluge/tests/test_torrentview.py index 590760d1ef..1153e968f6 100644 --- a/deluge/tests/test_torrentview.py +++ b/deluge/tests/test_torrentview.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import pytest from twisted.trial import unittest diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index e18d339879..8f6dda9001 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import pytest from twisted.trial.unittest import SkipTest diff --git a/deluge/tests/test_transfer.py b/deluge/tests/test_transfer.py index a048303254..f38833f77a 100644 --- a/deluge/tests/test_transfer.py +++ b/deluge/tests/test_transfer.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import base64 import rencode diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py index b0c3111831..d9df0f4d35 100644 --- a/deluge/tests/test_ui_common.py +++ b/deluge/tests/test_ui_common.py @@ -6,9 +6,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import unicode_literals - -from six import assertCountEqual from twisted.trial import unittest from deluge.common import windows_check @@ -170,4 +167,4 @@ def test_utf8_encoded_paths2(self): {'download': True, 'path': 'unicode_filenames/' + filepath1, 'size': 1771}, ] - assertCountEqual(self, ti.files, result_files) + self.assertCountEqual(ti.files, result_files) diff --git a/deluge/tests/test_ui_console.py b/deluge/tests/test_ui_console.py index 3667c608e1..eacf170da5 100644 --- a/deluge/tests/test_ui_console.py +++ b/deluge/tests/test_ui_console.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import argparse from deluge.ui.console.cmdline.commands.add import Command diff --git a/deluge/tests/test_ui_entry.py b/deluge/tests/test_ui_entry.py index f85bc7d7d9..0699dabc62 100644 --- a/deluge/tests/test_ui_entry.py +++ b/deluge/tests/test_ui_entry.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import argparse import sys from io import StringIO @@ -23,7 +21,7 @@ import deluge.ui.console.cmdline.commands.quit import deluge.ui.console.main import deluge.ui.web.server -from deluge.common import PY2, get_localhost_auth, windows_check +from deluge.common import get_localhost_auth, windows_check from deluge.ui import ui_entry from deluge.ui.web.server import DelugeWeb @@ -51,10 +49,7 @@ def __init__(self, fd): setattr(self, a, getattr(sys_stdout, a)) def write(self, *data, **kwargs): - # io.StringIO requires unicode strings. data_string = str(*data) - if PY2: - data_string = data_string.decode() print(data_string, file=self.out, end='') def flush(self): @@ -448,11 +443,7 @@ def test_console_command_config_set_download_location(self): yield self.exec_command() std_output = fd.out.getvalue() self.assertTrue( - std_output.startswith( - 'Setting "download_location" to: {}\'/downloads\''.format( - 'u' if PY2 else '' - ) - ) + std_output.startswith('Setting "download_location" to: \'/downloads\'') ) self.assertTrue( std_output.endswith('Configuration value successfully updated.\n') diff --git a/deluge/tests/test_ui_gtk3.py b/deluge/tests/test_ui_gtk3.py index a208bb4947..fb8f9e6d37 100644 --- a/deluge/tests/test_ui_gtk3.py +++ b/deluge/tests/test_ui_gtk3.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import sys import mock diff --git a/deluge/tests/test_web_api.py b/deluge/tests/test_web_api.py index 0180e0bda9..96b5234b14 100644 --- a/deluge/tests/test_web_api.py +++ b/deluge/tests/test_web_api.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import json from io import BytesIO diff --git a/deluge/tests/test_web_auth.py b/deluge/tests/test_web_auth.py index a5185737c8..84a5586f47 100644 --- a/deluge/tests/test_web_auth.py +++ b/deluge/tests/test_web_auth.py @@ -4,8 +4,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import unicode_literals - from mock import patch from twisted.trial import unittest diff --git a/deluge/tests/test_webserver.py b/deluge/tests/test_webserver.py index d9684bacde..cdb0ee6ba1 100644 --- a/deluge/tests/test_webserver.py +++ b/deluge/tests/test_webserver.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import json as json_lib from io import BytesIO diff --git a/deluge/tests/twisted/plugins/delugereporter.py b/deluge/tests/twisted/plugins/delugereporter.py index c2a7b52b56..66e9a48b25 100644 --- a/deluge/tests/twisted/plugins/delugereporter.py +++ b/deluge/tests/twisted/plugins/delugereporter.py @@ -6,8 +6,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os from twisted.plugin import IPlugin diff --git a/deluge/transfer.py b/deluge/transfer.py index 6f8884ad4a..92240d2bf9 100644 --- a/deluge/transfer.py +++ b/deluge/transfer.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import struct import zlib diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 180d8ef2b2..3d7b2fc063 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import subprocess import sys diff --git a/deluge/ui/common.py b/deluge/ui/common.py index c5064a6f45..ca7d305375 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -11,8 +11,6 @@ """ The ui common module contains methods and classes that are deemed useful for all the interfaces. """ -from __future__ import unicode_literals - import logging import os from hashlib import sha1 as sha diff --git a/deluge/ui/console/__init__.py b/deluge/ui/console/__init__.py index 56e8d629d3..0ed3458533 100644 --- a/deluge/ui/console/__init__.py +++ b/deluge/ui/console/__init__.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.ui.console.console import Console UI_PATH = __path__[0] diff --git a/deluge/ui/console/cmdline/command.py b/deluge/ui/console/cmdline/command.py index 2ff32dff9f..0db7b2f47c 100644 --- a/deluge/ui/console/cmdline/command.py +++ b/deluge/ui/console/cmdline/command.py @@ -9,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import logging import shlex diff --git a/deluge/ui/console/cmdline/commands/__init__.py b/deluge/ui/console/cmdline/commands/__init__.py index 628fae5973..aa3f32cd5c 100644 --- a/deluge/ui/console/cmdline/commands/__init__.py +++ b/deluge/ui/console/cmdline/commands/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - 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 da42695b5c..b1d08cee3a 100644 --- a/deluge/ui/console/cmdline/commands/add.py +++ b/deluge/ui/console/cmdline/commands/add.py @@ -8,10 +8,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import os from base64 import b64encode +from urllib.parse import urlparse +from urllib.request import url2pathname from twisted.internet import defer @@ -21,14 +21,6 @@ from . import BaseCommand -try: - from urllib.parse import urlparse - from urllib.request import url2pathname -except ImportError: - # PY2 fallback - from urllib import url2pathname # pylint: disable=ungrouped-imports - from urlparse import urlparse # pylint: disable=ungrouped-imports - class Command(BaseCommand): """Add torrents""" diff --git a/deluge/ui/console/cmdline/commands/cache.py b/deluge/ui/console/cmdline/commands/cache.py index e427f085f4..724329b8d4 100644 --- a/deluge/ui/console/cmdline/commands/cache.py +++ b/deluge/ui/console/cmdline/commands/cache.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.ui.client import client from deluge.ui.common import DISK_CACHE_KEYS diff --git a/deluge/ui/console/cmdline/commands/config.py b/deluge/ui/console/cmdline/commands/config.py index 9821e47bca..0b2629633e 100644 --- a/deluge/ui/console/cmdline/commands/config.py +++ b/deluge/ui/console/cmdline/commands/config.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import json import logging import re diff --git a/deluge/ui/console/cmdline/commands/connect.py b/deluge/ui/console/cmdline/commands/connect.py index 6588f7a04f..677b159589 100644 --- a/deluge/ui/console/cmdline/commands/connect.py +++ b/deluge/ui/console/cmdline/commands/connect.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/cmdline/commands/debug.py b/deluge/ui/console/cmdline/commands/debug.py index 3ca06ed156..b62c85171c 100644 --- a/deluge/ui/console/cmdline/commands/debug.py +++ b/deluge/ui/console/cmdline/commands/debug.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from twisted.internet import defer import deluge.component as component diff --git a/deluge/ui/console/cmdline/commands/gui.py b/deluge/ui/console/cmdline/commands/gui.py index 10e4c499b0..6c750f3948 100644 --- a/deluge/ui/console/cmdline/commands/gui.py +++ b/deluge/ui/console/cmdline/commands/gui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/cmdline/commands/halt.py b/deluge/ui/console/cmdline/commands/halt.py index 6355958982..e68bcec33c 100644 --- a/deluge/ui/console/cmdline/commands/halt.py +++ b/deluge/ui/console/cmdline/commands/halt.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.ui.client import client diff --git a/deluge/ui/console/cmdline/commands/help.py b/deluge/ui/console/cmdline/commands/help.py index 2711eea995..42b463b3b6 100644 --- a/deluge/ui/console/cmdline/commands/help.py +++ b/deluge/ui/console/cmdline/commands/help.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from twisted.internet import defer diff --git a/deluge/ui/console/cmdline/commands/info.py b/deluge/ui/console/cmdline/commands/info.py index 0d22f76a91..c00583958e 100644 --- a/deluge/ui/console/cmdline/commands/info.py +++ b/deluge/ui/console/cmdline/commands/info.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - from os.path import sep as dirsep import deluge.component as component diff --git a/deluge/ui/console/cmdline/commands/manage.py b/deluge/ui/console/cmdline/commands/manage.py index 6375a74c39..714e3dd551 100644 --- a/deluge/ui/console/cmdline/commands/manage.py +++ b/deluge/ui/console/cmdline/commands/manage.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from twisted.internet import defer diff --git a/deluge/ui/console/cmdline/commands/move.py b/deluge/ui/console/cmdline/commands/move.py index 13e475e6f0..40f39508d9 100644 --- a/deluge/ui/console/cmdline/commands/move.py +++ b/deluge/ui/console/cmdline/commands/move.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path diff --git a/deluge/ui/console/cmdline/commands/pause.py b/deluge/ui/console/cmdline/commands/pause.py index 1f7ef31a04..de11a4c19a 100644 --- a/deluge/ui/console/cmdline/commands/pause.py +++ b/deluge/ui/console/cmdline/commands/pause.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.ui.client import client diff --git a/deluge/ui/console/cmdline/commands/plugin.py b/deluge/ui/console/cmdline/commands/plugin.py index 72cecb40f6..0dcb8062e0 100644 --- a/deluge/ui/console/cmdline/commands/plugin.py +++ b/deluge/ui/console/cmdline/commands/plugin.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component import deluge.configmanager from deluge.ui.client import client diff --git a/deluge/ui/console/cmdline/commands/quit.py b/deluge/ui/console/cmdline/commands/quit.py index 261a01a9bd..5daf77262c 100644 --- a/deluge/ui/console/cmdline/commands/quit.py +++ b/deluge/ui/console/cmdline/commands/quit.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from . import BaseCommand diff --git a/deluge/ui/console/cmdline/commands/recheck.py b/deluge/ui/console/cmdline/commands/recheck.py index c9b6360c98..7012c92bf4 100644 --- a/deluge/ui/console/cmdline/commands/recheck.py +++ b/deluge/ui/console/cmdline/commands/recheck.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.ui.client import client diff --git a/deluge/ui/console/cmdline/commands/resume.py b/deluge/ui/console/cmdline/commands/resume.py index 1f62c5f002..ed2ae0aa67 100644 --- a/deluge/ui/console/cmdline/commands/resume.py +++ b/deluge/ui/console/cmdline/commands/resume.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.ui.client import client diff --git a/deluge/ui/console/cmdline/commands/rm.py b/deluge/ui/console/cmdline/commands/rm.py index c34148ac92..bf1f9a02a9 100644 --- a/deluge/ui/console/cmdline/commands/rm.py +++ b/deluge/ui/console/cmdline/commands/rm.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/cmdline/commands/status.py b/deluge/ui/console/cmdline/commands/status.py index 948ad6b946..84cf21e947 100644 --- a/deluge/ui/console/cmdline/commands/status.py +++ b/deluge/ui/console/cmdline/commands/status.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from twisted.internet import defer diff --git a/deluge/ui/console/cmdline/commands/update_tracker.py b/deluge/ui/console/cmdline/commands/update_tracker.py index 591b951927..bee933d2fd 100644 --- a/deluge/ui/console/cmdline/commands/update_tracker.py +++ b/deluge/ui/console/cmdline/commands/update_tracker.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.component as component from deluge.ui.client import client diff --git a/deluge/ui/console/console.py b/deluge/ui/console/console.py index f683c749d5..494ead9727 100644 --- a/deluge/ui/console/console.py +++ b/deluge/ui/console/console.py @@ -7,8 +7,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import fnmatch import logging import os diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py index c74d9022f8..aee61fd32e 100644 --- a/deluge/ui/console/main.py +++ b/deluge/ui/console/main.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import locale import logging import os @@ -753,8 +751,6 @@ def write(self, s): if date_different: string = time.strftime(self.date_change_format) - if deluge.common.PY2: - string = string.decode() self.console.write_event(' ') self.console.write_event(string) diff --git a/deluge/ui/console/modes/add_util.py b/deluge/ui/console/modes/add_util.py index ac60b89748..3f7c734286 100644 --- a/deluge/ui/console/modes/add_util.py +++ b/deluge/ui/console/modes/add_util.py @@ -9,15 +9,11 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import glob import logging import os from base64 import b64encode -from six import unichr as chr # noqa: A001 shadowing - import deluge.common from deluge.ui.client import client from deluge.ui.common import TorrentInfo diff --git a/deluge/ui/console/modes/addtorrents.py b/deluge/ui/console/modes/addtorrents.py index 6b2c105d95..6d68e6c42c 100644 --- a/deluge/ui/console/modes/addtorrents.py +++ b/deluge/ui/console/modes/addtorrents.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os from base64 import b64encode @@ -23,12 +21,6 @@ from deluge.ui.console.utils import format_utils from deluge.ui.console.widgets.popup import InputPopup, MessagePopup -try: - from future_builtins import zip -except ImportError: - # Ignore on Py3. - pass - try: import curses except ImportError: diff --git a/deluge/ui/console/modes/basemode.py b/deluge/ui/console/modes/basemode.py index 5267eae5a4..4adf0f2b0b 100644 --- a/deluge/ui/console/modes/basemode.py +++ b/deluge/ui/console/modes/basemode.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import sys diff --git a/deluge/ui/console/modes/cmdline.py b/deluge/ui/console/modes/cmdline.py index 2735168db6..680bbdc5a8 100644 --- a/deluge/ui/console/modes/cmdline.py +++ b/deluge/ui/console/modes/cmdline.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import re @@ -17,7 +15,6 @@ import deluge.component as component import deluge.configmanager -from deluge.common import PY2 from deluge.decorators import overrides from deluge.ui.console.cmdline.command import Commander from deluge.ui.console.modes.basemode import BaseMode, move_cursor @@ -332,10 +329,10 @@ def read_input(self): # A key to add to the input string else: - if c > 31 and c < 256: + if 31 < c < 256: # Emulate getwch stroke = chr(c) - uchar = '' if PY2 else stroke + uchar = stroke while not uchar: try: uchar = stroke.decode(self.encoding) diff --git a/deluge/ui/console/modes/connectionmanager.py b/deluge/ui/console/modes/connectionmanager.py index a5c5968605..755694260b 100644 --- a/deluge/ui/console/modes/connectionmanager.py +++ b/deluge/ui/console/modes/connectionmanager.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/modes/eventview.py b/deluge/ui/console/modes/eventview.py index cd3308cf9a..b2949b71a7 100644 --- a/deluge/ui/console/modes/eventview.py +++ b/deluge/ui/console/modes/eventview.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/modes/preferences/__init__.py b/deluge/ui/console/modes/preferences/__init__.py index 15d77c4a8d..e827d91a3d 100644 --- a/deluge/ui/console/modes/preferences/__init__.py +++ b/deluge/ui/console/modes/preferences/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from deluge.ui.console.modes.preferences.preferences import Preferences __all__ = ['Preferences'] diff --git a/deluge/ui/console/modes/preferences/preference_panes.py b/deluge/ui/console/modes/preferences/preference_panes.py index 8663d8a9c0..1aaa66fdc4 100644 --- a/deluge/ui/console/modes/preferences/preference_panes.py +++ b/deluge/ui/console/modes/preferences/preference_panes.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.common import is_ip diff --git a/deluge/ui/console/modes/preferences/preferences.py b/deluge/ui/console/modes/preferences/preferences.py index 45a39a6216..397ab687a7 100644 --- a/deluge/ui/console/modes/preferences/preferences.py +++ b/deluge/ui/console/modes/preferences/preferences.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from collections import deque diff --git a/deluge/ui/console/modes/torrentdetail.py b/deluge/ui/console/modes/torrentdetail.py index 758cac878d..bcc22eb35f 100644 --- a/deluge/ui/console/modes/torrentdetail.py +++ b/deluge/ui/console/modes/torrentdetail.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/modes/torrentlist/__init__.py b/deluge/ui/console/modes/torrentlist/__init__.py index 18c4db377a..7b16b9d888 100644 --- a/deluge/ui/console/modes/torrentlist/__init__.py +++ b/deluge/ui/console/modes/torrentlist/__init__.py @@ -1,6 +1,3 @@ -from __future__ import unicode_literals - - class ACTION(object): PAUSE = 'pause' RESUME = 'resume' diff --git a/deluge/ui/console/modes/torrentlist/add_torrents_popup.py b/deluge/ui/console/modes/torrentlist/add_torrents_popup.py index b0ac483a00..ae73708838 100644 --- a/deluge/ui/console/modes/torrentlist/add_torrents_popup.py +++ b/deluge/ui/console/modes/torrentlist/add_torrents_popup.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.common diff --git a/deluge/ui/console/modes/torrentlist/filtersidebar.py b/deluge/ui/console/modes/torrentlist/filtersidebar.py index 0f39b5c3c3..114365e044 100644 --- a/deluge/ui/console/modes/torrentlist/filtersidebar.py +++ b/deluge/ui/console/modes/torrentlist/filtersidebar.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import curses import logging diff --git a/deluge/ui/console/modes/torrentlist/queue_mode.py b/deluge/ui/console/modes/torrentlist/queue_mode.py index 0c44aafdfe..f101cea699 100644 --- a/deluge/ui/console/modes/torrentlist/queue_mode.py +++ b/deluge/ui/console/modes/torrentlist/queue_mode.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.ui.client import client from deluge.ui.console.utils import curses_util as util from deluge.ui.console.widgets.popup import MessagePopup, SelectablePopup diff --git a/deluge/ui/console/modes/torrentlist/search_mode.py b/deluge/ui/console/modes/torrentlist/search_mode.py index 57a8e5f640..ffe75ee4cb 100644 --- a/deluge/ui/console/modes/torrentlist/search_mode.py +++ b/deluge/ui/console/modes/torrentlist/search_mode.py @@ -7,11 +7,8 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging -from deluge.common import PY2 from deluge.decorators import overrides from deluge.ui.console.modes.basemode import InputKeyHandler, move_cursor from deluge.ui.console.modes.torrentlist.torrentactions import torrent_actions_popup @@ -176,7 +173,7 @@ def handle_read(self, c): elif c > 31 and c < 256: old_search_string = self.search_string stroke = chr(c) - uchar = '' if PY2 else stroke + uchar = stroke while not uchar: try: uchar = stroke.decode(self.torrentlist.encoding) diff --git a/deluge/ui/console/modes/torrentlist/torrentactions.py b/deluge/ui/console/modes/torrentlist/torrentactions.py index f3cd395099..9ec397538e 100644 --- a/deluge/ui/console/modes/torrentlist/torrentactions.py +++ b/deluge/ui/console/modes/torrentlist/torrentactions.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os diff --git a/deluge/ui/console/modes/torrentlist/torrentlist.py b/deluge/ui/console/modes/torrentlist/torrentlist.py index a427d65b0f..522986c899 100644 --- a/deluge/ui/console/modes/torrentlist/torrentlist.py +++ b/deluge/ui/console/modes/torrentlist/torrentlist.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from collections import deque diff --git a/deluge/ui/console/modes/torrentlist/torrentview.py b/deluge/ui/console/modes/torrentlist/torrentview.py index 67de3e7868..2668d3aaae 100644 --- a/deluge/ui/console/modes/torrentlist/torrentview.py +++ b/deluge/ui/console/modes/torrentlist/torrentview.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py b/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py index 9dff843067..86494cbf4b 100644 --- a/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py +++ b/deluge/ui/console/modes/torrentlist/torrentviewcolumns.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.decorators import overrides from deluge.ui.console.utils import curses_util as util from deluge.ui.console.utils.column import torrent_data_fields diff --git a/deluge/ui/console/parser.py b/deluge/ui/console/parser.py index 917773aef1..b39f2a878b 100644 --- a/deluge/ui/console/parser.py +++ b/deluge/ui/console/parser.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import argparse import shlex diff --git a/deluge/ui/console/utils/colors.py b/deluge/ui/console/utils/colors.py index 587c1f3f6b..5c35a83277 100644 --- a/deluge/ui/console/utils/colors.py +++ b/deluge/ui/console/utils/colors.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import re diff --git a/deluge/ui/console/utils/column.py b/deluge/ui/console/utils/column.py index d932159577..f59a549d94 100644 --- a/deluge/ui/console/utils/column.py +++ b/deluge/ui/console/utils/column.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import copy import logging diff --git a/deluge/ui/console/utils/common.py b/deluge/ui/console/utils/common.py index df1c079178..b0dbe0ec4a 100644 --- a/deluge/ui/console/utils/common.py +++ b/deluge/ui/console/utils/common.py @@ -5,8 +5,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - TORRENT_OPTIONS = { 'max_download_speed': float, 'max_upload_speed': float, diff --git a/deluge/ui/console/utils/curses_util.py b/deluge/ui/console/utils/curses_util.py index a0cd6dc4bd..0d94d0c518 100644 --- a/deluge/ui/console/utils/curses_util.py +++ b/deluge/ui/console/utils/curses_util.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - try: import curses except ImportError: diff --git a/deluge/ui/console/utils/format_utils.py b/deluge/ui/console/utils/format_utils.py index 029fb20112..441d06dea7 100644 --- a/deluge/ui/console/utils/format_utils.py +++ b/deluge/ui/console/utils/format_utils.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import re from collections import deque from unicodedata import east_asian_width, normalize diff --git a/deluge/ui/console/widgets/__init__.py b/deluge/ui/console/widgets/__init__.py index a11e3f2b87..bc88a3b6bb 100644 --- a/deluge/ui/console/widgets/__init__.py +++ b/deluge/ui/console/widgets/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from deluge.ui.console.widgets.inputpane import BaseInputPane from deluge.ui.console.widgets.statusbars import StatusBars from deluge.ui.console.widgets.window import BaseWindow diff --git a/deluge/ui/console/widgets/fields.py b/deluge/ui/console/widgets/fields.py index 021cab7383..86a06109ee 100644 --- a/deluge/ui/console/widgets/fields.py +++ b/deluge/ui/console/widgets/fields.py @@ -9,12 +9,9 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os -from deluge.common import PY2 from deluge.decorators import overrides from deluge.ui.console.modes.basemode import InputKeyHandler from deluge.ui.console.utils import colors @@ -951,7 +948,7 @@ def handle_read(self, c): elif c > 31 and c < 256: # Emulate getwch stroke = chr(c) - uchar = '' if PY2 else stroke + uchar = stroke while not uchar: try: uchar = stroke.decode(self.parent.encoding) diff --git a/deluge/ui/console/widgets/inputpane.py b/deluge/ui/console/widgets/inputpane.py index 097a6cb8df..d79d63df09 100644 --- a/deluge/ui/console/widgets/inputpane.py +++ b/deluge/ui/console/widgets/inputpane.py @@ -9,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.decorators import overrides diff --git a/deluge/ui/console/widgets/popup.py b/deluge/ui/console/widgets/popup.py index d588bbb241..d73dd1a23e 100644 --- a/deluge/ui/console/widgets/popup.py +++ b/deluge/ui/console/widgets/popup.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.decorators import overrides diff --git a/deluge/ui/console/widgets/sidebar.py b/deluge/ui/console/widgets/sidebar.py index cc237174da..73f350a7f3 100644 --- a/deluge/ui/console/widgets/sidebar.py +++ b/deluge/ui/console/widgets/sidebar.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import curses import logging diff --git a/deluge/ui/console/widgets/statusbars.py b/deluge/ui/console/widgets/statusbars.py index 44cc158187..f9bd8ba528 100644 --- a/deluge/ui/console/widgets/statusbars.py +++ b/deluge/ui/console/widgets/statusbars.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import deluge.common import deluge.component as component from deluge.ui.client import client diff --git a/deluge/ui/console/widgets/window.py b/deluge/ui/console/widgets/window.py index 2ef35281ec..1b68346eaf 100644 --- a/deluge/ui/console/widgets/window.py +++ b/deluge/ui/console/widgets/window.py @@ -9,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from deluge.ui.console.modes.basemode import add_string, mkpad, mkpanel diff --git a/deluge/ui/coreconfig.py b/deluge/ui/coreconfig.py index ed6b614a23..f5483e5625 100644 --- a/deluge/ui/coreconfig.py +++ b/deluge/ui/coreconfig.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/countries.py b/deluge/ui/countries.py index af390853e6..b21c8b9110 100644 --- a/deluge/ui/countries.py +++ b/deluge/ui/countries.py @@ -3,8 +3,6 @@ # This file is public domain. # -from __future__ import unicode_literals - # ISO 3166-1 country names and codes COUNTRIES = { 'AF': _('Afghanistan'), diff --git a/deluge/ui/gtk3/__init__.py b/deluge/ui/gtk3/__init__.py index 8e8b196135..82bcea1d41 100644 --- a/deluge/ui/gtk3/__init__.py +++ b/deluge/ui/gtk3/__init__.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from os import environ diff --git a/deluge/ui/gtk3/aboutdialog.py b/deluge/ui/gtk3/aboutdialog.py index 9974a13de0..2165cbc280 100644 --- a/deluge/ui/gtk3/aboutdialog.py +++ b/deluge/ui/gtk3/aboutdialog.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from gi.repository import Gtk import deluge.component as component diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py index 81b8dbaf34..f4df0d29e1 100644 --- a/deluge/ui/gtk3/addtorrentdialog.py +++ b/deluge/ui/gtk3/addtorrentdialog.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import os from base64 import b64encode diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py index e7b46c8d54..455a4da2e6 100644 --- a/deluge/ui/gtk3/common.py +++ b/deluge/ui/gtk3/common.py @@ -7,15 +7,13 @@ # See LICENSE for more details. # """Common functions for various parts of gtkui to use.""" -from __future__ import unicode_literals - import contextlib import logging import os +import pickle import shutil import sys -import six.moves.cPickle as pickle # noqa: N813 from gi.repository.Gdk import SELECTION_CLIPBOARD, SELECTION_PRIMARY, Display from gi.repository.GdkPixbuf import Colorspace, Pixbuf from gi.repository.GLib import GError @@ -29,7 +27,7 @@ SortType, ) -from deluge.common import PY2, get_pixmap, is_ip, osx_check, windows_check +from deluge.common import get_pixmap, is_ip, osx_check, windows_check log = logging.getLogger(__name__) @@ -232,10 +230,7 @@ def associate_magnet_links(overwrite=False): """ if windows_check(): - try: - import winreg - except ImportError: - import _winreg as winreg # For Python 2. + import winreg try: hkey = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'Magnet') @@ -356,10 +351,7 @@ def load_pickled_state_file(filename): log.info('Opening %s for load: %s', filename, _filepath) try: with open(_filepath, 'rb') as _file: - if PY2: - state = pickle.load(_file) - else: - state = pickle.load(_file, encoding='utf8') + state = pickle.load(_file, encoding='utf8') except (IOError, pickle.UnpicklingError) as ex: log.warning('Unable to load %s: %s', _filepath, ex) else: diff --git a/deluge/ui/gtk3/connectionmanager.py b/deluge/ui/gtk3/connectionmanager.py index d5883c4b34..89718e0e0b 100644 --- a/deluge/ui/gtk3/connectionmanager.py +++ b/deluge/ui/gtk3/connectionmanager.py @@ -7,11 +7,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os from socket import gaierror, gethostbyname +from urllib.parse import urlparse from gi.repository import Gtk from twisted.internet import defer, reactor @@ -26,12 +25,6 @@ from .common import get_clipboard_text from .dialogs import AuthenticationDialog, ErrorDialog -try: - from urllib.parse import urlparse -except ImportError: - # PY2 fallback - from urlparse import urlparse # pylint: disable=ungrouped-imports - log = logging.getLogger(__name__) HOSTLIST_COL_ID = 0 diff --git a/deluge/ui/gtk3/createtorrentdialog.py b/deluge/ui/gtk3/createtorrentdialog.py index 1e5e73cb66..4108f629ac 100644 --- a/deluge/ui/gtk3/createtorrentdialog.py +++ b/deluge/ui/gtk3/createtorrentdialog.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import os.path from base64 import b64encode diff --git a/deluge/ui/gtk3/details_tab.py b/deluge/ui/gtk3/details_tab.py index 2431e0836e..2dde17aa6b 100644 --- a/deluge/ui/gtk3/details_tab.py +++ b/deluge/ui/gtk3/details_tab.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from xml.sax.saxutils import escape as xml_escape diff --git a/deluge/ui/gtk3/dialogs.py b/deluge/ui/gtk3/dialogs.py index 4a2a60a7e0..5bb332b039 100644 --- a/deluge/ui/gtk3/dialogs.py +++ b/deluge/ui/gtk3/dialogs.py @@ -9,8 +9,6 @@ # pylint: disable=super-on-old-class -from __future__ import unicode_literals - from gi.repository import Gtk from twisted.internet import defer diff --git a/deluge/ui/gtk3/edittrackersdialog.py b/deluge/ui/gtk3/edittrackersdialog.py index a21a7d71fb..5e4b0e5e62 100644 --- a/deluge/ui/gtk3/edittrackersdialog.py +++ b/deluge/ui/gtk3/edittrackersdialog.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path diff --git a/deluge/ui/gtk3/files_tab.py b/deluge/ui/gtk3/files_tab.py index 50f8a45873..61e0b9089a 100644 --- a/deluge/ui/gtk3/files_tab.py +++ b/deluge/ui/gtk3/files_tab.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import json import logging import os.path diff --git a/deluge/ui/gtk3/filtertreeview.py b/deluge/ui/gtk3/filtertreeview.py index 4272ef018b..5b9c1e2fb7 100644 --- a/deluge/ui/gtk3/filtertreeview.py +++ b/deluge/ui/gtk3/filtertreeview.py @@ -9,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import warnings diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py index 02b3090783..6c4972ba72 100644 --- a/deluge/ui/gtk3/gtkui.py +++ b/deluge/ui/gtk3/gtkui.py @@ -8,8 +8,6 @@ # # pylint: disable=wrong-import-position -from __future__ import division, unicode_literals - import logging import os import signal diff --git a/deluge/ui/gtk3/ipcinterface.py b/deluge/ui/gtk3/ipcinterface.py index 78858c4434..ac176479d5 100644 --- a/deluge/ui/gtk3/ipcinterface.py +++ b/deluge/ui/gtk3/ipcinterface.py @@ -7,14 +7,14 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import sys from base64 import b64encode from glob import glob from tempfile import mkstemp +from urllib.parse import urlparse +from urllib.request import url2pathname import rencode import twisted.internet.error @@ -26,14 +26,6 @@ from deluge.configmanager import ConfigManager, get_config_dir from deluge.ui.client import client -try: - from urllib.parse import urlparse - from urllib.request import url2pathname -except ImportError: - # PY2 fallback - from urllib import url2pathname # pylint: disable=ungrouped-imports - from urlparse import urlparse # pylint: disable=ungrouped-imports - log = logging.getLogger(__name__) diff --git a/deluge/ui/gtk3/listview.py b/deluge/ui/gtk3/listview.py index 4e9fe5db8d..d828e5d864 100644 --- a/deluge/ui/gtk3/listview.py +++ b/deluge/ui/gtk3/listview.py @@ -7,13 +7,11 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository import GObject, Gtk -from deluge.common import PY2, decode_bytes +from deluge.common import decode_bytes from .common import cmp, load_pickled_state_file, save_pickled_state_file @@ -75,9 +73,7 @@ class TreeviewColumn(Gtk.TreeViewColumn, object): """ __gsignals__ = { - 'button-press-event' - if not PY2 - else b'button-press-event': (GObject.SIGNAL_RUN_LAST, None, (object,)) + 'button-press-event': (GObject.SIGNAL_RUN_LAST, None, (object,)) } def __init__(self, title=None, cell_renderer=None, **args): diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py index b7d7514109..43a419cb47 100644 --- a/deluge/ui/gtk3/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path from hashlib import sha1 as sha diff --git a/deluge/ui/gtk3/menubar.py b/deluge/ui/gtk3/menubar.py index e09f394fc9..77b1d3a10d 100644 --- a/deluge/ui/gtk3/menubar.py +++ b/deluge/ui/gtk3/menubar.py @@ -9,8 +9,6 @@ # -from __future__ import unicode_literals - import logging import os.path diff --git a/deluge/ui/gtk3/menubar_osx.py b/deluge/ui/gtk3/menubar_osx.py index 1df6fab08f..096c5ffd49 100644 --- a/deluge/ui/gtk3/menubar_osx.py +++ b/deluge/ui/gtk3/menubar_osx.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from gi.repository.Gdk import ModifierType from gi.repository.Gtk import SeparatorMenuItem, accel_groups_from_object from gi.repository.Gtk.AccelFlags import VISIBLE diff --git a/deluge/ui/gtk3/new_release_dialog.py b/deluge/ui/gtk3/new_release_dialog.py index 6aa3282601..a36b6f26d9 100644 --- a/deluge/ui/gtk3/new_release_dialog.py +++ b/deluge/ui/gtk3/new_release_dialog.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from gi.repository.Gtk import IconSize import deluge.common diff --git a/deluge/ui/gtk3/options_tab.py b/deluge/ui/gtk3/options_tab.py index 6a25fd1e83..e592ad53ec 100644 --- a/deluge/ui/gtk3/options_tab.py +++ b/deluge/ui/gtk3/options_tab.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from gi.repository.Gdk import keyval_name import deluge.component as component diff --git a/deluge/ui/gtk3/path_chooser.py b/deluge/ui/gtk3/path_chooser.py index b7228415e1..9521969169 100644 --- a/deluge/ui/gtk3/path_chooser.py +++ b/deluge/ui/gtk3/path_chooser.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/gtk3/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py index 72e98e4972..755ae5fe13 100755 --- a/deluge/ui/gtk3/path_combo_chooser.py +++ b/deluge/ui/gtk3/path_combo_chooser.py @@ -8,15 +8,13 @@ # See LICENSE for more details. # -from __future__ import division, print_function, unicode_literals - import os import warnings from gi.repository import Gdk, GObject, Gtk from gi.repository.GObject import SignalFlags -from deluge.common import PY2, resource_filename +from deluge.common import resource_filename from deluge.path_chooser_common import get_completion_paths # Filter the pygobject signal warning: @@ -1106,9 +1104,7 @@ def _end_completion(self, args): class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject): __gsignals__ = { - signal - if not PY2 - else signal.encode(): (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,)) + signal: (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,)) for signal in [ 'text-changed', 'accelerator-set', diff --git a/deluge/ui/gtk3/peers_tab.py b/deluge/ui/gtk3/peers_tab.py index e0282becf3..afd4774beb 100644 --- a/deluge/ui/gtk3/peers_tab.py +++ b/deluge/ui/gtk3/peers_tab.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path @@ -42,12 +40,6 @@ cell_data_speed_up, ) -try: - from future_builtins import zip -except ImportError: - # Ignore on Py3. - pass - log = logging.getLogger(__name__) diff --git a/deluge/ui/gtk3/piecesbar.py b/deluge/ui/gtk3/piecesbar.py index 549f9c048c..6f0b980529 100644 --- a/deluge/ui/gtk3/piecesbar.py +++ b/deluge/ui/gtk3/piecesbar.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - from math import pi import gi # isort:skip (Version check required before import). @@ -24,7 +22,6 @@ from gi.repository.Pango import SCALE, Weight # isort:imports-firstparty -from deluge.common import PY2 from deluge.configmanager import ConfigManager COLOR_STATES = ['missing', 'waiting', 'downloading', 'completed'] @@ -32,7 +29,7 @@ class PiecesBar(DrawingArea): # Draw in response to an draw - __gsignals__ = {'draw': 'override'} if not PY2 else {b'draw': b'override'} + __gsignals__ = {'draw': 'override'} def __init__(self): super(PiecesBar, self).__init__() diff --git a/deluge/ui/gtk3/pluginmanager.py b/deluge/ui/gtk3/pluginmanager.py index d60f8d390b..017798ab98 100644 --- a/deluge/ui/gtk3/pluginmanager.py +++ b/deluge/ui/gtk3/pluginmanager.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/gtk3/preferences.py b/deluge/ui/gtk3/preferences.py index 13930fc554..ee6d23dfdc 100644 --- a/deluge/ui/gtk3/preferences.py +++ b/deluge/ui/gtk3/preferences.py @@ -8,11 +8,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os from hashlib import sha1 as sha +from urllib.parse import urlparse from gi import require_version from gi.repository import Gtk @@ -30,12 +29,6 @@ from .dialogs import AccountDialog, ErrorDialog, InformationDialog, YesNoDialog from .path_chooser import PathChooser -try: - from urllib.parse import urlparse -except ImportError: - # PY2 fallback - from urlparse import urlparse # pylint: disable=ungrouped-imports - try: require_version('AppIndicator3', '0.1') from gi.repository import AppIndicator3 # noqa: F401 diff --git a/deluge/ui/gtk3/queuedtorrents.py b/deluge/ui/gtk3/queuedtorrents.py index 0f08c24c6e..f2aa851b8b 100644 --- a/deluge/ui/gtk3/queuedtorrents.py +++ b/deluge/ui/gtk3/queuedtorrents.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os.path diff --git a/deluge/ui/gtk3/removetorrentdialog.py b/deluge/ui/gtk3/removetorrentdialog.py index 48806a5d5d..cc0cffedca 100644 --- a/deluge/ui/gtk3/removetorrentdialog.py +++ b/deluge/ui/gtk3/removetorrentdialog.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os diff --git a/deluge/ui/gtk3/sidebar.py b/deluge/ui/gtk3/sidebar.py index 1d751918f6..7cf6377616 100644 --- a/deluge/ui/gtk3/sidebar.py +++ b/deluge/ui/gtk3/sidebar.py @@ -8,8 +8,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository.Gtk import Label, PolicyType, ScrolledWindow diff --git a/deluge/ui/gtk3/status_tab.py b/deluge/ui/gtk3/status_tab.py index 938c2dd7d7..c1fe9ccba2 100644 --- a/deluge/ui/gtk3/status_tab.py +++ b/deluge/ui/gtk3/status_tab.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/gtk3/statusbar.py b/deluge/ui/gtk3/statusbar.py index 18db753fa8..fda235eeb1 100644 --- a/deluge/ui/gtk3/statusbar.py +++ b/deluge/ui/gtk3/statusbar.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import logging from gi.repository import Gtk diff --git a/deluge/ui/gtk3/systemtray.py b/deluge/ui/gtk3/systemtray.py index a2435223b5..ef497747d6 100644 --- a/deluge/ui/gtk3/systemtray.py +++ b/deluge/ui/gtk3/systemtray.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os diff --git a/deluge/ui/gtk3/tab_data_funcs.py b/deluge/ui/gtk3/tab_data_funcs.py index 6fa0ba59ce..e0fb74587d 100644 --- a/deluge/ui/gtk3/tab_data_funcs.py +++ b/deluge/ui/gtk3/tab_data_funcs.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - from deluge.common import fdate, fsize, fspeed, ftime from deluge.ui.common import TRACKER_STATUS_TRANSLATION diff --git a/deluge/ui/gtk3/toolbar.py b/deluge/ui/gtk3/toolbar.py index 7bc029e4b1..600fce7381 100644 --- a/deluge/ui/gtk3/toolbar.py +++ b/deluge/ui/gtk3/toolbar.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from gi.repository.Gtk import SeparatorToolItem, ToolButton diff --git a/deluge/ui/gtk3/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py index a586c29972..888ae5e38b 100644 --- a/deluge/ui/gtk3/torrentdetails.py +++ b/deluge/ui/gtk3/torrentdetails.py @@ -9,8 +9,6 @@ """The torrent details component shows info about the selected torrent.""" -from __future__ import unicode_literals - import logging from collections import namedtuple diff --git a/deluge/ui/gtk3/torrentview.py b/deluge/ui/gtk3/torrentview.py index 46c0884b15..3bc8bbacd0 100644 --- a/deluge/ui/gtk3/torrentview.py +++ b/deluge/ui/gtk3/torrentview.py @@ -8,8 +8,6 @@ # """The torrent view component that lists all torrents in the session.""" -from __future__ import unicode_literals - import logging from locale import strcoll diff --git a/deluge/ui/gtk3/torrentview_data_funcs.py b/deluge/ui/gtk3/torrentview_data_funcs.py index 8bd1f9c517..91d4663bcc 100644 --- a/deluge/ui/gtk3/torrentview_data_funcs.py +++ b/deluge/ui/gtk3/torrentview_data_funcs.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import warnings from functools import partial diff --git a/deluge/ui/gtk3/trackers_tab.py b/deluge/ui/gtk3/trackers_tab.py index d83b9956cd..6accf1d67e 100644 --- a/deluge/ui/gtk3/trackers_tab.py +++ b/deluge/ui/gtk3/trackers_tab.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.component as component diff --git a/deluge/ui/hostlist.py b/deluge/ui/hostlist.py index b4bb538fb6..5d0e68c7a5 100644 --- a/deluge/ui/hostlist.py +++ b/deluge/ui/hostlist.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os import uuid diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py index 5af8e79cd1..b89d04dfc5 100644 --- a/deluge/ui/sessionproxy.py +++ b/deluge/ui/sessionproxy.py @@ -6,8 +6,6 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import unicode_literals - import logging from time import time diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index c10cd2f8e3..3f3ca4dbee 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -7,11 +7,11 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os +from html.parser import HTMLParser from tempfile import mkstemp +from urllib.parse import urljoin, urlparse from twisted.internet import defer, threads from twisted.web.error import PageRedirect @@ -22,14 +22,6 @@ from deluge.decorators import proxy from deluge.httpdownloader import download_file -try: - from html.parser import HTMLParser - from urllib.parse import urljoin, urlparse -except ImportError: - # PY2 fallback - from HTMLParser import HTMLParser - from urlparse import urljoin, urlparse # pylint: disable=ungrouped-imports - try: from PIL import Image except ImportError: diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py index 0986ec7777..3c75f2acd2 100644 --- a/deluge/ui/ui.py +++ b/deluge/ui/ui.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import deluge.common diff --git a/deluge/ui/ui_entry.py b/deluge/ui/ui_entry.py index 71ce837835..eae56bf6a5 100644 --- a/deluge/ui/ui_entry.py +++ b/deluge/ui/ui_entry.py @@ -12,8 +12,6 @@ # user runs the command 'deluge'. """Main starting point for Deluge""" -from __future__ import unicode_literals - import argparse import logging import os diff --git a/deluge/ui/web/__init__.py b/deluge/ui/web/__init__.py index 0be7eedb9b..3757e0b1c8 100644 --- a/deluge/ui/web/__init__.py +++ b/deluge/ui/web/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from deluge.ui.web.web import Web diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py index d631f9186b..9c8158a52a 100644 --- a/deluge/ui/web/auth.py +++ b/deluge/ui/web/auth.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import hashlib import logging import os diff --git a/deluge/ui/web/common.py b/deluge/ui/web/common.py index 475f335653..a8c223d19e 100644 --- a/deluge/ui/web/common.py +++ b/deluge/ui/web/common.py @@ -7,19 +7,15 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import gettext from mako.template import Template as MakoTemplate -from deluge.common import PY2, get_version +from deluge.common import get_version def _(text): text_local = gettext.gettext(text) - if PY2: - return text_local.decode('utf-8') return text_local diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index ffdee342c1..822f654831 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import division, unicode_literals - import json import logging import os diff --git a/deluge/ui/web/pluginmanager.py b/deluge/ui/web/pluginmanager.py index 24f20ce94a..153d4977a2 100644 --- a/deluge/ui/web/pluginmanager.py +++ b/deluge/ui/web/pluginmanager.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import os diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 2f8921b225..3f079aefb1 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import fnmatch import json import logging diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py index 4d06247918..0cefa13b4c 100644 --- a/deluge/ui/web/web.py +++ b/deluge/ui/web/web.py @@ -7,8 +7,6 @@ # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import logging from twisted.internet.error import CannotListenError diff --git a/docs/source/conf.py b/docs/source/conf.py index f7db27efd9..c04a20452b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,11 +10,11 @@ # All configuration values have a default value; values that are commented out # serve to show the default value. +import builtins import os import sys from datetime import date -from six.moves import builtins from sphinx.ext import apidoc from sphinx.ext.autodoc import ClassDocumenter, bool_option diff --git a/docs/source/devguide/how-to/update-1.3-plugin.md b/docs/source/devguide/how-to/update-1.3-plugin.md index 6374a0c0d2..9c086902bc 100644 --- a/docs/source/devguide/how-to/update-1.3-plugin.md +++ b/docs/source/devguide/how-to/update-1.3-plugin.md @@ -11,7 +11,7 @@ compatible with 2.0 and this guide aims to helps with that process. ### Python version matching -Ensure your code is both Python 2.7 and Python >=3.5 compatible. +Ensure your code is Python >=3.5 compatible. In `1.3-stable` the plugins that were built with a specific version of Python would only be loaded if the system Python also matched. @@ -19,19 +19,6 @@ would only be loaded if the system Python also matched. This has change in Deluge 2.0 and it will load any Python version of plugin eggs so compatibility is essential for end-users not to encounter issues. -### Six - -Use [six] to assist with compatibility. - -[six]: https://pythonhosted.org/six/ - -### Unicode literals - -Add the following to files to ensure strings and bytes separation so there -are no surprises when running on Python 3. - - from __future__ import unicode_literals - ## GTK 3 addition In order to support both Deluge 1.3 and 2.0 all existing plugin GTK UI files diff --git a/gen_web_gettext.py b/gen_web_gettext.py index fac5097366..c299e429f4 100755 --- a/gen_web_gettext.py +++ b/gen_web_gettext.py @@ -10,8 +10,6 @@ """Script to parse javascript files for translation strings and generate gettext.js""" -from __future__ import print_function, unicode_literals - import os import re diff --git a/generate_pot.py b/generate_pot.py index f5cad5b62d..47d3b9f995 100755 --- a/generate_pot.py +++ b/generate_pot.py @@ -11,8 +11,6 @@ """Parses Python and Javascript code for translation strings to create the 'deluge.pot' template for translators""" -from __future__ import print_function, unicode_literals - import os import re from datetime import datetime diff --git a/minify_web_js.py b/minify_web_js.py index a5cd97c593..b91a963293 100755 --- a/minify_web_js.py +++ b/minify_web_js.py @@ -15,19 +15,12 @@ """ -from __future__ import print_function, unicode_literals - import fileinput import fnmatch import os import subprocess import sys - -try: - from shutil import which -except ImportError: - # PY2 Fallback - from distutils.spawn import find_executable as which +from shutil import which closure_cmd = None for cmd in ['closure-compiler', 'closure']: diff --git a/msgfmt.py b/msgfmt.py index c0e093ab61..4d0b83911f 100755 --- a/msgfmt.py +++ b/msgfmt.py @@ -25,8 +25,6 @@ --version Display version information and exit. """ -from __future__ import print_function, unicode_literals - import array import ast import getopt @@ -103,10 +101,7 @@ def generate(): 0, 0, ) # size and offset of hash table - if sys.version_info.major == 2: - output += array.array(b'i', offsets).tostring() - else: - output += array.array('i', offsets).tobytes() + output += array.array('i', offsets).tobytes() output += ids.encode('utf8') output += strs.encode('utf8') return output @@ -181,9 +176,6 @@ def make(filename, outfile): if not line: continue line = ast.literal_eval(line) - # Python 2 ast.literal_eval returns bytes. - if isinstance(line, bytes): - line = line.decode('utf8') if section == section_id: msgid += line elif section == section_str: diff --git a/packaging/source/make_release.py b/packaging/source/make_release.py index e1cee00362..38fc3d566d 100755 --- a/packaging/source/make_release.py +++ b/packaging/source/make_release.py @@ -7,18 +7,11 @@ # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # -from __future__ import print_function, unicode_literals - import os.path -import sys from hashlib import sha256 from subprocess import call, check_output -PY2 = sys.version_info.major == 2 - sdist_formats = 'xztar' -if PY2: - sdist_formats = 'tar' version = check_output(['python', 'version.py']).strip().decode() diff --git a/pyproject.toml b/pyproject.toml index 2674219a74..67ebe0a0c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,5 +9,3 @@ skip-string-normalization = true [tool.isort] profile = "black" -# Python 2 stdlib -extra_standard_library = ["urlparse", "HTMLParser", "urllib2"] diff --git a/requirements.txt b/requirements.txt index c414829b9d..99e646c181 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ pyxdg pillow mako chardet -six setproctitle pywin32; sys_platform == 'win32' certifi; sys_platform == 'win32' diff --git a/setup.py b/setup.py index ef8d38e212..181d74cd80 100755 --- a/setup.py +++ b/setup.py @@ -9,8 +9,6 @@ # See LICENSE for more details. # -from __future__ import print_function - import glob import os import platform @@ -18,7 +16,7 @@ from distutils.command.build import build as _build from distutils.command.clean import clean as _clean from distutils.command.install_data import install_data as _install_data -from shutil import rmtree +from shutil import rmtree, which from setuptools import Command, find_packages, setup from setuptools.command.test import test as _test @@ -26,12 +24,6 @@ import msgfmt from version import get_version -try: - from shutil import which -except ImportError: - # PY2 Fallback - from distutils.spawn import find_executable as which - try: from sphinx.setup_command import BuildDoc except ImportError: @@ -548,7 +540,6 @@ def run(self): 'pyopenssl', 'pyxdg', 'mako', - 'six', 'setuptools', "pywin32; sys_platform == 'win32'", "certifi; sys_platform == 'win32'", @@ -599,7 +590,7 @@ def run(self): 'Operating System :: POSIX', 'Topic :: Internet', ], - python_requires='>=2.7', + python_requires='>=3.5', license='GPLv3+', cmdclass=cmdclass, setup_requires=setup_requires, diff --git a/tox.ini b/tox.ini index 5b91529785..8f6810cd84 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # Usage: `pip install tox` and then run `tox` from this directory. [tox] -envlist = py27, py3, lint, docs +envlist = py3, lint, docs minversion=3.0 [pytest] diff --git a/version.py b/version.py index ff8f684d51..28d071093f 100755 --- a/version.py +++ b/version.py @@ -31,8 +31,6 @@ # include RELEASE-VERSION # -from __future__ import print_function, unicode_literals - import os import subprocess