mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-30 03:28:31 -07:00
Bump future from 0.18.2 to 0.18.3 (#1970)
* Bump future from 0.18.2 to 0.18.3 Bumps [future](https://github.com/PythonCharmers/python-future) from 0.18.2 to 0.18.3. - [Release notes](https://github.com/PythonCharmers/python-future/releases) - [Changelog](https://github.com/PythonCharmers/python-future/blob/master/docs/changelog.rst) - [Commits](https://github.com/PythonCharmers/python-future/compare/v0.18.2...v0.18.3) --- updated-dependencies: - dependency-name: future dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Update future==0.18.3 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
cc78f17be5
commit
9f727d0086
18 changed files with 196 additions and 115 deletions
|
@ -87,7 +87,7 @@ __license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright 2013-2019 Python Charmers Pty Ltd'
|
__copyright__ = 'Copyright 2013-2019 Python Charmers Pty Ltd'
|
||||||
__ver_major__ = 0
|
__ver_major__ = 0
|
||||||
__ver_minor__ = 18
|
__ver_minor__ = 18
|
||||||
__ver_patch__ = 2
|
__ver_patch__ = 3
|
||||||
__ver_sub__ = ''
|
__ver_sub__ = ''
|
||||||
__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__,
|
__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__,
|
||||||
__ver_patch__, __ver_sub__)
|
__ver_patch__, __ver_sub__)
|
||||||
|
|
|
@ -28,6 +28,7 @@ from __future__ import division
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from future.builtins import range
|
from future.builtins import range
|
||||||
from future.builtins import bytes
|
from future.builtins import bytes
|
||||||
|
from future.builtins import str
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'body_decode',
|
'body_decode',
|
||||||
|
|
|
@ -225,10 +225,14 @@ LOOSE_HTTP_DATE_RE = re.compile(
|
||||||
(?::(\d\d))? # optional seconds
|
(?::(\d\d))? # optional seconds
|
||||||
)? # optional clock
|
)? # optional clock
|
||||||
\s*
|
\s*
|
||||||
([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
|
(?:
|
||||||
|
([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
|
||||||
\s*
|
\s*
|
||||||
(?:\(\w+\))? # ASCII representation of timezone in parens.
|
)?
|
||||||
\s*$""", re.X | re.ASCII)
|
(?:
|
||||||
|
\(\w+\) # ASCII representation of timezone in parens.
|
||||||
|
\s*
|
||||||
|
)?$""", re.X | re.ASCII)
|
||||||
def http2time(text):
|
def http2time(text):
|
||||||
"""Returns time in seconds since epoch of time represented by a string.
|
"""Returns time in seconds since epoch of time represented by a string.
|
||||||
|
|
||||||
|
@ -298,9 +302,11 @@ ISO_DATE_RE = re.compile(
|
||||||
(?::?(\d\d(?:\.\d*)?))? # optional seconds (and fractional)
|
(?::?(\d\d(?:\.\d*)?))? # optional seconds (and fractional)
|
||||||
)? # optional clock
|
)? # optional clock
|
||||||
\s*
|
\s*
|
||||||
|
(?:
|
||||||
([-+]?\d\d?:?(:?\d\d)?
|
([-+]?\d\d?:?(:?\d\d)?
|
||||||
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
|
|Z|z) # timezone (Z is "zero meridian", i.e. GMT)
|
||||||
\s*$""", re.X | re. ASCII)
|
\s*
|
||||||
|
)?$""", re.X | re. ASCII)
|
||||||
def iso2time(text):
|
def iso2time(text):
|
||||||
"""
|
"""
|
||||||
As for http2time, but parses the ISO 8601 formats:
|
As for http2time, but parses the ISO 8601 formats:
|
||||||
|
|
|
@ -46,6 +46,16 @@ def ceil(x):
|
||||||
|
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
|
|
||||||
|
if PY26:
|
||||||
|
# itertools.count in Py 2.6 doesn't accept a step parameter
|
||||||
|
def count(start=0, step=1):
|
||||||
|
while True:
|
||||||
|
yield start
|
||||||
|
start += step
|
||||||
|
else:
|
||||||
|
from itertools import count
|
||||||
|
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
try:
|
try:
|
||||||
from _thread import get_ident
|
from _thread import get_ident
|
||||||
|
@ -85,6 +95,10 @@ def recursive_repr(fillvalue='...'):
|
||||||
return decorating_function
|
return decorating_function
|
||||||
|
|
||||||
|
|
||||||
|
# OrderedDict Shim from Raymond Hettinger, python core dev
|
||||||
|
# http://code.activestate.com/recipes/576693-ordered-dictionary-for-py24/
|
||||||
|
# here to support version 2.6.
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
### OrderedDict
|
### OrderedDict
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
``python-future``: pure Python implementation of Python 3 round().
|
``python-future``: pure Python implementation of Python 3 round().
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
from future.utils import PYPY, PY26, bind_method
|
from future.utils import PYPY, PY26, bind_method
|
||||||
|
|
||||||
# Use the decimal module for simplicity of implementation (and
|
# Use the decimal module for simplicity of implementation (and
|
||||||
|
@ -29,12 +30,10 @@ def newround(number, ndigits=None):
|
||||||
if hasattr(number, '__round__'):
|
if hasattr(number, '__round__'):
|
||||||
return number.__round__(ndigits)
|
return number.__round__(ndigits)
|
||||||
|
|
||||||
if ndigits < 0:
|
|
||||||
raise NotImplementedError('negative ndigits not supported yet')
|
|
||||||
exponent = Decimal('10') ** (-ndigits)
|
exponent = Decimal('10') ** (-ndigits)
|
||||||
|
|
||||||
if PYPY:
|
|
||||||
# Work around issue #24: round() breaks on PyPy with NumPy's types
|
# Work around issue #24: round() breaks on PyPy with NumPy's types
|
||||||
|
# Also breaks on CPython with NumPy's specialized int types like uint64
|
||||||
if 'numpy' in repr(type(number)):
|
if 'numpy' in repr(type(number)):
|
||||||
number = float(number)
|
number = float(number)
|
||||||
|
|
||||||
|
@ -42,15 +41,19 @@ def newround(number, ndigits=None):
|
||||||
d = number
|
d = number
|
||||||
else:
|
else:
|
||||||
if not PY26:
|
if not PY26:
|
||||||
d = Decimal.from_float(number).quantize(exponent,
|
d = Decimal.from_float(number)
|
||||||
rounding=ROUND_HALF_EVEN)
|
|
||||||
else:
|
else:
|
||||||
d = from_float_26(number).quantize(exponent, rounding=ROUND_HALF_EVEN)
|
d = from_float_26(number)
|
||||||
|
|
||||||
|
if ndigits < 0:
|
||||||
|
result = newround(d / exponent) * exponent
|
||||||
|
else:
|
||||||
|
result = d.quantize(exponent, rounding=ROUND_HALF_EVEN)
|
||||||
|
|
||||||
if return_int:
|
if return_int:
|
||||||
return int(d)
|
return int(result)
|
||||||
else:
|
else:
|
||||||
return float(d)
|
return float(result)
|
||||||
|
|
||||||
|
|
||||||
### From Python 2.7's decimal.py. Only needed to support Py2.6:
|
### From Python 2.7's decimal.py. Only needed to support Py2.6:
|
||||||
|
|
|
@ -60,20 +60,26 @@ def newsuper(typ=_SENTINEL, type_or_obj=_SENTINEL, framedepth=1):
|
||||||
raise RuntimeError('super() used in a function with no args')
|
raise RuntimeError('super() used in a function with no args')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Get the MRO so we can crawl it.
|
typ = find_owner(type_or_obj, f.f_code)
|
||||||
mro = type_or_obj.__mro__
|
except (AttributeError, RuntimeError, TypeError):
|
||||||
except (AttributeError, RuntimeError): # see issue #160
|
# see issues #160, #267
|
||||||
try:
|
try:
|
||||||
mro = type_or_obj.__class__.__mro__
|
typ = find_owner(type_or_obj.__class__, f.f_code)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise RuntimeError('super() used with a non-newstyle class')
|
raise RuntimeError('super() used with an old-style class')
|
||||||
|
except TypeError:
|
||||||
|
raise RuntimeError('super() called outside a method')
|
||||||
|
|
||||||
# A ``for...else`` block? Yes! It's odd, but useful.
|
# Dispatch to builtin super().
|
||||||
# If unfamiliar with for...else, see:
|
if type_or_obj is not _SENTINEL:
|
||||||
#
|
return _builtin_super(typ, type_or_obj)
|
||||||
# http://psung.blogspot.com/2007/12/for-else-in-python.html
|
return _builtin_super(typ)
|
||||||
for typ in mro:
|
|
||||||
# Find the class that owns the currently-executing method.
|
|
||||||
|
def find_owner(cls, code):
|
||||||
|
'''Find the class that owns the currently-executing method.
|
||||||
|
'''
|
||||||
|
for typ in cls.__mro__:
|
||||||
for meth in typ.__dict__.values():
|
for meth in typ.__dict__.values():
|
||||||
# Drill down through any wrappers to the underlying func.
|
# Drill down through any wrappers to the underlying func.
|
||||||
# This handles e.g. classmethod() and staticmethod().
|
# This handles e.g. classmethod() and staticmethod().
|
||||||
|
@ -88,21 +94,14 @@ def newsuper(typ=_SENTINEL, type_or_obj=_SENTINEL, framedepth=1):
|
||||||
try:
|
try:
|
||||||
meth = meth.__func__
|
meth = meth.__func__
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
meth = meth.__get__(type_or_obj, typ)
|
meth = meth.__get__(cls, typ)
|
||||||
except (AttributeError, TypeError):
|
except (AttributeError, TypeError):
|
||||||
continue
|
continue
|
||||||
if meth.func_code is f.f_code:
|
if meth.func_code is code:
|
||||||
break # Aha! Found you.
|
return typ # Aha! Found you.
|
||||||
else:
|
# Not found! Move onto the next class in MRO.
|
||||||
continue # Not found! Move onto the next class in MRO.
|
|
||||||
break # Found! Break out of the search loop.
|
|
||||||
else:
|
|
||||||
raise RuntimeError('super() called outside a method')
|
|
||||||
|
|
||||||
# Dispatch to builtin super().
|
raise TypeError
|
||||||
if type_or_obj is not _SENTINEL:
|
|
||||||
return _builtin_super(typ, type_or_obj)
|
|
||||||
return _builtin_super(typ)
|
|
||||||
|
|
||||||
|
|
||||||
def superm(*args, **kwds):
|
def superm(*args, **kwds):
|
||||||
|
|
|
@ -10,3 +10,9 @@ else:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError('The FileDialog module is missing. Does your Py2 '
|
raise ImportError('The FileDialog module is missing. Does your Py2 '
|
||||||
'installation include tkinter?')
|
'installation include tkinter?')
|
||||||
|
|
||||||
|
try:
|
||||||
|
from tkFileDialog import *
|
||||||
|
except ImportError:
|
||||||
|
raise ImportError('The tkFileDialog module is missing. Does your Py2 '
|
||||||
|
'installation include tkinter?')
|
||||||
|
|
|
@ -23,7 +23,7 @@ from future.types.newobject import newobject
|
||||||
|
|
||||||
|
|
||||||
_builtin_dict = dict
|
_builtin_dict = dict
|
||||||
ver = sys.version_info[:2]
|
ver = sys.version_info
|
||||||
|
|
||||||
|
|
||||||
class BaseNewDict(type):
|
class BaseNewDict(type):
|
||||||
|
@ -38,47 +38,18 @@ class newdict(with_metaclass(BaseNewDict, _builtin_dict)):
|
||||||
"""
|
"""
|
||||||
A backport of the Python 3 dict object to Py2
|
A backport of the Python 3 dict object to Py2
|
||||||
"""
|
"""
|
||||||
def items(self):
|
|
||||||
"""
|
|
||||||
On Python 2.7+:
|
|
||||||
D.items() -> a set-like object providing a view on D's items
|
|
||||||
On Python 2.6:
|
|
||||||
D.items() -> an iterator over D's items
|
|
||||||
"""
|
|
||||||
if ver == (2, 7):
|
|
||||||
return self.viewitems()
|
|
||||||
elif ver == (2, 6):
|
|
||||||
return self.iteritems()
|
|
||||||
elif ver >= (3, 0):
|
|
||||||
return self.items()
|
|
||||||
|
|
||||||
def keys(self):
|
if ver >= (3,):
|
||||||
"""
|
# Inherit items, keys and values from `dict` in 3.x
|
||||||
On Python 2.7+:
|
pass
|
||||||
D.keys() -> a set-like object providing a view on D's keys
|
elif ver >= (2, 7):
|
||||||
On Python 2.6:
|
items = dict.viewitems
|
||||||
D.keys() -> an iterator over D's keys
|
keys = dict.viewkeys
|
||||||
"""
|
values = dict.viewvalues
|
||||||
if ver == (2, 7):
|
else:
|
||||||
return self.viewkeys()
|
items = dict.iteritems
|
||||||
elif ver == (2, 6):
|
keys = dict.iterkeys
|
||||||
return self.iterkeys()
|
values = dict.itervalues
|
||||||
elif ver >= (3, 0):
|
|
||||||
return self.keys()
|
|
||||||
|
|
||||||
def values(self):
|
|
||||||
"""
|
|
||||||
On Python 2.7+:
|
|
||||||
D.values() -> a set-like object providing a view on D's values
|
|
||||||
On Python 2.6:
|
|
||||||
D.values() -> an iterator over D's values
|
|
||||||
"""
|
|
||||||
if ver == (2, 7):
|
|
||||||
return self.viewvalues()
|
|
||||||
elif ver == (2, 6):
|
|
||||||
return self.itervalues()
|
|
||||||
elif ver >= (3, 0):
|
|
||||||
return self.values()
|
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -93,13 +64,7 @@ class newdict(with_metaclass(BaseNewDict, _builtin_dict)):
|
||||||
in the keyword argument list. For example: dict(one=1, two=2)
|
in the keyword argument list. For example: dict(one=1, two=2)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(args) == 0:
|
return super(newdict, cls).__new__(cls, *args)
|
||||||
return super(newdict, cls).__new__(cls)
|
|
||||||
elif type(args[0]) == newdict:
|
|
||||||
value = args[0]
|
|
||||||
else:
|
|
||||||
value = args[0]
|
|
||||||
return super(newdict, cls).__new__(cls, value)
|
|
||||||
|
|
||||||
def __native__(self):
|
def __native__(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -284,6 +284,9 @@ class newint(with_metaclass(BaseNewInt, long)):
|
||||||
"""
|
"""
|
||||||
So subclasses can override this, Py3-style
|
So subclasses can override this, Py3-style
|
||||||
"""
|
"""
|
||||||
|
if PY3:
|
||||||
|
return super(newint, self).__bool__()
|
||||||
|
|
||||||
return super(newint, self).__nonzero__()
|
return super(newint, self).__nonzero__()
|
||||||
|
|
||||||
def __native__(self):
|
def __native__(self):
|
||||||
|
|
|
@ -87,7 +87,7 @@ class newrange(Sequence):
|
||||||
return (isinstance(other, newrange) and
|
return (isinstance(other, newrange) and
|
||||||
(self._len == 0 == other._len or
|
(self._len == 0 == other._len or
|
||||||
(self._start, self._step, self._len) ==
|
(self._start, self._step, self._len) ==
|
||||||
(other._start, other._step, self._len)))
|
(other._start, other._step, other._len)))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return self._len
|
return self._len
|
||||||
|
|
|
@ -61,6 +61,9 @@ PY3 = sys.version_info[0] >= 3
|
||||||
PY34_PLUS = sys.version_info[0:2] >= (3, 4)
|
PY34_PLUS = sys.version_info[0:2] >= (3, 4)
|
||||||
PY35_PLUS = sys.version_info[0:2] >= (3, 5)
|
PY35_PLUS = sys.version_info[0:2] >= (3, 5)
|
||||||
PY36_PLUS = sys.version_info[0:2] >= (3, 6)
|
PY36_PLUS = sys.version_info[0:2] >= (3, 6)
|
||||||
|
PY37_PLUS = sys.version_info[0:2] >= (3, 7)
|
||||||
|
PY38_PLUS = sys.version_info[0:2] >= (3, 8)
|
||||||
|
PY39_PLUS = sys.version_info[0:2] >= (3, 9)
|
||||||
PY2 = sys.version_info[0] == 2
|
PY2 = sys.version_info[0] == 2
|
||||||
PY26 = sys.version_info[0:2] == (2, 6)
|
PY26 = sys.version_info[0:2] == (2, 6)
|
||||||
PY27 = sys.version_info[0:2] == (2, 7)
|
PY27 = sys.version_info[0:2] == (2, 7)
|
||||||
|
@ -527,9 +530,9 @@ def implements_iterator(cls):
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
get_next = lambda x: x.next
|
|
||||||
else:
|
|
||||||
get_next = lambda x: x.__next__
|
get_next = lambda x: x.__next__
|
||||||
|
else:
|
||||||
|
get_next = lambda x: x.next
|
||||||
|
|
||||||
|
|
||||||
def encode_filename(filename):
|
def encode_filename(filename):
|
||||||
|
|
|
@ -92,7 +92,12 @@ class FixDivisionSafe(fixer_base.BaseFix):
|
||||||
else:
|
else:
|
||||||
children.append(child.clone())
|
children.append(child.clone())
|
||||||
if matched:
|
if matched:
|
||||||
|
# In Python 2.6, `Node` does not have the fixers_applied attribute
|
||||||
|
# https://github.com/python/cpython/blob/8493c0cd66cfc181ac1517268a74f077e9998701/Lib/lib2to3/pytree.py#L235
|
||||||
|
if hasattr(Node, "fixers_applied"):
|
||||||
return Node(node.type, children, fixers_applied=node.fixers_applied)
|
return Node(node.type, children, fixers_applied=node.fixers_applied)
|
||||||
|
else:
|
||||||
|
return Node(node.type, children)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,16 @@ class FixPrint(fixer_base.BaseFix):
|
||||||
if args and args[-1] == Comma():
|
if args and args[-1] == Comma():
|
||||||
args = args[:-1]
|
args = args[:-1]
|
||||||
end = " "
|
end = " "
|
||||||
|
|
||||||
|
# try to determine if the string ends in a non-space whitespace character, in which
|
||||||
|
# case there should be no space at the end of the conversion
|
||||||
|
string_leaves = [leaf for leaf in args[-1].leaves() if leaf.type == token.STRING]
|
||||||
|
if (
|
||||||
|
string_leaves
|
||||||
|
and string_leaves[-1].value[0] != "r" # "raw" string
|
||||||
|
and string_leaves[-1].value[-3:-1] in (r"\t", r"\n", r"\r")
|
||||||
|
):
|
||||||
|
end = ""
|
||||||
if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, u">>"):
|
if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, u">>"):
|
||||||
assert len(args) >= 2
|
assert len(args) >= 2
|
||||||
file = args[1].clone()
|
file = args[1].clone()
|
||||||
|
|
|
@ -94,7 +94,7 @@ class FixRaise(fixer_base.BaseFix):
|
||||||
args = [exc, Comma(), val]
|
args = [exc, Comma(), val]
|
||||||
if tb is not None:
|
if tb is not None:
|
||||||
args += [Comma(), tb]
|
args += [Comma(), tb]
|
||||||
return Call(Name(u"raise_"), args)
|
return Call(Name(u"raise_"), args, prefix=node.prefix)
|
||||||
|
|
||||||
if tb is not None:
|
if tb is not None:
|
||||||
tb.prefix = ""
|
tb.prefix = ""
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
import math
|
||||||
|
import numbers
|
||||||
|
|
||||||
from future.utils import PY2, PY3, exec_
|
from future.utils import PY2, PY3, exec_
|
||||||
|
|
||||||
|
@ -29,8 +31,67 @@ if PY3:
|
||||||
cmp(x, y) -> integer
|
cmp(x, y) -> integer
|
||||||
|
|
||||||
Return negative if x<y, zero if x==y, positive if x>y.
|
Return negative if x<y, zero if x==y, positive if x>y.
|
||||||
|
Python2 had looser comparison allowing cmp None and non Numerical types and collections.
|
||||||
|
Try to match the old behavior
|
||||||
"""
|
"""
|
||||||
|
if isinstance(x, set) and isinstance(y, set):
|
||||||
|
raise TypeError('cannot compare sets using cmp()',)
|
||||||
|
try:
|
||||||
|
if isinstance(x, numbers.Number) and math.isnan(x):
|
||||||
|
if not isinstance(y, numbers.Number):
|
||||||
|
raise TypeError('cannot compare float("nan"), {type_y} with cmp'.format(type_y=type(y)))
|
||||||
|
if isinstance(y, int):
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return -1
|
||||||
|
if isinstance(y, numbers.Number) and math.isnan(y):
|
||||||
|
if not isinstance(x, numbers.Number):
|
||||||
|
raise TypeError('cannot compare {type_x}, float("nan") with cmp'.format(type_x=type(x)))
|
||||||
|
if isinstance(x, int):
|
||||||
|
return -1
|
||||||
|
else:
|
||||||
|
return 1
|
||||||
return (x > y) - (x < y)
|
return (x > y) - (x < y)
|
||||||
|
except TypeError:
|
||||||
|
if x == y:
|
||||||
|
return 0
|
||||||
|
type_order = [
|
||||||
|
type(None),
|
||||||
|
numbers.Number,
|
||||||
|
dict, list,
|
||||||
|
set,
|
||||||
|
(str, bytes),
|
||||||
|
]
|
||||||
|
x_type_index = y_type_index = None
|
||||||
|
for i, type_match in enumerate(type_order):
|
||||||
|
if isinstance(x, type_match):
|
||||||
|
x_type_index = i
|
||||||
|
if isinstance(y, type_match):
|
||||||
|
y_type_index = i
|
||||||
|
if cmp(x_type_index, y_type_index) == 0:
|
||||||
|
if isinstance(x, bytes) and isinstance(y, str):
|
||||||
|
return cmp(x.decode('ascii'), y)
|
||||||
|
if isinstance(y, bytes) and isinstance(x, str):
|
||||||
|
return cmp(x, y.decode('ascii'))
|
||||||
|
elif isinstance(x, list):
|
||||||
|
# if both arguments are lists take the comparison of the first non equal value
|
||||||
|
for x_elem, y_elem in zip(x, y):
|
||||||
|
elem_cmp_val = cmp(x_elem, y_elem)
|
||||||
|
if elem_cmp_val != 0:
|
||||||
|
return elem_cmp_val
|
||||||
|
# if all elements are equal, return equal/0
|
||||||
|
return 0
|
||||||
|
elif isinstance(x, dict):
|
||||||
|
if len(x) != len(y):
|
||||||
|
return cmp(len(x), len(y))
|
||||||
|
else:
|
||||||
|
x_key = min(a for a in x if a not in y or x[a] != y[a])
|
||||||
|
y_key = min(b for b in y if b not in x or x[b] != y[b])
|
||||||
|
if x_key != y_key:
|
||||||
|
return cmp(x_key, y_key)
|
||||||
|
else:
|
||||||
|
return cmp(x[x_key], y[y_key])
|
||||||
|
return cmp(x_type_index, y_type_index)
|
||||||
|
|
||||||
from sys import intern
|
from sys import intern
|
||||||
|
|
||||||
|
@ -42,7 +103,13 @@ if PY3:
|
||||||
return '0' + builtins.oct(number)[2:]
|
return '0' + builtins.oct(number)[2:]
|
||||||
|
|
||||||
raw_input = input
|
raw_input = input
|
||||||
|
|
||||||
|
try:
|
||||||
|
from importlib import reload
|
||||||
|
except ImportError:
|
||||||
|
# for python2, python3 <= 3.4
|
||||||
from imp import reload
|
from imp import reload
|
||||||
|
|
||||||
unicode = str
|
unicode = str
|
||||||
unichr = chr
|
unichr = chr
|
||||||
xrange = range
|
xrange = range
|
||||||
|
|
|
@ -25,9 +25,8 @@ class BaseBaseString(type):
|
||||||
def __instancecheck__(cls, instance):
|
def __instancecheck__(cls, instance):
|
||||||
return isinstance(instance, (bytes, str))
|
return isinstance(instance, (bytes, str))
|
||||||
|
|
||||||
def __subclasshook__(cls, thing):
|
def __subclasscheck__(cls, subclass):
|
||||||
# TODO: What should go here?
|
return super(BaseBaseString, cls).__subclasscheck__(subclass) or issubclass(subclass, (bytes, str))
|
||||||
raise NotImplemented
|
|
||||||
|
|
||||||
|
|
||||||
class basestring(with_metaclass(BaseBaseString)):
|
class basestring(with_metaclass(BaseBaseString)):
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BaseOldStr(type):
|
||||||
|
|
||||||
|
|
||||||
def unescape(s):
|
def unescape(s):
|
||||||
"""
|
r"""
|
||||||
Interprets strings with escape sequences
|
Interprets strings with escape sequences
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
|
@ -13,7 +13,7 @@ cloudinary==1.30.0
|
||||||
distro==1.8.0
|
distro==1.8.0
|
||||||
dnspython==2.2.1
|
dnspython==2.2.1
|
||||||
facebook-sdk==3.1.0
|
facebook-sdk==3.1.0
|
||||||
future==0.18.2
|
future==0.18.3
|
||||||
ga4mp==2.0.4
|
ga4mp==2.0.4
|
||||||
gntp==1.0.3
|
gntp==1.0.3
|
||||||
html5lib==1.1
|
html5lib==1.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue