Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/future/types/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib/python2.7/site-packages/future/types/newbytes.pyc

�
,�]c@sdZddlmZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
ddlmZer�ddlmZnddlmZeZe	r�eZndefd	��YZd
�Zde
ee�fd��YZdgZdS(
s�
Pure-Python implementation of a Python 3-like bytes object for Python 2.

Why do this? Without it, the Python 2 bytes object is a very, very
different beast to the Python 3 bytes object.
i����(tIntegralN(tistexttisbytestPY2tPY3twith_metaclass(tnotissubset(t	newobject(tIterabletBaseNewBytescBseZd�ZRS(cCs-|tkrt|t�St|j|�SdS(N(tnewbytest
isinstancet_builtin_bytest
issubclasst	__class__(tclstinstance((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt__instancecheck__s
(t__name__t
__module__R(((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR
scCs*t|t�r|jd�St|�SdS(Ntascii(Rtstrtencodetchr(tx((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt_newchr%s
RcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Ze	e
�d��Ze	e
�d��Ze	e
�d	��Z
e	e
�d
��Zd�Zd�Zd
�Zed��Ze	e
�d��Ze	e
�d��Ze	e
d0�d��Zd�Zddd�Ze	e
�d��Ze	e
�d��Ze	e
�d1dd��Zed�Ze	e
�d1dd��Ze	e
�d��Z e	e
�d��Z!e	e
d2�d ��Z"e	e
�d!��Z#d"�Z$d#�Z%d$Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,e	e
�d1d+��Z-e	e
�d1d,��Z.d-�Z/e	e
�d.��Z0ee	e
�d/���Z1RS(3s8
    A backport of the Python 3 bytes object to Py2
   
cOs�d
}d
}t|�dkr4tt|�j|�St|�dkr�t|�}t|�dkrs|j�}n|j�}nt|d�tkr�|dSt|dt	�r�|d}n�t|dt
�r�yZd|kr|d
ks�t�|d}nd|kr,|d
kst�|d}nWntk
rLtd��nX|d
krhtd��n|g}|d
k	r�|j
|�n|dj|�}n�t|dd�r�|dj�}n�t|dt�rAt|d�dkr�d	}q�y-tg|dD]}t|�^q�}Wq�td
��q�XnMt|dt�r�|ddkrstd��nd|d}n
|d}t|�tkr�tj|�Stt|�j||�Sd
S(sK
        From the Py3 bytes docstring:

        bytes(iterable_of_ints) -> bytes
        bytes(string, encoding[, errors]) -> bytes
        bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
        bytes(int) -> bytes object of size given by the parameter
initialized with null bytes
        bytes() -> empty bytes object

        Construct an immutable array of bytes from:
          - an iterable yielding integers in range(256)
          - a text string encoded using the specified encoding
          - any object implementing the buffer API.
          - an integer
        iiitencodingterrorss#Argument given by name and
positions+unicode string argument without an encodingt	__bytes__tsbytes
must be in range(0, 256)snegative
counttN(tNonetlentsuperRt__new__tlisttpopttypeRR
tunicodetAssertionErrort	TypeErrortappendRthasattrRR	t	bytearrayRt
ValueErrorRtcopy(RtargstkwargsRRtvaluetnewargsR((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR#0s\


		-

cCsdtt|�j�S(Ntb(R"Rt__repr__(tself((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR4�scCs
ddjtt|�j��S(NR3s'{0}'(tformatR"Rt__str__(R5((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR7�scCs?tt|�j|�}t|t�r1t|�St|�SdS(N(R"Rt__getitem__RRtord(R5tyR1((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR8�s
cGs|jt|��S(N(R8tslice(R5R/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt__getslice__�scCsat|t�r!t|g�}n't|�tkr<|}nt|�}tt|�t|��S(N(RtintRR&RR$(R5tkeytnewbyteskey((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt__contains__�s	cCsttt|�j|��S(N(RR"t__add__(R5tother((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRA�scCst|�|S(N(R(R5tleft((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt__radd__�scCsttt|�j|��S(N(RR"t__mul__(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRE�scCsttt|�j|��S(N(RR"t__rmul__(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRF�scCs�t|t�r!tj|�}n�t|t�r�g}x<|D]4}t|t�rdtj|�}n|j|�q=Wt|�}nit|jd�r�t|jd�r�xB|j�D]1\}}t|t�r�tj|�||<q�q�Wntj	||�S(NR8t	iteritems(
RRR
R7ttupleR*R+RRGt__mod__(R5tvalstnewvalstvtk((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRI�s
cCs
|j|�S(N(RI(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt__imod__�scCs�d}t|�st|�r?t|jdt|����nxGt|�D]9\}}t|�rLt|j|t|����qLqLWttt|�j|��S(Ns,sequence
item {0}: expected bytes, {1}
foundi(	RRR)R6R&t	enumerateRR"tjoin(R5titerable_of_bytesterrmsgtititem((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRP�s!%cCs||jdd�jd��S(Nt
Rthex(treplacetdecode(Rtstring((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pytfromhex�scGstt|�j||�S(N(R"Rtfind(R5tsubR/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR[�scGstt|�j||�S(N(R"Rtrfind(R5R\R/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR]�siicGs"ttt|�j|||��S(N(RR"RW(R5toldtnewR/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRW�scGstd��dS(Ns+encode
method has been disabled in
newbytes(tAttributeError(R5R/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR�ssutf-8tstrictcCsUddlm}|dkr6ddlm}|�n|tt|�j||��S(s�
        Returns a newstr (i.e. unicode subclass)

        Decode B using the codec registered for encoding. Default encoding
        is 'utf-8'. errors may be given to set a different error
        handling scheme.  Default is 'strict' meaning that
encoding errors raise
        a UnicodeDecodeError.  Other possible values are 'ignore'
and 'replace'
        as well as any other name registered with codecs.register_error
that is
        able to handle UnicodeDecodeErrors.
       
i����(tnewstrtsurrogateescape(tregister_surrogateescape(tfuture.types.newstrRbtfuture.utils.surrogateescapeRdR"RRX(R5RRRbRd((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRX�s

cGstt|�j||�S(N(R"Rt
startswith(R5tprefixR/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRgscGstt|�j||�S(N(R"Rtendswith(R5RhR/((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRisi����cCs8tt|�j||�}g|D]}t|�^q"S(N(R"Rtsplit(R5tseptmaxsplittpartstpart((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRj"scCs5tt|�j|�}g|D]}t|�^qS(s�
        B.splitlines([keepends]) -> list of lines

        Return a list of the lines in B, breaking at line boundaries.
        Line breaks are not included in the resulting list unless keepends
        is given and true.
        (R"Rt
splitlines(R5tkeependsRmRn((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRo)s
cCs8tt|�j||�}g|D]}t|�^q"S(N(R"Rtrsplit(R5RkRlRmRn((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRq6scCs,tt|�j|�}td�|D��S(Ncss|]}t|�VqdS(N(R(t.0Rn((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pys	<genexpr>@s(R"Rt	partitionRH(R5RkRm((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRs=scCs,tt|�j|�}td�|D��S(Ncss|]}t|�VqdS(N(R(RrRn((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pys	<genexpr>Es(R"Rt
rpartitionRH(R5RkRm((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRtBscGs1|j||�}|dkr-td��ndS(s�
        S.rindex(sub [,start [,end]]) -> int

        Like S.rfind() but raise ValueError when the substring is not
found.
        i����ssubstring not
foundN(R]R-(R5R\R/tpos((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pytrindexGscGs)t|t�r�t|�dkr7dt|�}}nLt|�dkrV|d}n-t|�dkrw|\}}ntd��t|�||!j|�St|t�s�y|j|�}Wq�ttfk
r�td��q�Xnyt	t
|�j||�SWntk
r$td��nXdS(s�
        Returns index of sub in bytes.
        Raises ValueError if byte is not in bytes and TypeError if
can't
        be converted bytes or its length is not 1.
        iiistakes at most 3 argumentsscan't convert sub to
bytesssubstring not
foundN(RR=R!R)R$tindextbytesRR-R"R(R5R\R/tstarttend((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyRwRs$

cCs3t|ttf�r+tt|�j|�StSdS(N(RR
R,R"Rt__eq__tFalse(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR{mscCs-t|t�r%tt|�j|�StSdS(N(RR
R"Rt__ne__tTrue(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR}sss"unorderable
types: bytes() and
{0}cCsGt|t�r%tt|�j|�St|jjt|����dS(N(	RR
R"Rt__lt__R)tunorderable_errR6R&(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR{scCsGt|t�r%tt|�j|�St|jjt|����dS(N(	RR
R"Rt__le__R)R�R6R&(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsGt|t�r%tt|�j|�St|jjt|����dS(N(	RR
R"Rt__gt__R)R�R6R&(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsGt|t�r%tt|�j|�St|jjt|����dS(N(	RR
R"Rt__ge__R)R�R6R&(R5RB((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCstt|�j�S(N(R"RR7(R5((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt
__native__�scCs1|dkrtd��ntt|�j|�S(su
        A trick to cause the ``hasattr`` builtin-fn to return False for
        the 'encode' method on Py2.
        Ruencodes+encode method has been disabled in
newbytes(sencodeuencode(R`R"Rt__getattribute__(R5tname((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsttt|�j|��S(s�
        Strip trailing bytes contained in the argument.
        If the argument is omitted, strip trailing ASCII whitespace.
       
(RR"trstrip(R5tbytes_to_strip((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsttt|�j|��S(s�
        Strip leading and trailing bytes contained in the argument.
        If the argument is omitted, strip trailing ASCII whitespace.
       
(RR"tstrip(R5R�((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsttt|�j��S(sv
        b.lower() -> copy of b

        Return a copy of b with all ASCII characters converted to
lowercase.
       
(RR"tlower(R5((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsttt|�j��S(sv
        b.upper() -> copy of b

        Return a copy of b with all ASCII characters converted to
uppercase.
       
(RR"tupper(R5((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��scCsttj||��S(sT
        B.maketrans(frm, to) -> translation table

        Return a translation table (a bytes object of length 256) suitable
        for use in the bytes or bytearray translate method where each byte
        in frm is mapped to the byte at the same position in to.
        The bytes objects frm and to must be of the same length.
       
(RRYt	maketrans(Rtfrmtto((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR��s(iiN(i(2RRt__doc__R#R4R7R8R<R@RR'RARDRERFRIRNRPtclassmethodRZR[R]RWRRXRgRiR
RjR|RoRqRsRtRvRwR{R}R�RR�R�R�R�R�R�R�R�R�R�(((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyR,s`	Z										1	
														(R�tnumbersRRYR.tfuture.utilsRRRRRtfuture.typesRRtfuture.types.newobjectRtcollectionsR	tcollections.abcRxR
RR'R&R
RRt__all__(((s9/usr/lib/python2.7/site-packages/future/types/newbytes.pyt<module>s"(		��