| Current Path : /usr/lib/python3/dist-packages/future/utils/__pycache__/ |
| Current File : //usr/lib/python3/dist-packages/future/utils/__pycache__/__init__.cpython-38.pyc |
U
,1�]DU � 2 @ s� d Z ddlZddlZddlZddlZddlZddlZejd dkZejdd� dkZ ejdd� dkZ
ejdd� dkZejd dkZejdd� dkZ
ejdd� d kZeed
�Zdd� Zd
d� Zer�dd� Zdd� Zdd� ZefZefZefZeZeZn8dd� Zdd� Zdd� ZefZee fZeej!fZe"ZeZe�rDdd� Z#ndd� Z#de#_ e�rxd�dd�Z$d�dd �Z%d�d!d"�Z&nd�d#d�Z$d�d$d �Z%d�d&d"�Z&d'e$_ e�r�d(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*d�d1d2�Z0d3d4� Z1d5d6� Z2d7d8� Z3d9d:� Z4d;d<� Z5d=d>� Z6d?d@� Z7dAdB� Z8dCdD� Z9dEdF� Z:e�rddGdH� Z;d�dIdJ�Z<e=fdKdL�Z>ndMdH� Z;e?dN�@� � dOe>_ e<ZAdPdQ� ZBe�r�dRdS� ZCndTdS� ZCdUdV� ZDdWdX� ZEeZFeZGdYdZ� ZHd[d\� ZId]d^� ZJd_d`� ZKdadb� ZLe�r�ddlMZMeNeMdc�ZOn
d�ddde�ZOdfdg� ZPd�dhdi�ZQz
eRj4 W n& eSk
�rH djdk� ZTdldm� ZUY nX dndk� ZTdodm� ZUe�rjdpdq� ZVndrdq� ZVdsdtdudvdidwd@ddd dxdVdqdedydBdQdzdXd\d2d`d^dZd:d<d>d/dmdkd-d)d+dbd{d|ddgddJdLd}d~d"ddd4d6d8dg2ZWdS )�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
* string_types: basestring in Python 2, str in Python 3
* binary_type: str in Python 2, bytes in Python 3
* integer_types: (int, long) in Python 2, int in Python 3
* class_types: (type, types.ClassType) in Python 2, type 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 )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 | � � �d�S �N�utf-8)�__unicode__�encode)�self� r
�7/usr/lib/python3/dist-packages/future/utils/__init__.py�<lambda>k � z-python_2_unicode_compatible.<locals>.<lambda>)�PY3�__str__r
��clsr
r
r �python_2_unicode_compatibleF s #
r c s"