File: //usr/local/lib/python3.9/site-packages/future/utils/__pycache__/__init__.cpython-39.pyc
a
��?h�U � @ s� d Z ddlZddlZddlZddlZddlZddlZejd dkZejdd� dkZ ejdd� dkZ
ejdd� dkZejdd� dkZejdd� d kZ
ejdd� d
kZejd dkZejdd� dkZejdd� dkZeed
�Zdd� Zdd� Ze�r4dd� Zdd� Zdd� ZefZefZefZeZe Z!n8dd� Zdd� Zdd� Ze"fZee#fZeej$fZe%ZeZ!e�r|dd� Z&ndd� Z&de&_ e�r�dwd d!�Z'dxd"d#�Z(dyd$d%�Z)ndzd&d!�Z'd{d'd#�Z(d|d)d%�Z)d*e'_ e�r�d+d,� Z*d-d.� Z+d/d0� Z,d1d2� Z-n ddl.Z.e.j/Z*e.j0Z+e.j1Z,e.j2Z-d}d4d5�Z3d6d7� Z4d8d9� Z5d:d;� Z6d<d=� Z7d>d?� Z8d@dA� Z9dBdC� Z:dDdE� Z;dFdG� Z<dHdI� Z=e�r�dJdK� Z>d~dLdM�Z?e@fdNdO�ZAndPdK� Z>eBdQ�C� � dReA_ e?ZDdSdT� ZEe�r�dUdV� ZFndWdV� ZFdXdY� ZGdZd[� ZHeZIe ZJd\d]� ZKd^d_� ZLd`da� ZMdbdc� ZNddde� ZOe�r4ddlPZPeQePdf�ZRn
ddgdh�ZRdidj� ZSd�dkdl�ZTz
eUj7 W n$ eV�y~ dmdn� ZWdodp� ZXY n0 dqdn� ZWdrdp� ZXe�r�dsdt� ZYndudt� ZYg dv�ZZdS )�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 � )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 �?/usr/local/lib/python3.9/site-packages/future/utils/__init__.py�<lambda>n � z-python_2_unicode_compatible.<locals>.<lambda>)�PY3�__str__r ��clsr r r �python_2_unicode_compatibleI s #
r c s"