Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/future/utils/ |
| [Home] [System Details] [Kill Me] |
�
,1�]c2@s�dZddlZddlZddlZddlZddlZddlZejddkZejdd!dzkZ ejdd!d{kZ
ejdd!d|kZejddkZejdd!d}kZ
ejdd!d~kZeed
�Zd�Zd�ZerNd
�Zd�Zd�ZefZefZefZeZeZnKd�Zd�Zd�ZefZee
fZeej!fZe"ZeZer�d�Z#n d�Z#de#_er�dd�Z$dd�Z%dd�Z'n$dd�Z$dd�Z%dd�Z'de$_erDd�Z(d
�Z)d!�Z*d"�Z+n0ddl,Z,e,j-Z(e,j.Z)e,j/Z*e,j0Z+e1d#�Z2d$�Z3d%�Z4d&�Z5d'�Z6d(�Z7d)�Z8d*�Z9d+�Z:d,�Z;d-�Z<erd.�Z=ddd/�Z>e?d0�Z@nd1�Z=d2jA�dUd3e@_e>ZBd4�ZCerHd5�ZDn d6�ZDd7�ZEd8�ZFeZGeZHd9�ZId:�ZJd;�ZKd<�ZLd=�ZMer�ddlNZNeOeNd>�ZPnddd?�ZPd@�ZQddA�ZRyeSj6Wn#eTk
rdB�ZUdC�ZVnXdD�ZUdE�ZVer9dF�ZWn dG�ZWdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdyg2ZXdS(s�
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
i����Niiiiiiitpypy_translation_infocCs%ts!|j|_d�|_n|S(s�
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: \u5b54\u5b50'
>>> 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.
cSs|j�jd�S(Nsutf-8(t__unicode__tencode(tself((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt<lambda>ks(tPY3t__str__R(tcls((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytpython_2_unicode_compatibleFs#cs/d�f��fd��Y}|ddi�S(s�
Function from jinja2/_compat.py. License: BSD.
Use it like this::
class BaseForm(object):
pass
class FormType(type):
pass
class Form(with_metaclass(FormType, BaseForm)):
pass
This requires a bit of explanation: the basic idea is to make a
dummy metaclass for one level of class instantiation that replaces
itself with the actual metaclass. Because of internal type checks
we also need to make sure that we downgrade the custom metaclass
for one level to something closer to type (that's why __call__ and
__init__ comes back from type etc.).
This has the advantage over six.with_metaclass of not introducing
dummy classes into the final MRO.
t metaclasscs,eZejZejZ��fd�ZRS(cs2|dkr"tj||d|�S�|�|�S(N((tNonettypet__new__(Rtnamet
this_basestd(tbasestmeta(s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR�s(t__name__t
__module__Rt__call__t__init__R((RR(s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR �s ttemporary_classN(R
(RRR ((RRs9/usr/lib/python2.7/site-packages/future/utils/__init__.pytwith_metaclassoscCs
t|g�S(N(tbytes(ts((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytbchr�scCs*t|t�rt|d�St|�SdS(Nslatin-1(t
isinstancetstrR(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytbstr�s
cCs|S(N((R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytbord�scCs
t|�S(N(tchr(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR�scCs
t|�S(N(R(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR�scCs
t|�S(N(tord(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR�scCs=t|t�r|St|t�r/|jd�St|�SdS(Nslatin-1(RRRR(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyttobytes�s
cCs-t|t�r|jd�Sdj|�SdS(Nslatin-1t(RtunicodeRtjoin(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR!�s
sS
Encodes to latin-1 (where the first 256 chars are the same as
ASCII.)
sutf-8cCs
|j|�S(N(R(Rtencoding((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytnative_str_to_bytes�scCs
|j|�S(N(tdecode(tbR%((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytbytes_to_native_str�scCs|S(N((ttR%((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyttext_to_native_str�scCsddlm}||�S(Ni����(tnewbytes(tfuture.typesR,(RR%R,((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR&�scCs
t|�S(N(tnative(R(R%((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR)�stasciicCst|�j|�S(s}
Use this to create a Py2 native string when "from __future__
import
unicode_literals" is in effect.
(R#R(R*R%((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR+�ssu
On Py3, returns an encoded string.
On Py2, returns a newbytes type, ignoring the ``encoding`` argument.
cOstt||��S(N(tlisttrange(targstkwargs((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytlrange�scOstt||��S(N(R0tzip(R2R3((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytlzip�scOstt||��S(N(R0tmap(R2R3((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytlmap�scOstt||��S(N(R0tfilter(R2R3((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytlfilter�scCse|r#td�|jd�D��Str3|j�Sddl}|jd�}t|j|��SdS(sE
A function equivalent to the str.isidentifier method on Py3
css|]}t|�VqdS(N(tisidentifier(t.0ta((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pys <genexpr>st.i����Ns[a-zA-Z_][a-zA-Z0-9_]*$(talltsplitRR;tretcompiletbooltmatch(RtdottedRAt_name_re((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR;�s
cKs.t|dd�}|s$|j}n||�S(s�
Function for iterating over dictionary items with the same set-like
behaviour on Py2.7 as on Py3.
Passes kwargs to method.t viewitemsN(tgetattrR
titems(tobjR3tfunc((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRG
scKs.t|dd�}|s$|j}n||�S(s�
Function for iterating over dictionary keys with the same set-like
behaviour on Py2.7 as on Py3.
Passes kwargs to method.tviewkeysN(RHR
tkeys(RJR3RK((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRLscKs.t|dd�}|s$|j}n||�S(s�
Function for iterating over dictionary values with the same set-like
behaviour on Py2.7 as on Py3.
Passes kwargs to method.t
viewvaluesN(RHR
tvalues(RJR3RK((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRN%scKs.t|dd�}|s$|j}n||�S(ssUse
this only if compatibility with Python versions before 2.7 is
required. Otherwise, prefer viewitems().
t iteritemsN(RHR
RI(RJR3RK((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRP1scKs.t|dd�}|s$|j}n||�S(srUse
this only if compatibility with Python versions before 2.7 is
required. Otherwise, prefer viewkeys().
titerkeysN(RHR
RM(RJR3RK((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRQ;scKs.t|dd�}|s$|j}n||�S(stUse
this only if compatibility with Python versions before 2.7 is
required. Otherwise, prefer viewvalues().
t
itervaluesN(RHR
RO(RJR3RK((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRREscCs<ts(t||tj|d|��nt|||�dS(s/Bind
a method to class, python 2 and python 3 compatible.
Parameters
----------
cls : type
class to receive bound method
name : basestring
name of method on class instance
func : function
function to be bound as method
Returns
-------
None
N(Rtsetattrttypest
MethodTypeR
(RR
RK((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytbind_methodOs"cCstj�dS(Ni(tsystexc_info(((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytgetexceptiongscCs4tj�d}|dj}|dj}||fS(sr
Returns the globals and locals of the calling frame.
Is there an alternative to frame hacking here?
ii(tinspecttstackt f_globalstf_locals(tcaller_framet myglobalstmylocals((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt_get_caller_globals_and_localsks
cCs=t|�}|jd�r5|jd�r5|dd!S|SdS(sA
Returns the string without any initial or final quotes.
t'ii����N(treprt
startswithtendswith(tmystringtr((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt_repr_stripwscBsJe�\}}|j�}||d<||d<d}|||fdUdS(sn
Equivalent to:
raise EXCEPTION from CAUSE
on Python 3. (See PEP 3134).
t__python_future_raise_from_exct
__python_future_raise_from_causesJraise __python_future_raise_from_exc from
__python_future_raise_from_causeN(Ratcopy(texctcauseR_R`texecstr((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt
raise_from�s
cCs�t|t�r3|dk r*td��n|}n�t|t�rht|t�rhtd|j��nZt||�r�|}nBt|t�r�||�}n$|dkr�|�}n||�}|j|k r�|j |��n|�dS(s�
A function that matches the Python 2.x ``raise`` statement. This
allows re-raising exceptions with the cls value and traceback on
Python 2 and 3.
s0instance exception may not have a separate values,class must
derive from BaseException, not %sN(
Rt
BaseExceptionR
t TypeErrorRt
issubclassRttuplet
__traceback__twith_traceback(ttptvaluettbRl((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytraise_�s
cCs7|tkr$tj�\}}}n|j|��dS(N(tEllipsisRWRXRu(Rlt tracebackt_((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytraise_with_traceback�scCst|t�r*t|t�r*|�}n|}t|_t|t�r�t|t�r�|�|_tj�d|j_ t
|_nq|dkr�d|_t
|_nPt|t�r�||_t
j|jdtj�d�t
|_ntd��tj�d|_|�dS(sn
Equivalent to:
raise EXCEPTION from CAUSE
on Python 3. (See PEP 3134).
iRts/exception causes must derive from
BaseExceptioniN(RRRrt ExceptiontFalset__suppress_context__t __cause__RWRXRttTrueR
Rptobjectt__setattr__Rqt__context__(RlRmte((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRo�s$
s�
def raise_(tp, value=None, tb=None):
raise tp, value, tb
def raise_with_traceback(exc, traceback=Ellipsis):
if traceback == Ellipsis:
_, _, traceback = sys.exc_info()
raise exc, None, traceback
sjRaise exception with existing traceback.
If traceback is not passed, uses sys.exc_info() to get traceback.cCs$tr
|S|j|_|`|SdS(s
From jinja2/_compat.py. License: BSD.
Use as a decorator like this::
@implements_iterator
class UppercasingIterator(object):
def __init__(self, iterable):
self._iter = iter(iterable)
def __iter__(self):
return self
def __next__(self):
return next(self._iter).upper()
N(Rt__next__tnext(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytimplements_iterator�s
cCs|jS(N(R�(tx((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRscCs|jS(N(R�(R�((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyRscCs.tr
|St|t�r&|jd�S|SdS(Nsutf-8(RRR#R(tfilename((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytencode_filenames
cCs.t|d�o-dt|�kp-t|d�S(s
Python 2.7 has both new-style and old-style classes. Old-style classes
can
be pesky in some circumstances, such as when using inheritance. Use
this
function to test for whether a class is new-style. (Python 3 only has
new-style classes.)
t __class__t__dict__t __slots__(thasattrtdir(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytis_new_style
s!cCst|td��S(s
Deprecated. Use::
>>> isinstance(obj, str)
after this import:
>>> from future.builtins import str
u(RR(RJ((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytistext0scCst|td��S(s�
Deprecated. Use::
>>> isinstance(obj, bytes)
after this import:
>>> from future.builtins import bytes
R"(RR(RJ((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytisbytes:scCst|�jdkS(s
Equivalent to the result of ``type(obj) == type(newbytes)``
in other words, it is REALLY a newbytes instance, not a Py2 native str
object?
Note that this does not cover subclasses of newbytes, and it is not
equivalent to ininstance(obj, newbytes)
R,(RR(RJ((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt
isnewbytesDs cCst|tj�S(s_
Deprecated. Tests whether an object is a Py3 ``int`` or either a Py2
``int`` or
``long``.
Instead of using this function, you can use:
>>> from future.builtins import int
>>> isinstance(obj, int)
The following idiom is equivalent:
>>> from numbers import Integral
>>> isinstance(obj, Integral)
(RtnumberstIntegral(RJ((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytisintPscCs!t|d�r|j�S|SdS(sO
On Py3, this is a no-op: native(obj) -> obj
On Py2, returns the corresponding native Py2 types that are
superclasses for backported objects from Py3:
>>> from builtins import str, bytes, int
>>> native(str(u'ABC'))
u'ABC'
>>> type(native(str(u'ABC')))
unicode
>>> native(bytes(b'ABC'))
b'ABC'
>>> type(native(bytes(b'ABC')))
bytes
>>> native(int(10**20))
100000000000000000000L
>>> type(native(int(10**20)))
long
Existing native types on Py2 will be returned unchanged:
>>> type(native(u'ABC'))
unicode
t
__native__N(R�R�(RJ((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR.cs
texeccBsc|dkrBejd�}|j}|dkr<|j}n~n|dkrW|}nddUdS(sExecute
code in a namespace.isexec code in globs, locsN(R
RWt _getframeR\R](tcodetglobstlocstframe((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytexec_�s cCs8t|tj�r,t|tj�r,||S||SdS(s�
DEPRECATED: import ``old_div`` from ``past.utils`` instead.
Equivalent to ``a / b`` on Python 2 without ``from __future__ import
division``.
TODO: generalize this to other objects (like arrays etc.)
N(RR�R�(R=R(((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytold_div�s $cs$tr
d�S�fd�}|SdS(s~
A decorator to turn a function or method call that returns text, i.e.
unicode, into one that returns a native platform str.
Use it as a decorator like this::
from __future__ import unicode_literals
class MyClass(object):
@as_native_str(encoding='ascii')
def __repr__(self):
return next(self._iter).upper()
cSs|S(N((tf((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR�scs%tj����fd��}|S(Ncs�||�jd��S(NR%(R(R2R3(R%R�(s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytwrapper�s(t functoolstwraps(R�R�(R%(R�s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytencoder�s!N(R(R%R�((R%s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt
as_native_str�scCst|j��S(N(R0RO(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt
listvalues�scCst|j��S(N(R0RI(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt listitems�scCs
|j�S(N(RO(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR��scCs
|j�S(N(RI(R((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR��scCs|S(N((RJ((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pytensure_new_type�scCs�ddlm}ddlm}ddlm}ddlm}tt |��}t
|t|��r�|tkr}||�S|tkr�||�S|t
kr�||�S|tkr�||�S|tkr�||�S|Sn|SdS(Ni����(R,(tnewstr(tnewint(tnewdict(tfuture.types.newbytesR,tfuture.types.newstrR�tfuture.types.newintR�tfuture.types.newdictR�RR.RrRR#tinttlongtdict(RJR,R�R�R�tnative_type((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyR��s$
tPY2tPY26RtPYPYR�tbinary_typeRVRRR)tclass_typesR�R�R�tget_nextRYR�t
integer_typesR�R�R;R�R�R�RPRQRRR:R�R�R8R4R6R.tnative_bytest
native_strR&R�RRyR}treraisetstring_typesR+t text_typeR!RGRLRNR(ii(ii(ii(ii(ii(Yt__doc__RTRWR�R�RkRZtversion_infoRt PY34_PLUSt PY35_PLUSt PY36_PLUSR�R�tPY27R�R�RRRRRRR�R�R�RR�R�RR�t
basestringR�t ClassTypeR#R!R&R)R
R+R4R6R8R:t__builtin__R1R5R7R9RR;RGRLRNRPRQRRRVRYRaRhRoRyRzR}tstripR�R�R�R�R�R�R�R�R�R�R�R.tbuiltinsRHR�R�R�R�tAttributeErrorR�R�R�t__all__(((s9/usr/lib/python2.7/site-packages/future/utils/__init__.pyt<module>2s� ) $
& ,
$