Skip to content

Commit

Permalink
[script.module.future] 0.18.3+matrix.1 (#2548)
Browse files Browse the repository at this point in the history
  • Loading branch information
L2501 authored Dec 2, 2023
1 parent 2ec8098 commit 718c902
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 122 deletions.
11 changes: 4 additions & 7 deletions script.module.future/addon.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.future"
name="future"
version="0.18.2+matrix.1"
provider-name="Ed Schofield">
<addon id="script.module.future" name="future" version="0.18.3+matrix.1" provider-name="Ed Schofield">
<requires>
<import addon="xbmc.python" version="3.0.0" />
</requires>
<extension point="xbmc.python.module" library="lib" />
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">Clean single-source support for Python 3 and 2</summary>
<description lang="en_GB">future is the missing compatibility layer between Python 2 and Python 3. It allows you to use a single, clean Python 3.x-compatible codebase to support both Python 2 and Python 3 with minimal overhead.</description>
<platform>all</platform>
<license>MIT</license>
<platform>all</platform>
<website>https://python-future.org</website>
<source>https://github.com/PythonCharmers/python-future</source>
<website>http://python-future.org</website>
<assets>
<icon>icon.png</icon>
<icon>resources/icon.png</icon>
</assets>
</extension>
</addon>
Binary file removed script.module.future/icon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion script.module.future/lib/future/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
__copyright__ = 'Copyright 2013-2019 Python Charmers Pty Ltd'
__ver_major__ = 0
__ver_minor__ = 18
__ver_patch__ = 2
__ver_patch__ = 3
__ver_sub__ = ''
__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__,
__ver_patch__, __ver_sub__)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from __future__ import absolute_import
from future.builtins import range
from future.builtins import bytes
from future.builtins import str

__all__ = [
'body_decode',
Expand Down
18 changes: 12 additions & 6 deletions script.module.future/lib/future/backports/http/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,14 @@ def _str2time(day, mon, yr, hr, min, sec, tz):
(?::(\d\d))? # optional seconds
)? # optional clock
\s*
([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
(?:
([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
\s*
)?
(?:
\(\w+\) # ASCII representation of timezone in parens.
\s*
(?:\(\w+\))? # ASCII representation of timezone in parens.
\s*$""", re.X | re.ASCII)
)?$""", re.X | re.ASCII)
def http2time(text):
"""Returns time in seconds since epoch of time represented by a string.
Expand Down Expand Up @@ -298,9 +302,11 @@ def http2time(text):
(?::?(\d\d(?:\.\d*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?\d\d?:?(:?\d\d)?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$""", re.X | re. ASCII)
(?:
([-+]?\d\d?:?(:?\d\d)?
|Z|z) # timezone (Z is "zero meridian", i.e. GMT)
\s*
)?$""", re.X | re. ASCII)
def iso2time(text):
"""
As for http2time, but parses the ISO 8601 formats:
Expand Down
14 changes: 14 additions & 0 deletions script.module.future/lib/future/backports/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def ceil(x):

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:
try:
from _thread import get_ident
Expand Down Expand Up @@ -85,6 +95,10 @@ def wrapper(self):
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
################################################################################
Expand Down
25 changes: 14 additions & 11 deletions script.module.future/lib/future/builtins/newround.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
``python-future``: pure Python implementation of Python 3 round().
"""

from __future__ import division
from future.utils import PYPY, PY26, bind_method

# Use the decimal module for simplicity of implementation (and
Expand Down Expand Up @@ -29,28 +30,30 @@ def newround(number, ndigits=None):
if hasattr(number, '__round__'):
return number.__round__(ndigits)

if ndigits < 0:
raise NotImplementedError('negative ndigits not supported yet')
exponent = Decimal('10') ** (-ndigits)

if PYPY:
# Work around issue #24: round() breaks on PyPy with NumPy's types
if 'numpy' in repr(type(number)):
number = float(number)
# 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)):
number = float(number)

if isinstance(number, Decimal):
d = number
else:
if not PY26:
d = Decimal.from_float(number).quantize(exponent,
rounding=ROUND_HALF_EVEN)
d = Decimal.from_float(number)
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:
return int(d)
return int(result)
else:
return float(d)
return float(result)


### From Python 2.7's decimal.py. Only needed to support Py2.6:
Expand Down
71 changes: 35 additions & 36 deletions script.module.future/lib/future/builtins/newsuper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,51 +60,50 @@ def newsuper(typ=_SENTINEL, type_or_obj=_SENTINEL, framedepth=1):
raise RuntimeError('super() used in a function with no args')

try:
# Get the MRO so we can crawl it.
mro = type_or_obj.__mro__
except (AttributeError, RuntimeError): # see issue #160
typ = find_owner(type_or_obj, f.f_code)
except (AttributeError, RuntimeError, TypeError):
# see issues #160, #267
try:
mro = type_or_obj.__class__.__mro__
typ = find_owner(type_or_obj.__class__, f.f_code)
except AttributeError:
raise RuntimeError('super() used with a non-newstyle class')

# A ``for...else`` block? Yes! It's odd, but useful.
# If unfamiliar with for...else, see:
#
# http://psung.blogspot.com/2007/12/for-else-in-python.html
for typ in mro:
# Find the class that owns the currently-executing method.
for meth in typ.__dict__.values():
# Drill down through any wrappers to the underlying func.
# This handles e.g. classmethod() and staticmethod().
try:
while not isinstance(meth,FunctionType):
if isinstance(meth, property):
# Calling __get__ on the property will invoke
# user code which might throw exceptions or have
# side effects
meth = meth.fget
else:
try:
meth = meth.__func__
except AttributeError:
meth = meth.__get__(type_or_obj, typ)
except (AttributeError, TypeError):
continue
if meth.func_code is f.f_code:
break # Aha! Found you.
else:
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')
raise RuntimeError('super() used with an old-style class')
except TypeError:
raise RuntimeError('super() called outside a method')

# Dispatch to builtin super().
if type_or_obj is not _SENTINEL:
return _builtin_super(typ, type_or_obj)
return _builtin_super(typ)


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():
# Drill down through any wrappers to the underlying func.
# This handles e.g. classmethod() and staticmethod().
try:
while not isinstance(meth,FunctionType):
if isinstance(meth, property):
# Calling __get__ on the property will invoke
# user code which might throw exceptions or have
# side effects
meth = meth.fget
else:
try:
meth = meth.__func__
except AttributeError:
meth = meth.__get__(cls, typ)
except (AttributeError, TypeError):
continue
if meth.func_code is code:
return typ # Aha! Found you.
# Not found! Move onto the next class in MRO.

raise TypeError


def superm(*args, **kwds):
f = sys._getframe(1)
nm = f.f_code.co_name
Expand Down
6 changes: 6 additions & 0 deletions script.module.future/lib/future/moves/tkinter/filedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
except ImportError:
raise ImportError('The FileDialog module is missing. Does your Py2 '
'installation include tkinter?')

try:
from tkFileDialog import *
except ImportError:
raise ImportError('The tkFileDialog module is missing. Does your Py2 '
'installation include tkinter?')
63 changes: 14 additions & 49 deletions script.module.future/lib/future/types/newdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


_builtin_dict = dict
ver = sys.version_info[:2]
ver = sys.version_info


class BaseNewDict(type):
Expand All @@ -38,47 +38,18 @@ class newdict(with_metaclass(BaseNewDict, _builtin_dict)):
"""
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):
"""
On Python 2.7+:
D.keys() -> a set-like object providing a view on D's keys
On Python 2.6:
D.keys() -> an iterator over D's keys
"""
if ver == (2, 7):
return self.viewkeys()
elif ver == (2, 6):
return self.iterkeys()
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()

if ver >= (3,):
# Inherit items, keys and values from `dict` in 3.x
pass
elif ver >= (2, 7):
items = dict.viewitems
keys = dict.viewkeys
values = dict.viewvalues
else:
items = dict.iteritems
keys = dict.iterkeys
values = dict.itervalues

def __new__(cls, *args, **kwargs):
"""
Expand All @@ -93,13 +64,7 @@ def __new__(cls, *args, **kwargs):
in the keyword argument list. For example: dict(one=1, two=2)
"""

if len(args) == 0:
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)
return super(newdict, cls).__new__(cls, *args)

def __native__(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions script.module.future/lib/future/types/newint.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ def __bool__(self):
"""
So subclasses can override this, Py3-style
"""
if PY3:
return super(newint, self).__bool__()

return super(newint, self).__nonzero__()

def __native__(self):
Expand Down
2 changes: 1 addition & 1 deletion script.module.future/lib/future/types/newrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __eq__(self, other):
return (isinstance(other, newrange) and
(self._len == 0 == other._len or
(self._start, self._step, self._len) ==
(other._start, other._step, self._len)))
(other._start, other._step, other._len)))

def __len__(self):
return self._len
Expand Down
7 changes: 5 additions & 2 deletions script.module.future/lib/future/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
PY34_PLUS = sys.version_info[0:2] >= (3, 4)
PY35_PLUS = sys.version_info[0:2] >= (3, 5)
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
PY26 = sys.version_info[0:2] == (2, 6)
PY27 = sys.version_info[0:2] == (2, 7)
Expand Down Expand Up @@ -527,9 +530,9 @@ def __next__(self):
return cls

if PY3:
get_next = lambda x: x.next
else:
get_next = lambda x: x.__next__
else:
get_next = lambda x: x.next


def encode_filename(filename):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ def match(self, node):
else:
children.append(child.clone())
if matched:
return Node(node.type, children, fixers_applied=node.fixers_applied)
# 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)
else:
return Node(node.type, children)

return False

Expand Down
Loading

0 comments on commit 718c902

Please sign in to comment.