%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/future/utils/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyo

�
�A�[c-@s�dZddlZddlZddlZddlZddlZddlZejddkZejdd!dtkZ	ejdd!dukZ
ejddkZejdd!dvkZejdd!dwkZ
eed	�Zd
�Zd�Zer8d�Zd
�Zd�ZefZefZefZeZeZnKd�Zd�Zd�ZefZeefZeej fZe!ZeZer�d�Z"n	d�Z"de"_er�dd�Z#dd�Z$dd�Z&n$dd�Z#dd�Z$dd�Z&de#_er.d�Z'd�Z(d �Z)d!�Z*n0ddl+Z+e+j,Z'e+j-Z(e+j.Z)e+j/Z*e0d"�Z1d#�Z2d$�Z3d%�Z4d&�Z5d'�Z6d(�Z7d)�Z8d*�Z9d+�Z:d,�Z;er�d-�Z<ddd.�Z=e>d/�Z?nd0�Z<d1j@�dUd2e?_e=ZAd3�ZBer2d4�ZCn	d5�ZCd6�ZDd7�ZEeZFeZGd8�ZHd9�ZId:�ZJd;�ZKd<�ZLer�ddlMZMeNeMd=�ZOnddd>�ZOd?�ZPdd@�ZQyeRj5Wn#eSk
r�dA�ZTdB�ZUnXdC�ZTdD�ZUer#dE�ZVn	dF�ZVdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsg-ZWdS(xs;
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
i����Niiiiiitpypy_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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt<lambda>ht(tPY3t__str__R(tcls((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytpython_2_unicode_compatibleCs#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(sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR
�s(t__name__t
__module__Rt__call__t__init__R
((RR(sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR
�s		ttemporary_classN(R(RRR
((RRsF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytwith_metaclasslscCs
t|g�S(N(tbytes(ts((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytbchr�scCs*t|t�rt|d�St|�SdS(Nslatin-1(t
isinstancetstrR(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytbstr�s
cCs|S(N((R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytbord�scCs
t|�S(N(tchr(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR�scCs
t|�S(N(R(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR�scCs
t|�S(N(tord(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR�scCs=t|t�r|St|t�r/|jd�St|�SdS(Nslatin-1(RRRR(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyttobytes�s

cCs-t|t�r|jd�Sdj|�SdS(Nslatin-1R(RtunicodeRtjoin(R((sF/opt/alt/python27/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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytnative_str_to_bytes�scCs
|j|�S(N(tdecode(tbR%((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytbytes_to_native_str�scCs|S(N((ttR%((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyttext_to_native_str�scCsddlm}||�S(Ni����(tnewbytes(tfuture.typesR,(RR%R,((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR&�scCs
t|�S(N(tnative(R(R%((sF/opt/alt/python27/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%((sF/opt/alt/python27/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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytlrange�scOstt||��S(N(R0tzip(R2R3((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytlzip�scOstt||��S(N(R0tmap(R2R3((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytlmap�scOstt||��S(N(R0tfilter(R2R3((sF/opt/alt/python27/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(tisidentifier(t.0ta((sF/opt/alt/python27/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((sF/opt/alt/python27/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(tgetattrRtitems(tobjR3tfunc((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyRG
scKs.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(RHRtkeys(RJR3RK((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyRLscKs.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(RHRtvalues(RJR3RK((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyRN"scKs.t|dd�}|s$|j}n||�S(ssUse this only if compatibility with Python versions before 2.7 is
    required. Otherwise, prefer viewitems().
    t	iteritemsN(RHRRI(RJR3RK((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyRP.scKs.t|dd�}|s$|j}n||�S(srUse this only if compatibility with Python versions before 2.7 is
    required. Otherwise, prefer viewkeys().
    titerkeysN(RHRRM(RJR3RK((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyRQ8scKs.t|dd�}|s$|j}n||�S(stUse this only if compatibility with Python versions before 2.7 is
    required. Otherwise, prefer viewvalues().
    t
itervaluesN(RHRRO(RJR3RK((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyRRBscCs<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(RRRK((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytbind_methodLs"cCstj�dS(Ni(tsystexc_info(((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytgetexceptiondscCs4tj�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(tcaller_framet	myglobalstmylocals((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt_get_caller_globals_and_localshs

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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt_repr_striptscBsCe�\}}|j�}||d<||d<d}|||UdS(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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt
raise_from�s

cCsv|dk	r*t|t�r*td��n|dk	rE||�}n|}|j|k	rl|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 valueN(RRt	Exceptiont	TypeErrort
__traceback__twith_traceback(ttptvaluettbRl((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytraise_�scCs7|tkr$tj�\}}}n|j|��dS(N(tEllipsisRWRXRs(Rlt	tracebackt_((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytraise_with_traceback�scCs�t|t�r*t|t�r*|�}n|}t|_t|t�rot|t�ro|�|_t|_nQ|dkr�d|_t|_n0t|t	�r�||_t|_nt
d��tj�d|_
|�dS(sn
        Equivalent to:

            raise EXCEPTION from CAUSE

        on Python 3. (See PEP 3134).
        s/exception causes must derive from BaseExceptioniN(RRt
issubclassRptFalset__suppress_context__t	__cause__tTrueRt
BaseExceptionRqRWRXt__context__(RlRmte((sF/opt/alt/python27/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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytimplements_iterator�s
cCs|jS(N(R�(tx((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR�RcCs|jS(N(R�(R�((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR�RcCs.tr
|St|t�r&|jd�S|SdS(Nsutf-8(RRR#R(tfilename((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytencode_filename�s

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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytis_new_styles!cCst|td��S(s
    Deprecated. Use::
        >>> isinstance(obj, str)
    after this import:
        >>> from future.builtins import str
    u(RR(RJ((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytistextscCst|td��S(s�
    Deprecated. Use::
        >>> isinstance(obj, bytes)
    after this import:
        >>> from future.builtins import bytes
    R(RR(RJ((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytisbytesscCs ddlm}t|�|kS(s�
    Equivalent to the result of ``isinstance(obj, newbytes)`` were
    ``__instancecheck__`` not overridden on the newbytes subclass. In
    other words, it is REALLY a newbytes instance, not a Py2 native str
    object?
    i����(R,(tfuture.types.newbytesR,R(RJR,((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt
isnewbytes)s	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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytisint6scCs!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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR.Is
texeccBsc|dkrBejd�}|j}|dkr<|j}n~n|dkrW|}nddUdS(sExecute code in a namespace.isexec code in globs, locsN(RRWt	_getframeR\R](tcodetglobstlocstframe((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytexec_qs		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(((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytold_divs	$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((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR�Rcs%tj����fd��}|S(Ncs�||�jd��S(NR%(R(R2R3(R%R�(sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytwrapper�s(t	functoolstwraps(R�R�(R%(R�sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytencoder�s!N(R(R%R�((R%sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt
as_native_str�scCst|j��S(N(R0RO(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt
listvalues�scCst|j��S(N(R0RI(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt	listitems�scCs
|j�S(N(RO(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR��scCs
|j�S(N(RI(R((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR��scCs|S(N((RJ((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pytensure_new_type�scCs�ddlm}ddlm}ddlm}ddlm}tt	|��}t
|t|��r�|tkr}||�S|tkr�||�S|t
kr�||�S|tkr�||�S|tkr�||�S|Sn|SdS(Ni����(R,(tnewstr(tnewint(tnewdict(R�R,tfuture.types.newstrR�tfuture.types.newintR�tfuture.types.newdictR�RR.R|RR#tinttlongtdict(RJR,R�R�R�tnative_type((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyR��s$




tPY2tPY26RtPYPYR�RVRRR)R�R�R�tget_nextRYR�R�R�R;R�R�R�RPRQRRR:R�R�R8R4R6R.tnative_bytest
native_strR&R�R	RwR{treraiseR+R"RGRLRNR(ii(ii(ii(ii(Xt__doc__RTRWR�R�RkRZtversion_infoRt	PY35_PLUSt	PY36_PLUSR�R�tPY27R�R�R	RRRRRtstring_typesR�t
integer_typesRtclass_typest	text_typeRtbinary_typet
basestringR�t	ClassTypeR#R"R&R)RR+R4R6R8R:t__builtin__R1R5R7R9R}R;RGRLRNRPRQRRRVRYRaRhRoRwRxR{tstripR�R�R�R�R�R�R�R�R�R�R�R.tbuiltinsRHR�R�R�R�tAttributeErrorR�R�R�t__all__(((sF/opt/alt/python27/lib/python2.7/site-packages/future/utils/__init__.pyt<module>0s�	)	$											
			
												
	
	
						*							
	
	
		$	
	
					

Zerion Mini Shell 1.0