mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 05:13:21 -07:00
Remove Python 2 handling code (#2098)
* Remove Python 2 update modal * Remove Python 2 handling code * Remove backports dependencies * Remove uses of future and __future__ * Fix import * Remove requirements * Update lib folder * Clean up imports and blank lines --------- Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
This commit is contained in:
parent
dcec1f6f5f
commit
de3393d62b
97 changed files with 7443 additions and 2917 deletions
|
@ -52,7 +52,7 @@ Automatic conversion
|
|||
--------------------
|
||||
|
||||
An included script called `futurize
|
||||
<http://python-future.org/automatic_conversion.html>`_ aids in converting
|
||||
<https://python-future.org/automatic_conversion.html>`_ aids in converting
|
||||
code (from either Python 2 or Python 3) to code compatible with both
|
||||
platforms. It is similar to ``python-modernize`` but goes further in
|
||||
providing Python 3 compatibility through the use of the backported types
|
||||
|
@ -62,21 +62,20 @@ and builtin functions in ``future``.
|
|||
Documentation
|
||||
-------------
|
||||
|
||||
See: http://python-future.org
|
||||
See: https://python-future.org
|
||||
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
:Author: Ed Schofield, Jordan M. Adler, et al
|
||||
:Sponsor: Python Charmers Pty Ltd, Australia, and Python Charmers Pte
|
||||
Ltd, Singapore. http://pythoncharmers.com
|
||||
:Others: See docs/credits.rst or http://python-future.org/credits.html
|
||||
:Sponsor: Python Charmers: https://pythoncharmers.com
|
||||
:Others: See docs/credits.rst or https://python-future.org/credits.html
|
||||
|
||||
|
||||
Licensing
|
||||
---------
|
||||
Copyright 2013-2019 Python Charmers Pty Ltd, Australia.
|
||||
Copyright 2013-2024 Python Charmers, Australia.
|
||||
The software is distributed under an MIT licence. See LICENSE.txt.
|
||||
|
||||
"""
|
||||
|
@ -84,10 +83,10 @@ The software is distributed under an MIT licence. See LICENSE.txt.
|
|||
__title__ = 'future'
|
||||
__author__ = 'Ed Schofield'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright 2013-2019 Python Charmers Pty Ltd'
|
||||
__ver_major__ = 0
|
||||
__ver_minor__ = 18
|
||||
__ver_patch__ = 3
|
||||
__copyright__ = 'Copyright 2013-2024 Python Charmers (https://pythoncharmers.com)'
|
||||
__ver_major__ = 1
|
||||
__ver_minor__ = 0
|
||||
__ver_patch__ = 0
|
||||
__ver_sub__ = ''
|
||||
__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__,
|
||||
__ver_patch__, __ver_sub__)
|
||||
|
|
|
@ -689,7 +689,7 @@ class date(object):
|
|||
|
||||
@classmethod
|
||||
def fromordinal(cls, n):
|
||||
"""Contruct a date from a proleptic Gregorian ordinal.
|
||||
"""Construct a date from a proleptic Gregorian ordinal.
|
||||
|
||||
January 1 of year 1 is day 1. Only the year, month and day are
|
||||
non-zero in the result.
|
||||
|
|
|
@ -2867,7 +2867,7 @@ def parse_content_type_header(value):
|
|||
_find_mime_parameters(ctype, value)
|
||||
return ctype
|
||||
ctype.append(token)
|
||||
# XXX: If we really want to follow the formal grammer we should make
|
||||
# XXX: If we really want to follow the formal grammar we should make
|
||||
# mantype and subtype specialized TokenLists here. Probably not worth it.
|
||||
if not value or value[0] != '/':
|
||||
ctype.defects.append(errors.InvalidHeaderDefect(
|
||||
|
|
|
@ -26,7 +26,7 @@ class Parser(object):
|
|||
textual representation of the message.
|
||||
|
||||
The string must be formatted as a block of RFC 2822 headers and header
|
||||
continuation lines, optionally preceeded by a `Unix-from' header. The
|
||||
continuation lines, optionally preceded by a `Unix-from' header. The
|
||||
header block is terminated either by the end of the string or by a
|
||||
blank line.
|
||||
|
||||
|
@ -92,7 +92,7 @@ class BytesParser(object):
|
|||
textual representation of the message.
|
||||
|
||||
The input must be formatted as a block of RFC 2822 headers and header
|
||||
continuation lines, optionally preceeded by a `Unix-from' header. The
|
||||
continuation lines, optionally preceded by a `Unix-from' header. The
|
||||
header block is terminated either by the end of the input or by a
|
||||
blank line.
|
||||
|
||||
|
|
|
@ -1851,7 +1851,7 @@ def lwp_cookie_str(cookie):
|
|||
class LWPCookieJar(FileCookieJar):
|
||||
"""
|
||||
The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
|
||||
"Set-Cookie3" is the format used by the libwww-perl libary, not known
|
||||
"Set-Cookie3" is the format used by the libwww-perl library, not known
|
||||
to be compatible with any browser, but which is easy to read and
|
||||
doesn't lose information about RFC 2965 cookies.
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import importlib
|
|||
# import collections.abc # not present on Py2.7
|
||||
import re
|
||||
import subprocess
|
||||
import imp
|
||||
import time
|
||||
try:
|
||||
import sysconfig
|
||||
|
@ -341,37 +340,6 @@ def rmtree(path):
|
|||
if error.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
def make_legacy_pyc(source):
|
||||
"""Move a PEP 3147 pyc/pyo file to its legacy pyc/pyo location.
|
||||
|
||||
The choice of .pyc or .pyo extension is done based on the __debug__ flag
|
||||
value.
|
||||
|
||||
:param source: The file system path to the source file. The source file
|
||||
does not need to exist, however the PEP 3147 pyc file must exist.
|
||||
:return: The file system path to the legacy pyc file.
|
||||
"""
|
||||
pyc_file = imp.cache_from_source(source)
|
||||
up_one = os.path.dirname(os.path.abspath(source))
|
||||
legacy_pyc = os.path.join(up_one, source + ('c' if __debug__ else 'o'))
|
||||
os.rename(pyc_file, legacy_pyc)
|
||||
return legacy_pyc
|
||||
|
||||
def forget(modname):
|
||||
"""'Forget' a module was ever imported.
|
||||
|
||||
This removes the module from sys.modules and deletes any PEP 3147 or
|
||||
legacy .pyc and .pyo files.
|
||||
"""
|
||||
unload(modname)
|
||||
for dirname in sys.path:
|
||||
source = os.path.join(dirname, modname + '.py')
|
||||
# It doesn't matter if they exist or not, unlink all possible
|
||||
# combinations of PEP 3147 and legacy pyc and pyo files.
|
||||
unlink(source + 'c')
|
||||
unlink(source + 'o')
|
||||
unlink(imp.cache_from_source(source, debug_override=True))
|
||||
unlink(imp.cache_from_source(source, debug_override=False))
|
||||
|
||||
# On some platforms, should not run gui test even if it is allowed
|
||||
# in `use_resources'.
|
||||
|
|
|
@ -134,10 +134,11 @@ from __future__ import (absolute_import, division, print_function,
|
|||
from future.builtins import bytes, dict, int, range, str
|
||||
|
||||
import base64
|
||||
# Py2.7 compatibility hack
|
||||
base64.encodebytes = base64.encodestring
|
||||
base64.decodebytes = base64.decodestring
|
||||
import sys
|
||||
if sys.version_info < (3, 9):
|
||||
# Py2.7 compatibility hack
|
||||
base64.encodebytes = base64.encodestring
|
||||
base64.decodebytes = base64.decodestring
|
||||
import time
|
||||
from datetime import datetime
|
||||
from future.backports.http import client as http_client
|
||||
|
@ -1251,7 +1252,7 @@ class Transport(object):
|
|||
# Send HTTP request.
|
||||
#
|
||||
# @param host Host descriptor (URL or (URL, x509 info) tuple).
|
||||
# @param handler Targer RPC handler (a path relative to host)
|
||||
# @param handler Target RPC handler (a path relative to host)
|
||||
# @param request_body The XML-RPC request body
|
||||
# @param debug Enable debugging if debug is true.
|
||||
# @return An HTTPConnection.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
A module that brings in equivalents of the new and modified Python 3
|
||||
builtins into Py2. Has no effect on Py3.
|
||||
|
||||
See the docs `here <http://python-future.org/what-else.html>`_
|
||||
See the docs `here <https://python-future.org/what-else.html>`_
|
||||
(``docs/what-else.rst``) for more information.
|
||||
|
||||
"""
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
from future.utils import PY3
|
||||
from future.utils import PY3, PY39_PLUS
|
||||
|
||||
if PY3:
|
||||
from _dummy_thread import *
|
||||
|
||||
if PY39_PLUS:
|
||||
# _dummy_thread and dummy_threading modules were both deprecated in
|
||||
# Python 3.7 and removed in Python 3.9
|
||||
from _thread import *
|
||||
elif PY3:
|
||||
from _dummy_thread import *
|
||||
else:
|
||||
__future_module__ = True
|
||||
from dummy_thread import *
|
||||
|
|
7
lib/future/moves/multiprocessing.py
Normal file
7
lib/future/moves/multiprocessing.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
from future.utils import PY3
|
||||
|
||||
from multiprocessing import *
|
||||
if not PY3:
|
||||
__future_module__ = True
|
||||
from multiprocessing.queues import SimpleQueue
|
|
@ -1,9 +1,18 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
|
||||
from future.standard_library import suspend_hooks
|
||||
from future.utils import PY3
|
||||
|
||||
if PY3:
|
||||
from test.support import *
|
||||
if sys.version_info[:2] >= (3, 10):
|
||||
from test.support.os_helper import (
|
||||
EnvironmentVarGuard,
|
||||
TESTFN,
|
||||
)
|
||||
from test.support.warnings_helper import check_warnings
|
||||
else:
|
||||
__future_module__ = True
|
||||
with suspend_hooks():
|
||||
|
|
|
@ -17,7 +17,7 @@ And then these normal Py3 imports work on both Py3 and Py2::
|
|||
import socketserver
|
||||
import winreg # on Windows only
|
||||
import test.support
|
||||
import html, html.parser, html.entites
|
||||
import html, html.parser, html.entities
|
||||
import http, http.client, http.server
|
||||
import http.cookies, http.cookiejar
|
||||
import urllib.parse, urllib.request, urllib.response, urllib.error, urllib.robotparser
|
||||
|
@ -33,6 +33,7 @@ And then these normal Py3 imports work on both Py3 and Py2::
|
|||
from collections import OrderedDict, Counter, ChainMap # even on Py2.6
|
||||
from subprocess import getoutput, getstatusoutput
|
||||
from subprocess import check_output # even on Py2.6
|
||||
from multiprocessing import SimpleQueue
|
||||
|
||||
(The renamed modules and functions are still available under their old
|
||||
names on Python 2.)
|
||||
|
@ -62,9 +63,12 @@ from __future__ import absolute_import, division, print_function
|
|||
|
||||
import sys
|
||||
import logging
|
||||
import imp
|
||||
# imp was deprecated in python 3.6
|
||||
if sys.version_info >= (3, 6):
|
||||
import importlib as imp
|
||||
else:
|
||||
import imp
|
||||
import contextlib
|
||||
import types
|
||||
import copy
|
||||
import os
|
||||
|
||||
|
@ -108,6 +112,7 @@ RENAMES = {
|
|||
'future.moves.socketserver': 'socketserver',
|
||||
'ConfigParser': 'configparser',
|
||||
'repr': 'reprlib',
|
||||
'multiprocessing.queues': 'multiprocessing',
|
||||
# 'FileDialog': 'tkinter.filedialog',
|
||||
# 'tkFileDialog': 'tkinter.filedialog',
|
||||
# 'SimpleDialog': 'tkinter.simpledialog',
|
||||
|
@ -125,7 +130,7 @@ RENAMES = {
|
|||
# 'Tkinter': 'tkinter',
|
||||
'_winreg': 'winreg',
|
||||
'thread': '_thread',
|
||||
'dummy_thread': '_dummy_thread',
|
||||
'dummy_thread': '_dummy_thread' if sys.version_info < (3, 9) else '_thread',
|
||||
# 'anydbm': 'dbm', # causes infinite import loop
|
||||
# 'whichdb': 'dbm', # causes infinite import loop
|
||||
# anydbm and whichdb are handled by fix_imports2
|
||||
|
@ -184,6 +189,7 @@ MOVES = [('collections', 'UserList', 'UserList', 'UserList'),
|
|||
('itertools', 'filterfalse','itertools', 'ifilterfalse'),
|
||||
('itertools', 'zip_longest','itertools', 'izip_longest'),
|
||||
('sys', 'intern','__builtin__', 'intern'),
|
||||
('multiprocessing', 'SimpleQueue', 'multiprocessing.queues', 'SimpleQueue'),
|
||||
# The re module has no ASCII flag in Py2, but this is the default.
|
||||
# Set re.ASCII to a zero constant. stat.ST_MODE just happens to be one
|
||||
# (and it exists on Py2.6+).
|
||||
|
|
|
@ -223,9 +223,11 @@ class newint(with_metaclass(BaseNewInt, long)):
|
|||
|
||||
def __rpow__(self, other):
|
||||
value = super(newint, self).__rpow__(other)
|
||||
if value is NotImplemented:
|
||||
if isint(value):
|
||||
return newint(value)
|
||||
elif value is NotImplemented:
|
||||
return other ** long(self)
|
||||
return newint(value)
|
||||
return value
|
||||
|
||||
def __lshift__(self, other):
|
||||
if not isint(other):
|
||||
|
@ -318,7 +320,7 @@ class newint(with_metaclass(BaseNewInt, long)):
|
|||
bits = length * 8
|
||||
num = (2**bits) + self
|
||||
if num <= 0:
|
||||
raise OverflowError("int too smal to convert")
|
||||
raise OverflowError("int too small to convert")
|
||||
else:
|
||||
if self < 0:
|
||||
raise OverflowError("can't convert negative int to unsigned")
|
||||
|
|
|
@ -105,7 +105,7 @@ class newrange(Sequence):
|
|||
raise ValueError('%r is not in range' % value)
|
||||
|
||||
def count(self, value):
|
||||
"""Return the number of ocurrences of integer `value`
|
||||
"""Return the number of occurrences of integer `value`
|
||||
in the sequence this range represents."""
|
||||
# a value can occur exactly zero or one times
|
||||
return int(value in self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue