B
A[eO - @ s d Z ddlZddlZddlZddlZddlZddlZejd dkZejdd dkZ ejdd dkZ
ejd dkZejdd dkZejdd dkZ
eed Zd
d Zdd
Zerdd Zdd Zdd ZefZefZefZeZeZn8dd Zdd Zdd ZefZeefZeej fZe!ZeZer2dd Z"ndd Z"de"_ erfdzddZ#d{ddZ$d|d d!Z%nd}d"dZ#d~d#dZ$dd%d!Z%d&e#_ erd'd( Z&d)d* Z'd+d, Z(d-d. Z)n ddl*Z*e*j+Z&e*j,Z'e*j-Z(e*j.Z)dd0d1Z/d2d3 Z0d4d5 Z1d6d7 Z2d8d9 Z3d:d; Z4d<d= Z5d>d? Z6d@dA Z7dBdC Z8dDdE Z9erRdFdG Z:ddHdIZ;e<fdJdKZ=ndLdG Z:e>dM? dNe=_ e;Z@dOdP ZAerdQdR ZBndSdR ZBdTdU ZCdVdW ZDeZEeZFdXdY ZGdZd[ ZHd\d] ZId^d_ ZJd`da ZKerddlLZLeMeLdbZNn
ddcddZNdedf ZOddgdhZPy
eQj3 W n& eRk
r6 didj ZSdkdl ZTY nX dmdj ZSdndl ZTerXdodp ZUndqdp ZUdrdsdtdudhd?ddddUdpdddvdAdPdWd[d1d_d]dYd9d;d=d.dldjd,d(d*dadwdxddfddIdKdyd!dd3d5d7d
g-ZVdS )a;
A selection of cross-compatible functions for Python 2 and 3.
This module exports useful functions for 2/3 compatible code:
* bind_method: binds functions to classes
* ``native_str_to_bytes`` and ``bytes_to_native_str``
* ``native_str``: always equal to the native platform string object (because
this may be shadowed by imports from future.builtins)
* lists: lrange(), lmap(), lzip(), lfilter()
* iterable method compatibility:
- iteritems, iterkeys, itervalues
- viewitems, viewkeys, viewvalues
These use the original method if available, otherwise they use items,
keys, values.
* types:
* text_type: unicode in Python 2, str in Python 3
* binary_type: str in Python 2, bytes in Python 3
* string_types: basestring in Python 2, str in Python 3
* bchr(c):
Take an integer and make a 1-character byte string
* bord(c)
Take the result of indexing on a byte string and make an integer
* tobytes(s)
Take a text string, a byte string, or a sequence of characters taken
from a byte string, and make a byte string.
* raise_from()
* raise_with_traceback()
This module also defines these decorators:
* ``python_2_unicode_compatible``
* ``with_metaclass``
* ``implements_iterator``
Some of the functions in this module come from the following sources:
* Jinja2 (BSD licensed: see
https://github.com/mitsuhiko/jinja2/blob/master/LICENSE)
* Pandas compatibility module pandas.compat
* six.py by Benjamin Peterson
* Django
N )r )r )r r )r Zpypy_translation_infoc C s t s| j| _dd | _| S )u
A decorator that defines __unicode__ and __str__ methods under Python
2. Under Python 3, this decorator is a no-op.
To support Python 2 and 3 with a single code base, define a __str__
method returning unicode text and apply this decorator to the class, like
this::
>>> from future.utils import python_2_unicode_compatible
>>> @python_2_unicode_compatible
... class MyClass(object):
... def __str__(self):
... return u'Unicode string: 孔子'
>>> a = MyClass()
Then, after this import:
>>> from future.builtins import str
the following is ``True`` on both Python 3 and 2::
>>> str(a) == a.encode('utf-8').decode('utf-8')
True
and, on a Unicode-enabled terminal with the right fonts, these both print the
Chinese characters for Confucius::
>>> print(a)
>>> print(str(a))
The implementation comes from django.utils.encoding.
c S s | dS )Nzutf-8)__unicode__encode)self r
F/opt/alt/python37/lib/python3.7/site-packages/future/utils/__init__.py<lambda>h z-python_2_unicode_compatible.<locals>.<lambda>)PY3__str__r )clsr
r
r python_2_unicode_compatibleC s #
r c s"