File: //usr/lib/python3/dist-packages/future/utils/__pycache__/__init__.cpython-310.pyc
o
,1�]DU � @ sv d Z ddlZddlZddlZddlZddlZddlZejd dkZejdd� dkZ ejdd� dkZ
ejdd� dkZejd dkZejdd� dkZ
ejdd� d kZeed
�Zdd� Zd
d� Zer~dd� Zdd� Zdd� ZefZefZefZeZeZndd� Zdd� Zdd� ZefZee fZeej!fZe"ZeZer�dd� Z#ndd� Z#de#_ er�dtdd�Z$dtdd �Z%dud!d"�Z&ndud#d�Z$dud$d �Z%dvd&d"�Z&d'e$_ er�d(d)� Z'd*d+� Z(d,d-� Z)d.d/� Z*nddl+Z+e+j,Z'e+j-Z(e+j.Z)e+j/Z*dwd1d2�Z0d3d4� Z1d5d6� Z2d7d8� Z3d9d:� Z4d;d<� Z5d=d>� Z6d?d@� Z7dAdB� Z8dCdD� Z9dEdF� Z:e�r/dGdH� Z;dxdIdJ�Z<e=fdKdL�Z>n
dMdH� Z;e?dN�@� � dOe>_ e<ZAdPdQ� ZBe�rJdRdS� ZCndTdS� ZCdUdV� ZDdWdX� ZEeZFeZGdYdZ� ZHd[d\� ZId]d^� ZJd_d`� ZKdadb� ZLe�r{ddlMZMeNeMdc�ZOndxddde�ZOdfdg� ZPdtdhdi�ZQzeRj4 W n eS�y� djdk� ZTdldm� ZUY n w dndk� ZTdodm� ZUe�r�dpdq� ZVndrdq� ZVg ds�ZWdS )ya�
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 � �pypy_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 s z-python_2_unicode_compatible.<locals>.<lambda>)�PY3�__str__r ��clsr r r �python_2_unicode_compatibleF s #
r c s"