Remove all Python 2 support
* Removed all __future__ imports from code * Removed all six dependencies * Removed all future_builtins imports * Removed all Python 2 related code Closes: deluge-torrent/deluge#325
This commit is contained in:
parent
ff309ea4c5
commit
897955f0a1
|
@ -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]
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Changelog
|
||||
|
||||
## 2.0.6 (WIP)
|
||||
## 2.1.0 (WIP)
|
||||
|
||||
- Removed Python 2 support.
|
||||
|
||||
## 2.0.5 (2021-12-15)
|
||||
|
||||
|
|
|
@ -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/
|
||||
|
|
|
@ -15,8 +15,6 @@ Example:
|
|||
>>> from deluge._libtorrent import lt
|
||||
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.common import VersionSplit, get_version
|
||||
from deluge.error import LibtorrentImportError
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
|
|
|
@ -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 @@ encode_func[dict] = encode_dict
|
|||
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):
|
||||
|
|
|
@ -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 @@ import time
|
|||
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 @@ try:
|
|||
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 @@ JSON_FORMAT = {'indent': 4, 'sort_keys': True, 'ensure_ascii': False}
|
|||
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.
|
||||
|
||||
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')
|
||||
|
||||
if windows_check():
|
||||
from ctypes import cdll, windll
|
||||
|
@ -1271,30 +1255,7 @@ 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
|
||||
# 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
|
||||
|
|
|
@ -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 @@ class ComponentRegistry(object):
|
|||
# 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 @@ class ComponentRegistry(object):
|
|||
"""
|
||||
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 @@ class ComponentRegistry(object):
|
|||
"""
|
||||
if not names:
|
||||
names = list(self.components)
|
||||
elif isinstance(names, string_types):
|
||||
elif isinstance(names, str):
|
||||
names = [names]
|
||||
|
||||
deferreds = []
|
||||
|
@ -425,7 +422,7 @@ class ComponentRegistry(object):
|
|||
"""
|
||||
if not names:
|
||||
names = list(self.components)
|
||||
elif isinstance(names, string_types):
|
||||
elif isinstance(names, str):
|
||||
names = [names]
|
||||
|
||||
deferreds = []
|
||||
|
|
|
@ -39,18 +39,15 @@ this can only be done for the 'config file version' and not for the 'format'
|
|||
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__)
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
|
|
@ -15,10 +15,8 @@ This should typically only be used by the Core. Plugins should utilize the
|
|||
`: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 @@ from deluge.common import decode_bytes
|
|||
|
||||
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"""
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
|
|
@ -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 shutil
|
|||
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.event import (
|
|||
)
|
||||
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 @@ class Core(component.Component):
|
|||
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 @@ class Core(component.Component):
|
|||
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 @@ class Core(component.Component):
|
|||
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:
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#
|
||||
|
||||
"""The Deluge daemon"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import deluge.component as component
|
||||
|
|
|
@ -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 @@ class FilterManager(component.Component):
|
|||
|
||||
# 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
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
|
||||
"""PluginManager for Core"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from twisted.internet import defer
|
||||
|
|
|
@ -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 @@ try:
|
|||
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 = {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#
|
||||
|
||||
"""RPCServer Module"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -14,11 +14,10 @@ Attributes:
|
|||
|
||||
"""
|
||||
|
||||
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 @@ from deluge.event import (
|
|||
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 = {
|
||||
|
|
|
@ -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 @@ from twisted.internet.task import LoopingCall
|
|||
import deluge.component as component
|
||||
from deluge._libtorrent import LT_VERSION, lt
|
||||
from deluge.common import (
|
||||
PY2,
|
||||
VersionSplit,
|
||||
archive_files,
|
||||
decode_bytes,
|
||||
|
@ -821,9 +818,6 @@ class TorrentManager(component.Component):
|
|||
|
||||
try:
|
||||
with open(filepath, 'rb') as _file:
|
||||
if PY2:
|
||||
state = pickle.load(_file)
|
||||
else:
|
||||
state = pickle.load(_file, encoding='utf8')
|
||||
except (IOError, EOFError, pickle.UnpicklingError) as ex:
|
||||
message = 'Unable to load {}: {}'.format(filepath, ex)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import inspect
|
||||
import re
|
||||
import warnings
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -14,10 +14,6 @@ This module describes the types of events that can be generated by the daemon
|
|||
and subsequently emitted to the clients.
|
||||
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import six
|
||||
|
||||
known_events = {}
|
||||
|
||||
|
||||
|
@ -32,7 +28,7 @@ class DelugeEventMetaClass(type):
|
|||
known_events[name] = cls
|
||||
|
||||
|
||||
class DelugeEvent(six.with_metaclass(DelugeEventMetaClass, object)):
|
||||
class DelugeEvent(metaclass=DelugeEventMetaClass):
|
||||
"""
|
||||
The base class for all events.
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import cgi
|
||||
import logging
|
||||
import os.path
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 os
|
|||
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):
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#
|
||||
|
||||
"""Logging functions"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
import logging.handlers
|
||||
|
@ -102,9 +100,6 @@ class Logging(LoggingLoggerClass):
|
|||
continue
|
||||
rv = (co.co_filename, f.f_lineno, co.co_name, None)
|
||||
break
|
||||
if common.PY2:
|
||||
return rv[:-1]
|
||||
else:
|
||||
return rv
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
|
||||
import os
|
||||
from hashlib import sha1 as sha
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import time
|
||||
|
|
|
@ -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,9 +50,6 @@ 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]
|
||||
except StopIteration:
|
||||
# Invalid dirname
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
|
||||
"""PluginManagerBase"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -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 raises_errors_as(error):
|
|||
return func(self, *args, **kwargs)
|
||||
except Exception:
|
||||
(value, tb) = exc_info()[1:]
|
||||
six.reraise(error, value, tb)
|
||||
raise error(value).with_traceback(tb) from None
|
||||
|
||||
return wrapper
|
||||
|
||||
|
|
|
@ -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 .common import IP, BadIP
|
|||
from .detect import UnknownFormatError, create_reader, detect_compression, detect_format
|
||||
from .readers import ReaderParseError
|
||||
|
||||
try:
|
||||
from urllib.parse import urljoin
|
||||
except ImportError:
|
||||
# PY2 fallback
|
||||
from urlparse import urljoin # pylint: disable=ungrouped-imports
|
||||
|
||||
# TODO: check return values for deferred callbacks
|
||||
# TODO: review class attributes for redundancy
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#
|
||||
# pylint: disable=redefined-builtin
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import bz2
|
||||
import gzip
|
||||
import zipfile
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import gzip
|
||||
import logging
|
||||
import socket
|
||||
|
@ -65,8 +63,5 @@ class PGReader(object):
|
|||
|
||||
return (start, end)
|
||||
|
||||
# Python 2 compatibility
|
||||
next = __next__
|
||||
|
||||
def close(self):
|
||||
self.fd.close()
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import gi # isort:skip (Required before Gtk import).
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import errno
|
||||
import logging
|
||||
import os
|
||||
|
@ -37,10 +35,7 @@ if windows_check():
|
|||
'C:\\Program Files (x86)\\7-Zip\\7z.exe',
|
||||
]
|
||||
|
||||
try:
|
||||
import winreg
|
||||
except ImportError:
|
||||
import _winreg as winreg # For Python 2.
|
||||
|
||||
try:
|
||||
hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\7-Zip')
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import gi # isort:skip (Required before Gtk import).
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
torrent-label core plugin.
|
||||
adds a status field for tracker.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge import component # for systray
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from gi.repository.Gtk import Builder
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import gi # isort:skip (Required before Gtk import).
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from gi.repository.Gtk import Menu, MenuItem
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
|
|
|
@ -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 @@ Date: %(date)s
|
|||
message = '\r\n'.join((headers + message).splitlines())
|
||||
|
||||
try:
|
||||
# Python 2.6
|
||||
server = smtplib.SMTP(
|
||||
self.config['smtp_host'], self.config['smtp_port'], timeout=60
|
||||
)
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
from os.path import basename
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from gi.repository import Gdk, Gtk
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
port of old plugin by markybob.
|
||||
"""
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
|
||||
import logging
|
||||
import math
|
||||
import time
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import deluge.component as component
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import deluge.component as component
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from deluge.plugins.pluginbase import WebPluginBase
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from twisted.internet import defer
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from twisted.trial import unittest
|
||||
|
||||
import deluge.component as component
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import deluge.component as component
|
||||
|
|
|
@ -7,8 +7,6 @@ python create_plugin.py --name MyPlugin2 --basepath . --author-name "Your Name"
|
|||
|
||||
"""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#
|
||||
# Authour: Garett Harnish
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
|
|
@ -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:
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue