• File: __init__.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/future/utils/__pycache__/__init__.cpython-37.pyc
  • Date Modified: 06/27/2022 11:49 PM
  • File size: 19.26 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

A[eO-@sdZddlZddlZddlZddlZddlZddlZejddkZejdddkZ	ejdddkZ
ejddkZejdddkZejdddkZ
eed	Zd
dZdd
ZerddZddZddZefZefZefZeZeZn8ddZddZddZefZeefZeej fZe!ZeZer2ddZ"nddZ"de"_erfdzddZ#d{ddZ$d|d d!Z%nd}d"dZ#d~d#dZ$dd%d!Z%d&e#_erd'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)dd0d1Z/d2d3Z0d4d5Z1d6d7Z2d8d9Z3d:d;Z4d<d=Z5d>d?Z6d@dAZ7dBdCZ8dDdEZ9erRdFdGZ:ddHdIZ;e<fdJdKZ=ndLdGZ:e>dM?dNe=_e;Z@dOdPZAerdQdRZBndSdRZBdTdUZCdVdWZDeZEeZFdXdYZGdZd[ZHd\d]ZId^d_ZJd`daZKerddlLZLeMeLdbZNn
ddcddZNdedfZOddgdhZPy
eQj3Wn&eRk
r6didjZSdkdlZTYnXdmdjZSdndlZTerXdodpZUndqdpZUdrdsdtdudhd?ddddUdpdddvdAdPdWd[d1d_d]dYd9d;d=d.dldjd,d(d*dadwdxddfddIdKdyd!dd3d5d7d
g-ZVdS)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
        * 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
N)r)r)rr)rZpypy_translation_infocCsts|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.
    cSs|dS)Nzutf-8)__unicode__encode)selfr
F/opt/alt/python37/lib/python3.7/site-packages/future/utils/__init__.py<lambda>hz-python_2_unicode_compatible.<locals>.<lambda>)PY3__str__r)clsr
r
rpython_2_unicode_compatibleCs#
rcs"Gfddd}|ddiS)a
    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.
    cs&eZdZejZejZfddZdS)z!with_metaclass.<locals>.metaclasscs$|dkrt||d|S||S)Nr
)type__new__)rnameZ
this_basesd)basesmetar
rrsz)with_metaclass.<locals>.metaclass.__new__N)__name__
__module____qualname__r__call____init__rr
)rrr
r	metaclasssrZtemporary_classNr
)rrrr
)rrrwith_metaclasslsrcCs
t|gS)N)bytes)sr
r
rbchrsr!cCs t|trt|dSt|SdS)Nzlatin-1)
isinstancestrr)r r
r
rbstrs

r$cCs|S)Nr
)r r
r
rbordsr%cCst|S)N)chr)r r
r
rr!scCst|S)N)r#)r r
r
rr$scCst|S)N)ord)r r
r
rr%scCs.t|tr|St|tr"|dSt|SdS)Nzlatin-1)r"rr#r)r r
r
rtobytess



r(cCs"t|tr|dSd|SdS)Nzlatin-1)r"unicoderjoin)r r
r
rr(s

zS
    Encodes to latin-1 (where the first 256 chars are the same as
    ASCII.)
    utf-8cCs
||S)N)r)r encodingr
r
rnative_str_to_bytessr.cCs
||S)N)decode)br-r
r
rbytes_to_native_strsr1cCs|S)Nr
)tr-r
r
rtext_to_native_strsr3cCsddlm}||S)Nr)newbytes)Zfuture.typesr4)r r-r4r
r
rr.scCst|S)N)native)r0r-r
r
rr1sasciicCst||S)z}
        Use this to create a Py2 native string when "from __future__ import
        unicode_literals" is in effect.
        )r*r)r2r-r
r
rr3szu
    On Py3, returns an encoded string.
    On Py2, returns a newbytes type, ignoring the ``encoding`` argument.
    cOstt||S)N)listrange)argskwargsr
r
rlrangesr;cOstt||S)N)r7zip)r9r:r
r
rlzipsr=cOstt||S)N)r7map)r9r:r
r
rlmapsr?cOstt||S)N)r7filter)r9r:r
r
rlfiltersrAFcCsL|rtdd|dDStr(|Sddl}|d}t||SdS)zE
    A function equivalent to the str.isidentifier method on Py3
    css|]}t|VqdS)N)isidentifier).0ar
r
r	<genexpr>szisidentifier.<locals>.<genexpr>.rNz[a-zA-Z_][a-zA-Z0-9_]*$)allsplitrrBrecompileboolmatch)r ZdottedrIZ_name_rer
r
rrBs
rBcKs t|dd}|s|j}|f|S)z
    Function for iterating over dictionary items with the same set-like
    behaviour on Py2.7 as on Py3.

    Passes kwargs to method.	viewitemsN)getattritems)objr:funcr
r
rrM
srMcKs t|dd}|s|j}|f|S)z
    Function for iterating over dictionary keys with the same set-like
    behaviour on Py2.7 as on Py3.

    Passes kwargs to method.viewkeysN)rNkeys)rPr:rQr
r
rrRsrRcKs t|dd}|s|j}|f|S)z
    Function for iterating over dictionary values with the same set-like
    behaviour on Py2.7 as on Py3.

    Passes kwargs to method.
viewvaluesN)rNvalues)rPr:rQr
r
rrT"srTcKs t|dd}|s|j}|f|S)zsUse this only if compatibility with Python versions before 2.7 is
    required. Otherwise, prefer viewitems().
    	iteritemsN)rNrO)rPr:rQr
r
rrV.srVcKs t|dd}|s|j}|f|S)zrUse this only if compatibility with Python versions before 2.7 is
    required. Otherwise, prefer viewkeys().
    iterkeysN)rNrS)rPr:rQr
r
rrW8srWcKs t|dd}|s|j}|f|S)ztUse this only if compatibility with Python versions before 2.7 is
    required. Otherwise, prefer viewvalues().
    
itervaluesN)rNrU)rPr:rQr
r
rrXBsrXcCs,tst||t|d|nt|||dS)a/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)rsetattrtypes
MethodType)rrrQr
r
rbind_methodLsr\cCstdS)N)sysexc_infor
r
r
rgetexceptiondsr`cCs(td}|dj}|dj}||fS)zr
    Returns the globals and locals of the calling frame.

    Is there an alternative to frame hacking here?
    rr)inspectstack	f_globalsf_locals)Zcaller_frame	myglobalsmylocalsr
r
r_get_caller_globals_and_localshs

rgcCs0t|}|dr(|dr(|ddS|SdS)zA
    Returns the string without any initial or final quotes.
    'r]N)repr
startswithendswith)Zmystringrr
r
r_repr_striptsrncCs6t\}}|}||d<||d<d}t|||dS)zn
        Equivalent to:

            raise EXCEPTION from CAUSE

        on Python 3. (See PEP 3134).
        Z__python_future_raise_from_excZ __python_future_raise_from_causezJraise __python_future_raise_from_exc from __python_future_raise_from_causeN)rgcopyexec)exccausererfZexecstrr
r
r
raise_froms
rscCsL|dk	rt|trtd|dk	r,||}n|}|j|k	rD|||dS)z
        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.
        Nz0instance exception may not have a separate value)r"	Exception	TypeError
__traceback__with_traceback)tpvaluetbrqr
r
rraise_s


r{cCs$|tkrt\}}}||dS)N)Ellipsisr^r_rw)rq	traceback_r
r
rraise_with_tracebacksrcCst|trt|tr|}n|}d|_t|trJt|trJ||_d|_n6|dkr`d|_d|_n t|trx||_d|_ntdt	d|_
|dS)zn
        Equivalent to:

            raise EXCEPTION from CAUSE

        on Python 3. (See PEP 3134).
        FTNz/exception causes must derive from BaseExceptionr])r"r
issubclassrt__suppress_context__	__cause__
BaseExceptionrur^r___context__)rqrrer
r
rrss 
z
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
zjRaise exception with existing traceback.
If traceback is not passed, uses sys.exc_info() to get traceback.cCstr|S|j|_|`|SdS)a
    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)r__next__next)rr
r
rimplements_iterators
rcCs|jS)N)r)xr
r
rrr
rcCs|jS)N)r)rr
r
rrr
cCs$tr|St|tr|dS|SdS)Nzutf-8)rr"r*r)filenamer
r
rencode_filenames


rcCs t|dodt|kpt|dS)a
    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.)
    	__class____dict__	__slots__)hasattrdir)rr
r
ris_new_stylesrcCst|tdS)z
    Deprecated. Use::
        >>> isinstance(obj, str)
    after this import:
        >>> from future.builtins import str
    r))r"r)rPr
r
ristextsrcCst|tdS)z
    Deprecated. Use::
        >>> isinstance(obj, bytes)
    after this import:
        >>> from future.builtins import bytes
    r
)r"r)rPr
r
risbytessrcCsddlm}t||kS)z
    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?
    r)r4)future.types.newbytesr4r)rPr4r
r
r
isnewbytes)s	rcCst|tjS)a_
    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)
    )r"numbersIntegral)rPr
r
risint6srcCst|dr|S|SdS)aO
    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
    
__native__N)rr)rPr
r
rr5Is
r5rpcCsB|dkr*td}|j}|dkr&|j}~n|dkr6|}tddS)zExecute code in a namespace.Nr]zexec code in globs, locs)r^	_getframercrdrp)codeZglobsZlocsframer
r
rexec_qs
rcCs,t|tjr t|tjr ||S||SdS)z
    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)r"rr)rDr0r
r
rold_divs	rcs trddSfdd}|SdS)a~
    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)Nr
)fr
r
rrr
zas_native_str.<locals>.<lambda>cstfdd}|S)Ncs||jdS)N)r-)r)r9r:)r-rr
rwrappersz/as_native_str.<locals>.encoder.<locals>.wrapper)	functoolswraps)rr)r-)rrencoderszas_native_str.<locals>.encoderN)r)r-rr
)r-r
as_native_strsrcCst|S)N)r7rU)rr
r
r
listvaluessrcCst|S)N)r7rO)rr
r
r	listitemssrcCs|S)N)rU)rr
r
rrscCs|S)N)rO)rr
r
rrscCs|S)Nr
)rPr
r
rensure_new_typesrcCsddlm}ddlm}ddlm}ddlm}tt	|}t
|t|r|tkrZ||S|tkrj||S|t
krz||S|tkr||S|tkr||S|Snt|||gkst|SdS)Nr)r4)newstr)newint)newdict)rr4Zfuture.types.newstrrZfuture.types.newintrZfuture.types.newdictrrr5rr#r*intlongdictAssertionError)rPr4rrrZnative_typer
r
rrs&PY2PY26rPYPYget_nextnative_bytes
native_strreraise)r,)r,)N)N)N)r6)F)NN)NN)r,)W__doc__rZr^rrroraversion_inforZ	PY35_PLUSZ	PY36_PLUSrrZPY27rrrrr!r$r%r#Zstring_typesrZ
integer_typesrZclass_typesZ	text_typerZbinary_typeZ
basestringrZ	ClassTyper*r(r.r1r3r;r=r?rAZ__builtin__r8r<r>r@rBrMrRrTrVrWrXr\r`rgrnrsr{r|rrpstriprrrrrrrrrrrr5builtinsrNrrrrAttributeErrorrrr__all__r
r
r
r<module>0s
)$


	











"

	


$