AlkantarClanX12

Your IP : 18.219.47.239


Current Path : /proc/self/root/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyc

�
��abc
@s>ddlmZdZdZdZdZdZdZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZyddlZddlZWnek
r�eZZnXeefZyeef7ZWnek
r�nXd	d
ddgZejd
dkr3ddlZnddlZejZdZdZ e dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2d!Z3d"Z4d#Z5d
Z6d$Z7d%Z8e7Z9e'e(e)e*e-e.e/e+e,e0e1e2fZ:e'e(e/e2fZ;e0e1e2fZ<d&d'd(d)d*d+d,d-fZ=e>d&d'd,d-f�Z?ie@d.6e@d/6e@d)6eAd*6eAd+6eAd(6ZBd0ZCd1ZDd2ZEd3ZFd4ZGd5ZHd6ZId7ZJdZKd8ZLd9ZMd:ZNd;ZOd<ZPd=ZQd>ZRd%ZSd$ZTe	jUd?d@fkr)dAZVnejW�ZVdB�ZXdC�ZYdD�ZZd=e9dE�Z[dF�Z\edG�Z]eCdHfeDdIfeEdJfeFdKfeGdLfeHdMffeLdNffeMdOffeNeIBdPfeId feNd!ffeOdNffePdOffeQeJBdPfeJd feQd!ffeRdNffeSdOffeTeKBdQfeKdRfeTd!fff
Z^dS�Z_de`fdT��YZadUeafdV��YZbdWeafdX��YZcdYeafdZ��YZdd[eafd\��YZed]eafd^��YZfd_effd`��YZgdaeffdb��YZhdceffdd��YZideeffdf��YZjdgeffdh��YZkdielfdj��YZmdkelfdl��YZndmelfdn��YZodoelfdp��YZpdqelfdr��YZqdselfdt��YZrd
elfdu��YZsd	elfdv��YZtdwelfdx��YZudy�ZveZwetjZdS(zi����(tprint_functions
$Revision$s0.9.0s&Lars Gust\u00e4bel (lars@gustaebel.de)s5$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $s?$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $s8Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend.NtTarFiletTarInfot
is_tarfiletTarErroriisiisustar  sustar00idi�t0t1t2t3t4t5t6t7tLtKtStxtgtXiitpathtlinkpathtsizetmtimetuidtgidtunametgnametatimetctimei�i�i`i@i iiiii�i@i iiitnttcesutf-8cCs,|j||�}|| |t|�tS(s8Convert a string to a null-terminated bytes object.
    (tencodetlentNUL(tstlengthtencodingterrors((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytstn�scCs8|jd�}|dkr(|| }n|j||�S(s8Convert a null-terminated bytes object to a string.
    si����(tfindtdecode(R"R$R%tp((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytnts�s
cCs�|dtd�kr^y%tt|dd�p1dd�}Wq�tk
rZtd��q�XnId}x@tt|�d�D](}|dK}|t||d�7}q{W|S(	s/Convert a number field to a python number.
    ii�tasciitstrictRisinvalid headeri(tchrtintR*t
ValueErrortInvalidHeaderErrortrangeR tord(R"tnti((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytnti�s%

cCs�d|kod|dknrHd|d|fjd�t}n�|tksh|d|dkrwtd��n|dkr�tjdtjd	|��d}nt�}x6t|d�D]$}|j	d|d
@�|dL}q�W|j	dd�|S(s/Convert a python number to a number field.
    iiis%0*oR+isoverflow in number fieldR
tli�i�(
RR!t
GNU_FORMATR/tstructtunpacktpackt	bytearrayR1tinsert(R3tdigitstformatR"R4((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytitn�s	$$ %	cCsxdttjd|d �tjd|dd!��}dttjd|d �tjd|dd!��}||fS(	s�Calculate the checksum for a member's header by summing up all
       characters except for the chksum field which is treated as if
       it was filled with spaces. According to the GNU tar sources,
       some tars (Sun and NeXT) calculate chksum with signed char,
       which will be different if there are chars in the buffer with
       the high bit set. So we calculate two checksums, unsigned and
       signed.
    it148Bi�t356Bi�it148bt356b(tsumR8R9(tbuftunsigned_chksumt
signed_chksum((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytcalc_chksums�s	77cCs|dkrdS|dkrSx0trN|jd�}|s>Pn|j|�qWdSd}t||�\}}xQt|�D]C}|j|�}t|�|kr�td��n|j|�q{W|dkr|j|�}t|�|kr�td��n|j|�ndS(sjCopy length bytes from fileobj src to fileobj dst.
       If length is None, copy the entire content.
    iNiisend of file reachedi@i@(tNonetTruetreadtwritetdivmodR1R tIOError(tsrctdstR#REtBUFSIZEtblockst	remaindertb((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytcopyfileobjs,	R6t-RTtdtcR)trtwR"tttTcCsig}xStD]K}xB|D]-\}}||@|kr|j|�PqqW|jd�q
Wdj|�S(scConvert a file's mode to a string of the form
       -rwxrwxrwx.
       Used by TarFile.list()
    RVt(tfilemode_tabletappendtjoin(tmodetpermttabletbittchar((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytfilemode8s

cBseZdZRS(sBase exception.(t__name__t
__module__t__doc__(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRGstExtractErrorcBseZdZRS(s%General exception for extract errors.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRjJst	ReadErrorcBseZdZRS(s&Exception for unreadable tar archives.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRkMstCompressionErrorcBseZdZRS(s.Exception for unavailable compression methods.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRlPstStreamErrorcBseZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRmSstHeaderErrorcBseZdZRS(s!Base exception for header errors.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRnVstEmptyHeaderErrorcBseZdZRS(sException for empty headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRoYstTruncatedHeaderErrorcBseZdZRS(s Exception for truncated headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRp\stEOFHeaderErrorcBseZdZRS(s"Exception for end of file headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRq_sR0cBseZdZRS(sException for invalid headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR0bstSubsequentHeaderErrorcBseZdZRS(s3Exception for missing and invalid extended headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRrest
_LowLevelFilecBs2eZdZd�Zd�Zd�Zd�ZRS(s�Low-level file object. Supports reading and writing.
       It is used instead of a regular file object for streaming
       access.
    cCsgitjd6tjtjBtjBd6|}ttd�rK|tjO}ntj||d�|_dS(NRYRZtO_BINARYi�(	tostO_RDONLYtO_WRONLYtO_CREATtO_TRUNCthasattrRttopentfd(tselftnameRa((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__init__rs
cCstj|j�dS(N(RutcloseR|(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�{scCstj|j|�S(N(RuRKR|(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRK~scCstj|j|�dS(N(RuRLR|(R}R"((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRL�s(RgRhRiRR�RKRL(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRsls
				t_StreamcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	d
�Zdd�Z
d�Zd
�ZRS(s�Class that serves as an adapter between TarFile and
       a stream-like object.  The stream-like object only
       needs to have a read() or write() method and is accessed
       blockwise.  Use of gzip or bzip2 compression is possible.
       A stream-like object could be for example: sys.stdin,
       sys.stdout, a socket, a tape device etc.

       _Stream is intended to be used only internally.
    cCs�t|_|dkr0t||�}t|_n|dkrWt|�}|j�}n|p`d|_||_||_	||_
||_d|_d|_
t|_y�|dkr%yddl}Wntk
r�td��nX||_|jd�|_|dkr|j�q%|j�n|d	kr�yddl}Wntk
r`td
��nX|dkr�d|_|j�|_q�|j�|_nWn,|js�|j
j�nt|_�nXdS(s$Construct a _Stream object.
        t*R]itgzi����Nszlib module is not availableRYtbz2sbz2 module is not available(RJt_extfileobjRIRstFalset_StreamProxytgetcomptypeR~RatcomptypetfileobjtbufsizeREtpostclosedtzlibtImportErrorRltcrc32tcrct
_init_read_gzt_init_write_gzR�tdbuftBZ2Decompressortcmpt
BZ2CompressorR�(R}R~RaR�R�R�R�R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�sP								
	


			cCs*t|d�r&|jr&|j�ndS(NR�(RzR�R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__del__�scCs�|jjd|jj|jj|jjd�|_tjdtt	j	���}|j
d|d�|jjd�r�|jd |_n|j
|jj
dd	�t�d
S(s6Initialize for writing with gzip compression.
        i	is<Ls�s�s.gzi����s
iso-8859-1treplaceN(R�tcompressobjtDEFLATEDt	MAX_WBITSt
DEF_MEM_LEVELR�R8R:R.ttimet_Stream__writeR~tendswithRR!(R}t	timestamp((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s
	cCsw|jdkr-|jj||j�|_n|jt|�7_|jdkrf|jj|�}n|j|�dS(s&Write string s to the stream.
        R�ttarN(	R�R�R�R�R�R R�tcompressR�(R}R"((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRL�scCs_|j|7_xIt|j�|jkrZ|jj|j|j �|j|j|_qWdS(s]Write string s to the stream if a whole new block
           is ready to be written.
        N(RER R�R�RL(R}R"((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__write�scCs�|jr
dS|jdkrF|jdkrF|j|jj�7_n|jdkr�|jr�|jj|j�d|_|jdkr�|jjtj	d|j
d@��|jjtj	d|jd@��q�n|js�|jj
�nt|_dS(s[Close the _Stream object. No operation should be
           done on it afterwards.
        NRZR�R]R�s<LI����(R�RaR�RER�tflushR�RLR8R:R�R�R�R�RJ(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s		#)	cCss|jj|jj�|_d|_|jd�dkrItd��n|jd�dkrmtd��nt|jd��}|jd�|d	@r�t|jd��d
t|jd��}|j	|�n|d@rx3t
r|jd�}|s
|tkr�Pq�q�Wn|d@rUx3t
rQ|jd�}|sJ|tkr"Pq"q"Wn|d@ro|jd�nd
S(s:Initialize for reading a gzip compressed fileobj.
        R]is�snot a gzip fileissunsupported compression methodiiiiiN(R�t
decompressobjR�R�R�t
_Stream__readRkRlR2RKRJR!(R}tflagtxlenR"((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s.	

,
	
	
cCs|jS(s3Return the stream's file pointer position.
        (R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyttell#sicCs|||jdkrit||j|j�\}}x$t|�D]}|j|j�q?W|j|�ntd��|jS(sXSet the stream's file pointer to pos. Negative seeking
           is forbidden.
        is seeking backwards is not allowed(R�RMR�R1RKRm(R}R�RRRSR4((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytseek(scCs�|dkrZg}x3trG|j|j�}|s7Pn|j|�qWdj|�}n|j|�}|jt|�7_|S(s�Return the next size number of bytes from the stream.
           If size is not defined, return all bytes of the stream
           up to EOF.
        R]N(RIRJt_readR�R_R`R�R (R}RR[RE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRK5s	cCs�|jdkr|j|�St|j�}x�||kr�|j|j�}|sVPny|jj|�}Wntk
r�td��nX|j|7_|t|�7}q.W|j| }|j||_|S(s+Return size bytes from the stream.
        R�sinvalid compressed data(	R�R�R R�R�R�t
decompressRNRk(R}RRXRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�Gs 


cCs�t|j�}xN||kr_|jj|j�}|s=Pn|j|7_|t|�7}qW|j| }|j||_|S(ssReturn size bytes from stream. If internal buffer is empty,
           read another block from the stream.
        (R RER�RKR�(R}RRXRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__read\s
N(RgRhRiRR�R�RLR�R�R�R�R�RIRKR�R�(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s		4			
					
	R�cBs2eZdZd�Zd�Zd�Zd�ZRS(ssSmall proxy class that enables transparent compression
       detection for the Stream interface (mode 'r|*').
    cCs"||_|jjt�|_dS(N(R�RKt	BLOCKSIZERE(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRqs	cCs|jj|_|jS(N(R�RKRE(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRKuscCs0|jjd�rdS|jjd�r,dSdS(Ns�R�tBZh91R�R�(REt
startswith(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�ys
cCs|jj�dS(N(R�R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s(RgRhRiRRKR�R�(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�ls
			t	_BZ2ProxycBsSeZdZd
Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
RS(sSmall proxy class that enables external file object
       support for "r:bz2" and "w:bz2" modes. This is actually
       a workaround for a limitation in bz2 module's BZ2File
       class which (unlike gzip.GzipFile) has no support for
       a file object argument.
    iicCs8||_||_t|jdd�|_|j�dS(NR~(R�RatgetattrRIR~tinit(R}R�Ra((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s		cCsbddl}d|_|jdkrO|j�|_|jjd�d|_n|j�|_dS(Ni����iRYR](	R�R�RaR�tbz2objR�R�RER�(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s	cCs�t|j�}x`||krq|jj|j�}|s=Pn|jj|�}|j|7_|t|�7}qW|j| }|j||_|jt|�7_|S(N(R RER�RKt	blocksizeR�R�R�(R}RRtrawtdataRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRK�s
cCs4||jkr|j�n|j||j�dS(N(R�R�RK(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s
cCs|jS(N(R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��scCs;|jt|�7_|jj|�}|jj|�dS(N(R�R R�R�R�RL(R}R�R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRL�scCs5|jdkr1|jj�}|jj|�ndS(NRZ(RaR�R�R�RL(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��si@(RgRhRiR�RR�RKR�R�RLR�(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s		
				t_FileInFilecBsAeZdZdd�Zd�Zd�Zd�Zdd�ZRS(sA thin wrapper around an existing file object that
       provides a part of its data as an individual file
       object.
    cCs||_||_||_d|_|dkrBd|fg}nd|_g|_d}|j}xs|D]k\}}||kr�|jjt||df�n|jjt	||||f�||7}||}qjW||jkr
|jjt||jdf�ndS(Ni(
R�toffsetRtpositionRIt	map_indextmapR_R�RJ(R}R�R�Rt	blockinfotlastpostrealpos((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s$							 
cCs#t|jd�stS|jj�S(Ntseekable(RzR�RJR�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��scCs|jS(s*Return the current file position.
        (R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��scCs
||_dS(s(Seek to a position in the file.
        N(R�(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��scCsK|dkr|j|j}nt||j|j�}d}x|dkrFx|tr�|j|j\}}}}||jko�|knr�PqP|jd7_|jt|j�krPd|_qPqPWt|||j�}|r|jj	||j|�||jj
|�7}n|t|7}||8}|j|7_qAW|S(s!Read data from the file.
        R]iiN(RIRR�tminRJR�R�R R�R�RKR!(R}RRER�tstarttstopR�R#((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRK�s(	
N(	RgRhRiRIRR�R�R�RK(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s			tExFileObjectcBs�eZdZdZd�Zd�Zd�Zd�Zdd�Z	e	Z
dd�Zd	�Zd
�Z
ejd�Zd�Zd
�ZRS(saFile-like object for reading an archive member.
       Is returned by TarFile.extractfile().
    icCsdt|j|j|j|j�|_|j|_d|_t|_|j|_d|_	d|_
dS(NRYiR](R�R�toffset_dataRtsparseR~RaR�R�R�tbuffer(R}ttarfilettarinfo((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRs				cCstS(N(RJ(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytreadable!scCstS(N(R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytwritable$scCs
|jj�S(N(R�R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�'scCs�|jrtd��nd}|jrh|dkrH|j}d|_qh|j| }|j||_n|dkr�||jj�7}n ||jj|t|��7}|jt|�7_|S(s~Read at most size bytes from the file. If size is not
           present or None, read all data until EOF is reached.
        sI/O operation on closed fileR]N(R�R/R�RIR�RKR R�(R}RRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRK*s			
 i����cCs
|jrtd��n|jjd�d}|dkr�x|tr�|jj|j�}|j|7_|szd|kr=|jjd�d}|dkr�t|j�}nPq=q=Wn|dkr�t	||�}n|j| }|j||_|j
t|�7_
|S(s�Read one entire line from the file. If size is present
           and non-negative, return a string with at most that
           size, which may be an incomplete line.
        sI/O operation on closed files
iii����(R�R/R�R'RJR�RKR�R R�R�(R}RR�RE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytreadlineEs$		
cCs:g}x-tr5|j�}|s%Pn|j|�q	W|S(s0Return a list with all remaining lines.
        (RJR�R_(R}tresulttline((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt	readlinesbs	cCs|jrtd��n|jS(s*Return the current file position.
        sI/O operation on closed file(R�R/R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�ls	cCs|jrtd��n|tjkrHtt|d�|j�|_n�|tjkr�|dkrt|j|d�|_q�t|j||j�|_nC|tj	kr�tt|j||j�d�|_ntd��d|_
|jj|j�dS(s(Seek to a position in the file.
        sI/O operation on closed fileisInvalid argumentR]N(
R�R/RutSEEK_SETR�tmaxRR�tSEEK_CURtSEEK_ENDR�R�R�(R}R�twhence((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�ts	!(	cCs
t|_dS(sClose the file object.
        N(RJR�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��sccs,x%tr'|j�}|sPn|VqWdS(s/Get an iterator over the file's lines.
        N(RJR�(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__iter__�s
	N(RgRhRiR�RR�R�R�RIRKtread1R�R�R�RuR�R�R�R�(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s	
				
		cBs�eZdZd?Zdd�Zd�Zd�Zeee�Zd�Z	d�Z
ee	e
�Zd�Zd�Z
eedd�Zd�Zd �Zd!�Zed"��Zd#�Zed$��Zed%��Zed&��Zed'��Zed(��Zed)��Zd*�Zd+�Zd,�Z d-�Z!d.�Z"d/�Z#d0�Z$d1�Z%d2�Z&d3�Z'd4�Z(d5�Z)d6�Z*d7�Z+d8�Z,d9�Z-d:�Z.d;�Z/d<�Z0d=�Z1d>�Z2RS(@sInformational class which holds the details about an
       archive member given by a tar header block.
       TarInfo objects are returned by TarFile.getmember(),
       TarFile.getmembers() and TarFile.gettarinfo() and are
       usually created internally.
    R~RaRRRRtchksumttypetlinknameRRtdevmajortdevminorR�R�tpax_headersR�R�t_sparse_structst_link_targetR]cCs�||_d|_d|_d|_d|_d|_d|_t|_d|_	d|_
d|_d|_d|_
d|_d|_d|_i|_dS(sXConstruct a TarInfo object. name is the optional name
           of the member.
        i�iR]N(R~RaRRRRR�tREGTYPER�R�RRR�R�R�R�RIR�R�(R}R~((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s"																cCs|jS(N(R~(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_getpath�scCs
||_dS(N(R~(R}R~((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_setpath�scCs|jS(N(R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_getlinkpath�scCs
||_dS(N(R�(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_setlinkpath�scCs d|jj|jt|�fS(Ns<%s %r at %#x>(t	__class__RgR~tid(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__repr__�scCs�i
|jd6|jd@d6|jd6|jd6|jd6|jd6|jd6|jd	6|jd
6|j	d6|j
d6|jd
6|jd6}|d	t
kr�|djd�r�|dcd7<n|S(s9Return the TarInfo's attributes as a dictionary.
        R~i�RaRRRRR�R�R�RRR�R�t/(R~RaRRRRR�R�R�RRR�R�tDIRTYPER�(R}tinfo((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytget_info�s"











$tsurrogateescapecCsv|j�}|tkr+|j|||�S|tkrJ|j|||�S|tkrf|j||�Std��dS(s<Return a tar header as a string of 512 byte blocks.
        sinvalid formatN(R�tUSTAR_FORMATtcreate_ustar_headerR7tcreate_gnu_headert
PAX_FORMATtcreate_pax_headerR/(R}R>R$R%R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyttobuf�scCst|d<t|d�tkr/td��nt|d�tkri|j|d�\|d<|d<n|j|t||�S(s3Return the object as a ustar header block.
        tmagicR�slinkname is too longR~tprefix(tPOSIX_MAGICR tLENGTH_LINKR/tLENGTH_NAMEt_posix_split_namet_create_headerR�(R}R�R$R%((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s
$cCs�t|d<d}t|d�tkrI||j|dt||�7}nt|d�tkr�||j|dt||�7}n||j|t||�S(s:Return the object as a GNU header block sequence.
        R�R]R�R~(	t	GNU_MAGICR R�t_create_gnu_long_headertGNUTYPE_LONGLINKR�tGNUTYPE_LONGNAMER�R7(R}R�R$R%RE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s
##c
Cs�t|d<|jj�}x�ddtfddtfddfD]�\}}}||kr_q>ny||jd	d
�Wn"tk
r�||||<q>nXt||�|kr>||||<q>q>Wx�ddddfD]�\}}||krd||<q�n||}d|ko+d|dkns@t|t	�r�t
|�||<d||<q�q�W|r|j|t|�}	nd}	|	|j
|td	d�S(s�Return the object as a ustar header block. If it cannot be
           represented this way, prepend a pax extended header sequence
           with supplement information.
        R�R~RR�RRi RR+R,RiRRiRiiR]R�(RRi (RRi (Ri(Ri(Ri(Ri(R�R�tcopyR�R�RtUnicodeEncodeErrorR t
isinstancetfloattstrt_create_pax_generic_headertXHDTYPER�R�(
R}R�R$R�R~thnameR#R=tvalRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s4



4cCs|j|td�S(sAReturn the object as a pax global header block sequence.
        tutf8(RtXGLTYPE(tclsR�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytcreate_pax_global_headerDscCs�|td }x$|r4|ddkr4|d }qW|t|�}|d }|sht|�tkrwtd��n||fS(sUSplit a name longer than 100 chars into a prefix
           and a name part.
        ii����R�sname is too long(t
LENGTH_PREFIXR R�R/(R}R~R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�Js
cCs�t|jdd�d||�t|jdd�d@d|�t|jdd�d|�t|jd	d�d|�t|jd
d�d|�t|jdd�d|�d
|jdt�t|jdd�d||�|jdt�t|jdd�d||�t|jdd�d||�t|jdd�d|�t|jdd�d|�t|jdd�d||�g}tjdtdj|��}t	|t�d}|d d|j
d�|d}|S(s�Return a header block. info is a dictionary with file
           information, format must be one of the *_FORMAT constants.
        R~R]idRaii�iRRRiRs        R�R�R�Ri RR�R�R�i�s%dsi����s%06oR+i����(R&tgetR?R�R�R8R:R�R`RHR(R�R>R$R%tpartsRER�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�Ys&$#cCs@tt|�t�\}}|dkr<|t|t7}n|S(sdReturn the string payload filled with zero bytes
           up to the next 512 byte border.
        i(RMR R�R!(tpayloadRRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_create_payloaduscCsm|j||�t}i}d|d<||d<t|�|d<t|d<|j|t||�|j|�S(sTReturn a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
           for name.
        s
././@LongLinkR~R�RR�(RR!R R�R�R�R(R	R~R�R$R%R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s


cCs�t}xI|j�D];\}}y|jdd�Wqtk
rMt}PqXqWd}|rk|d7}nx�|j�D]�\}}|jd�}|r�|j|d�}n|jd�}t|�t|�d}d}	}
x6tr|tt|
��}	|	|
krPn|	}
q�W|tt|
�d�d	|d
|d7}qxWi}d|d
<||d<t|�|d<t|d<|j	|t
dd�|j|�S(s�Return a POSIX.1-2008 extended or global header sequence
           that contains a list of keyword, value pairs. The values
           must be strings.
        RR,R]s21 hdrcharset=BINARY
R�iiR+t t=s
s././@PaxHeaderR~R�RR�R�(R�titemsRR�RJR RtbytesR�R�R�R(R	R�R�R$tbinarytkeywordtvaluetrecordsR6R3R)R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s<
	

	
1


cCs2t|�dkr!td��nt|�tkrBtd��n|jt�tkrftd��nt|dd!�}|t|�kr�t	d��n|�}t
|dd!||�|_t|dd	!�|_t|d	d
!�|_
t|d
d!�|_t|dd!�|_t|dd!�|_||_|dd
!|_t
|d
d!||�|_t
|dd!||�|_t
|dd!||�|_t|dd!�|_t|dd!�|_t
|dd!||�}|jtkr|jjd�rt|_n|jtkr�d}g}x|td�D]n}	y6t|||d!�}
t||d|d!�}Wntk
r�PnX|j|
|f�|d7}q4Wt|d�}t|dd!�}
|||
f|_ n|j!�r|jj"d�|_n|r.|jt#kr.|d|j|_n|S(sAConstruct a TarInfo object from a 512 byte bytes object.
        isempty headerstruncated headersend of file headeri�i�sbad checksumidiliti|i�i�ii	i)iIiQiYi�R�i�iiii�i�i�($R RoR�RptcountR!RqR5RHR0R*R~RaRRRRR�R�R�RRR�R�tAREGTYPER�R�tGNUTYPE_SPARSER1R/R_tboolR�tisdirtrstript	GNU_TYPES(R	RER$R%R�tobjR�R�tstructsR4R�tnumbytest
isextendedtorigsize((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytfrombuf�sZ		!
cCsP|jjt�}|j||j|j�}|jj�t|_|j|�S(sOReturn the next TarInfo object from TarFile object
           tarfile.
        (	R�RKR�R$R$R%R�R�t_proc_member(R	R�RER((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytfromtarfilescCst|jttfkr"|j|�S|jtkr>|j|�S|jtttfkrc|j	|�S|j
|�SdS(sYChoose the right processing method depending on
           the type and call it.
        N(R�R�R�t
_proc_gnulongRt_proc_sparseRRtSOLARIS_XHDTYPEt	_proc_paxt
_proc_builtin(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR%s


cCsx|jj�|_|j}|j�s6|jtkrO||j|j�7}n||_|j	|j
|j|j�|S(sfProcess a builtin type or an unknown type which
           will be treated as a regular file.
        (
R�R�R�tisregR�tSUPPORTED_TYPESt_blockRR�t_apply_pax_infoR�R$R%(R}R�R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR+$s		cCs�|jj|j|j��}y|j|�}Wntk
rPtd��nX|j|_|jt	kr�t
||j|j�|_
n-|jtkr�t
||j|j�|_n|S(sSProcess the blocks that hold a GNU longname
           or longlink member.
        s missing or bad subsequent header(R�RKR.RR&RnRrR�R�R�R*R$R%R~R�R�(R}R�REtnext((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR'5s
c
Cs|j\}}}|`x�|r�|jjt�}d}x�td�D]}}y6t|||d!�}t||d|d!�}	Wntk
r�PnX|r�|	r�|j||	f�n|d7}qFWt|d�}qW||_	|jj
�|_|j|j|j
�|_||_
|S(s8Process a GNU sparse header plus extra headers.
        iiiii�(R�R�RKR�R1R5R/R_RR�R�R�R.RR�(
R}R�R R"R#RER�R4R�R!((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR(Ks(	
		cCs�|jj|j|j��}|jtkr9|j}n|jj�}tj	d|�}|dk	r�|jd�jd�|d<n|j
d�}|dkr�|j}nd}tjd�}d}x�tr�|j||�}|s�Pn|j�\}	}
t|	�}	||jd�d|jd�|	d!}|j|
dd|j�}
|
tkr}|j|||j|j�}n|j|dd|j�}|||
<||	7}q�Wy|j|�}Wntk
r�td	��nXd
|kr|j||�nbd|kr$|j|||�n@|j
d�d
krd|j
d�dkrd|j|||�n|jtt fkr�|j!||j|j�|j"|_"d|kr�|j#}
|j$�s�|jt%kr�|
|j|j�7}
n|
|_"q�n|S(sVProcess an extended or global header as described in
           POSIX.1-2008.
        s\d+ hdrcharset=([^\n]+)\niRt
hdrcharsettBINARYs(\d+) ([^=]+)=iis missing or bad subsequent headersGNU.sparse.mapsGNU.sparse.sizesGNU.sparse.majorRsGNU.sparse.minorRRN(&R�RKR.RR�RR�R�tretsearchRItgroupR(RR$tcompileRJtmatchtgroupsR.tendR�t_decode_pax_fieldR%tPAX_NAME_FIELDSR&RnRrt_proc_gnusparse_01t_proc_gnusparse_00t_proc_gnusparse_10RR)R/R�R�R,R-(R}R�RER�R7R1R$tregexR�R#RRR0R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR*gs`	+	

*	cCs�g}x6tjd|�D]"}|jt|jd���qWg}x6tjd|�D]"}|jt|jd���qXWtt||��|_dS(s?Process a GNU tar extended sparse header, version 0.0.
        s\d+ GNU.sparse.offset=(\d+)\nis\d+ GNU.sparse.numbytes=(\d+)\nN(R3tfinditerR_R.R5tlisttzipR�(R}R0R�REtoffsetsR7R!((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR=�s  cCsbg|djd�D]}t|�^q}tt|ddd�|ddd���|_dS(s?Process a GNU tar extended sparse header, version 0.1.
        sGNU.sparse.mapt,Nii(tsplitR.RARBR�(R}R0R�RR�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR<�s,cCs�d}g}|jjt�}|jdd�\}}t|�}xjt|�|dkr�d|kr�||jjt�7}n|jdd�\}}|jt|��qEW|jj�|_	t
t|ddd�|ddd���|_dS(s?Process a GNU tar extended sparse header, version 1.0.
        s
iiN(
RIR�RKR�RER.R R_R�R�RARBR�(R}R0R�R�tfieldsR�REtnumber((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR>�scCsx�|j�D]�\}}|dkr8t|d|�q
|dkr]t|dt|��q
|dkr�t|dt|��q
|tkr
|tkr�yt||�}Wq�tk
r�d}q�Xn|dkr�|jd�}nt|||�q
q
W|j�|_dS(	soReplace fields with supplemental information from a previous
           pax extended or global header.
        sGNU.sparse.nameRsGNU.sparse.sizeRsGNU.sparse.realsizeiR�N(	RtsetattrR.t
PAX_FIELDStPAX_NUMBER_FIELDSR/RR�R�(R}R�R$R%RR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR/�s"

cCs9y|j|d�SWntk
r4|j||�SXdS(s1Decode a single field from a pax record.
        R,N(R(tUnicodeDecodeError(R}RR$tfallback_encodingtfallback_errors((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR:s
cCs0t|t�\}}|r(|d7}n|tS(s_Round up a byte count by BLOCKSIZE and return it,
           e.g. _block(834) => 1024.
        i(RMR�(R}RRRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR.
s
cCs
|jtkS(N(R�t
REGULAR_TYPES(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR,scCs
|j�S(N(R,(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisfilescCs
|jtkS(N(R�R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRscCs
|jtkS(N(R�tSYMTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytissymscCs
|jtkS(N(R�tLNKTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytislnkscCs
|jtkS(N(R�tCHRTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytischr scCs
|jtkS(N(R�tBLKTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisblk"scCs
|jtkS(N(R�tFIFOTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisfifo$scCs
|jdk	S(N(R�RI(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytissparse&scCs|jtttfkS(N(R�RTRVRX(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisdev(s(R~RaRRRRR�R�R�RRR�R�R�R�R�R�R�R�R�(3RgRhRit	__slots__RR�R�tpropertyRR�R�RR�R�tDEFAULT_FORMATtENCODINGR�R�R�R�tclassmethodR
R�tstaticmethodR�RR�RR$R&R%R+R'R(R*R=R<R>R/R:R.R,RORRQRSRURWRYRZR[(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�s`							
		1	
3?	
				f																c
Bs-eZdZdZeZeZdZeZ	e
Zd1Z
eZeZd1dd1d1d1d1d1d1dd1d1d1d�Zed1dd1ed��Zedd1d��Zedd1dd	��Zedd1dd
��Zidd6d
d6dd6Zd�Zd�Zd�Zd�Zd1d1d1d�Zed�Z d1ed1d1d�Z!d1d�Z"dd1d�Z#ded�Z$d�Z%ed�Z&d�Z'd �Z(d!�Z)d"�Z*d#�Z+d$�Z,d%�Z-d&�Z.d'�Z/d(�Z0d1ed)�Z1d*�Z2d1d+�Z3d,�Z4d-�Z5d.�Z6d/�Z7d0�Z8RS(2s=The TarFile Class provides an interface to tar archives.
    iiRYR�c
Cs�t|�dks|dkr-td��n||_idd6dd6dd	6||_|s�|jdkr�tjj|�r�d	|_d|_nt||j�}t|_	nN|d
kr�t|d
�r�|j}nt|d�r�|j|_nt
|_	|rtjj|�nd
|_||_|d
k	rC||_n|d
k	r[||_n|d
k	rs||_n|d
k	r�||_n|d
k	r�||_n|	|_|
d
k	r�|jtkr�|
|_n	i|_|d
k	r�||_n|d
k	r||_nt|_g|_t|_|jj�|_i|_y9|jdkrod
|_ |j!�|_ n|jdkrx�t
r|jj"|j�y&|jj#|�}|jj$|�Wq�t%k
r�|jj"|j�Pq�t&k
r}
t't(|
���q�Xq�Wn|jdkrzt
|_|jrz|jj)|jj*��}|jj+|�|jt|�7_qznWn,|j	s�|jj,�nt
|_�nXd
S(s�Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
           read from an existing archive, 'a' to append data to an existing
           file or 'w' to create a new file overwriting an existing one. `mode'
           defaults to 'r'.
           If `fileobj' is given, it is used for reading or writing data. If it
           can be determined, `mode' is overridden by `fileobj's mode.
           `fileobj' is not closed, when TarFile is closed.
        iR�smode must be 'r', 'a' or 'w'trbRYsr+btatwbRZR~RatawN(-R R/Rat_modeRuRtexistst	bltn_openR�R�RIRzR~RJtabspathR�R>R�tdereferencetignore_zerosR$R%R�R�tdebugt
errorlevelR�tmemberst_loadedR�R�tinodestfirstmemberR0R�R&R_RqRnRkRR
R�RLR�(R}R~RaR�R>R�RjRkR$R%R�RlRmteRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRFs�	""		!									
				c
Ks4|r|rtd��n|dkr�x�|jD]�}t||j|�}|dk	rj|j�}ny||d||�SWq3ttfk
r�}	|dk	r3|j|�q3q3q3Xq3Wtd��nUd|krV|jdd�\}
}|
p�d}
|pd}||jkr3t||j|�}ntd|��|||
||�Sd	|kr|jd	d�\}
}|
p�d}
|p�d}|
d
kr�td��nt	||
|||�}y|||
||�}Wn|j
��nXt|_|S|dkr$|j
||||�Std
��dS(s|Open a tar archive for reading, writing or appending. Return
           an appropriate TarFile class.

           mode:
           'r' or 'r:*' open for reading with transparent compression
           'r:'         open for reading exclusively uncompressed
           'r:gz'       open for reading with gzip compression
           'r:bz2'      open for reading with bzip2 compression
           'a' or 'a:'  open for appending, creating the file if necessary
           'w' or 'w:'  open for writing without compression
           'w:gz'       open for writing with gzip compression
           'w:bz2'      open for writing with bzip2 compression

           'r|*'        open a stream of tar blocks with transparent compression
           'r|'         open an uncompressed stream of tar blocks for reading
           'r|gz'       open a gzip compressed stream of tar blocks
           'r|bz2'      open a bzip2 compressed stream of tar blocks
           'w|'         open an uncompressed stream for writing
           'w|gz'       open a gzip compressed stream for writing
           'w|bz2'      open a bzip2 compressed stream for writing
        snothing to openRYsr:*s%file could not be opened successfullyt:iR�sunknown compression type %rt|trwsmode must be 'r' or 'w'Resundiscernible modeN(RYsr:*(R/t	OPEN_METHR�RIR�RkRlR�RER�R�R�R�ttaropen(
R	R~RaR�R�tkwargsR�tfunct	saved_posRrRftstreamR[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR{�sN
	cKs@t|�dks|dkr-td��n|||||�S(sCOpen uncompressed tar archive name for reading or writing.
        iR�smode must be 'r', 'a' or 'w'(R R/(R	R~RaR�Rx((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRw�si	c	Ks6t|�dks|dkr-td��nyddl}|jWn#ttfk
ritd��nX|dk	}y8|j||d||�}|j||||�}Wnxt	k
r�|r�|dk	r�|j
�n|dkr��ntd��n*|r"|dk	r"|j
�n�nX||_|S(	skOpen gzip compressed tar archive name for reading or writing.
           Appending is not allowed.
        iRusmode must be 'r' or 'w'i����Nsgzip module is not availableRTsnot a gzip file(
R R/tgziptGzipFileR�tAttributeErrorRlRIRwRNR�RkR�(	R	R~RaR�t
compresslevelRxR|t
extfileobjR[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytgzopens.


	cKs�t|�dks|dkr-td��nyddl}Wntk
r\td��nX|dk	r{t||�}n|j||d|�}y|j||||�}Wn-t	t
fk
r�|j�td��nXt
|_|S(	slOpen bzip2 compressed tar archive name for reading or writing.
           Appending is not allowed.
        iRusmode must be 'r' or 'w'.i����Nsbz2 module is not availableRsnot a bzip2 file(R R/R�R�RlRIR�tBZ2FileRwRNtEOFErrorR�RkR�R�(R	R~RaR�RRxR�R[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytbz2open$s 

	RwR�R�R�R�R�cCs�|jr
dS|jdkr�|jjttd�|jtd7_t|jt�\}}|dkr�|jjtt|�q�n|j	s�|jj
�nt|_dS(slClose the TarFile. In write-mode, two finishing zero blocks are
           appended to the archive.
        NReii(R�RaR�RLR!R�R�RMt
RECORDSIZER�R�RJ(R}RRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�Hs		cCs2|j|�}|dkr.td|��n|S(sReturn a TarInfo object for member `name'. If `name' can not be
           found in the archive, KeyError is raised. If a member occurs more
           than once in the archive, its last occurrence is assumed to be the
           most up-to-date version.
        sfilename %r not foundN(t
_getmemberRItKeyError(R}R~R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt	getmember\scCs'|j�|js |j�n|jS(s�Return the members of the archive as a list of TarInfo objects. The
           list has the same order as the members in the archive.
        (t_checkRot_loadRn(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt
getmembersgs
	
cCs g|j�D]}|j^q
S(s�Return the members of the archive as a list of their names. It has
           the same order as the list returned by getmembers().
        (R�R~(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytgetnamesqscCs\|jd�|d	k	r%|j}n|d	kr:|}ntjj|�\}}|jtjd�}|jd�}|j	�}||_
|d	kr�ttd�r�|jr�tj
|�}q�tj|�}ntj|j��}d}|j}tj|�r�|j|jf}	|jrj|jdkrj|	|jkrj||j|	krjt}
|j|	}qt}
|	dr||j|	<qn�tj|�r�t}
nstj|�r�t}
n[tj|�r�t}
tj|�}n4tj |�r�t!}
ntj"|�rt#}
nd	S||_||_$|j%|_&|j'|_(|
tkr]|j)|_*n	d|_*|j+|_,|
|_-||_.t/r�yt/j0|j&�d|_1Wq�t2k
r�q�Xnt3r�yt3j4|j(�d|_5Wq�t2k
r�q�Xn|
t!t#fkrXttd�rXttd�rXtj6|j7�|_8tj9|j7�|_:qXn|S(
sOCreate a TarInfo object for either the file `name' or the file
           object `fileobj' (using os.fstat on its file descriptor). You can
           modify some of the TarInfo's attributes before you add it using
           addfile(). If given, `arcname' specifies an alternative name for the
           file in the archive.
        ReR�tlstatR]iitmajortminorN(;R�RIR~RuRt
splitdriveR�tseptlstripR�R�RzRjR�tstattfstattfilenotst_modetS_ISREGtst_inotst_devtst_nlinkRpRRR�tS_ISDIRR�tS_ISFIFORXtS_ISLNKRPtreadlinktS_ISCHRRTtS_ISBLKRVRatst_uidRtst_gidRtst_sizeRtst_mtimeRR�R�tpwdtgetpwuidRR�tgrptgetgrgidRR�tst_rdevR�R�R�(R}R~tarcnameR�tdrvR�tstatresR�tstmdtinodeR�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt
gettarinfows~
			"
									

cCsp|j�x_|D]W}|r�tt|j�dd�td|jpK|j|jpZ|jfdd�|j�s�|j	�r�tdd|j
|jfdd�ntd|jdd�tdt
j|j�d dd�nt|j|j�rd	nd
dd�|ra|j�r9td|jdd�n|j�ratd|jdd�qant�qWd
S(s�Print a table of contents to sys.stdout. If `verbose' is False, only
           the names of the members are printed. If it is True, an `ls -l'-like
           output is produced.
        R9Rs%s/%ss%10ss%d,%ds%10ds%d-%02d-%02d %02d:%02d:%02diR�R]s->slink toN(R�tprintRfRaRRRRRURWR�R�RR�t	localtimeRR~RRQR�RS(R}tverboseR�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRA�s&

	!)c	Cs�|jd�|dkr"|}n|dk	rtddl}|jdtd�||�rt|jdd|�dSn|jdk	r�tjj	|�|jkr�|jdd|�dS|jd|�|j
||�}|dkr�|jdd	|�dS|dk	r;||�}|dkr;|jdd|�dSn|j�rst|d
�}|j
||�|j�n�|j�r�|j
|�|r�xTtj|�D]@}|jtjj||�tjj||�||d|�q�Wq�n
|j
|�dS(s~Add the file `name' to the archive. `name' may be any type of file
           (directory, fifo, symbolic link, etc.). If given, `arcname'
           specifies an alternative name for the file in the archive.
           Directories are added recursively by default. This can be avoided by
           setting `recursive' to False. `exclude' is a function that should
           return True for each filename to be excluded. `filter' is a function
           that expects a TarInfo object argument and returns the changed
           TarInfo object, if it returns None the TarInfo object will be
           excluded from the archive.
        Rei����Nsuse the filter argument insteadistarfile: Excluded %rstarfile: Skipped %ristarfile: Unsupported type %rRbtfilter(R�RItwarningstwarntDeprecationWarningt_dbgR~RuRRiR�R,RhtaddfileR�RtlistdirtaddR`(	R}R~R�t	recursivetexcludeR�R�R�tf((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��sD
		
*

*cCs�|jd�tj|�}|j|j|j|j�}|jj|�|jt	|�7_|dk	r�t||j|j�t
|jt�\}}|dkr�|jjtt|�|d7}n|j|t7_n|jj|�dS(s]Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
           given, tarinfo.size bytes are read from it and added to the archive.
           You can create TarInfo objects using gettarinfo().
           On Windows platforms, `fileobj' should always be opened with mode
           'rb' to avoid irritation about the file size.
        ReiiN(R�R�R�R>R$R%R�RLR�R RIRURRMR�R!RnR_(R}R�R�RERRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�4s

t.cCs:g}|dkr|}nx_|D]W}|j�r\|j|�tj|�}d|_n|j||d|j��q"W|jdd��|j�x�|D]�}tj	j
||j�}y4|j||�|j
||�|j||�Wq�tk
r1}|jdkr�q2|jdd|�q�Xq�WdS(sMExtract all members from the archive to the current working
           directory and set owner, modification time and permissions on
           directories afterwards. `path' specifies a different directory
           to extract to. `members' is optional and must be a subset of the
           list returned by getmembers().
        i�t	set_attrstkeycSs|jS(N(R~(Rc((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt<lambda>dR]istarfile: %sN(RIRR_R�RatextracttsorttreverseRuRR`R~tchowntutimetchmodRjRmR�(R}RRntdirectoriesR�tdirpathRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt
extractallNs*	

!

R]cCs=|jd�t|t�r.|j|�}n|}|j�r^tjj||j�|_	ny,|j
|tjj||j�d|�Wn�tk
r�}|j
dkr��q9|jdkr�|jdd|j�q9|jdd|j|jf�n<tk
r8}|j
dkr!�q9|jdd|�nXdS(sxExtract a member from the archive to the current working directory,
           using its full name. Its file information is extracted as accurately
           as possible. `member' may be a filename or a TarInfo object. You can
           specify a different directory using `path'. File attributes (owner,
           mtime, mode) are set unless `set_attrs' is False.
        RYR�iistarfile: %sstarfile: %s %rN(R�RRR�RSRuRR`R�R�t_extract_memberR~tEnvironmentErrorRmtfilenameRIR�tstrerrorRj(R}tmemberRR�R�Rr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�ts&
!#cCs�|jd�t|t�r.|j|�}n|}|j�rP|j||�S|jtkro|j||�S|j�s�|j	�r�t|j
t�r�td��q�|j
|j|��SndSdS(s�Extract a member from the archive as a file object. `member' may be
           a filename or a TarInfo object. If `member' is a regular file, a
           file-like object is returned. If `member' is a link, a file-like
           object is constructed from the link's target. If `member' is none of
           the above, None is returned.
           The file-like object is read-only and provides the following
           methods: read(), readline(), readlines(), seek() and tell()
        RYs'cannot extract (sym)link as file objectN(R�RRR�R,t
fileobjectR�R-RSRQR�R�Rmtextractfilet_find_link_targetRI(R}R�R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s	
cCs�|jd�}|jdtj�}tjj|�}|r_tjj|�r_tj|�n|j�sw|j	�r�|j
dd|j|jf�n|j
d|j�|j
�r�|j||�n�|j�r�|j||�n�|j�r
|j||�n�|j�s"|j�r5|j||�n]|j�sM|j	�r`|j||�n2|jtkr�|j||�n|j||�|r�|j||�|j	�s�|j||�|j||�q�ndS(s\Extract the TarInfo object tarinfo to a physical
           file called targetpath.
        R�is%s -> %sN(RR�RuR�RtdirnameRgtmakedirsRSRQR�R~R�R,tmakefileRtmakedirRYtmakefifoRURWtmakedevtmakelinkR�R-tmakeunknownR�R�R�(R}R�t
targetpathR�t	upperdirs((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s4#cCsFytj|d�Wn+tk
rA}|jtjkrB�qBnXdS(s,Make a directory called targetpath.
        i�N(RutmkdirR�terrnotEEXIST(R}R�R�Rr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s
cCs�|j}|j|j�t|d�}|jdk	rqxJ|jD])\}}|j|�t|||�qAWnt|||j�|j|j�|j�|j	�dS(s'Make a file called targetpath.
        RdN(
R�R�R�RhR�RIRURttruncateR�(R}R�R�tsourcettargetR�R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��s	

cCs+|j||�|jdd|j�dS(sYMake a file from a TarInfo object with an unknown type
           at targetpath.
        is9tarfile: Unknown file type %r, extracted as regular file.N(R�R�R�(R}R�R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�	scCs/ttd�rtj|�ntd��dS(s'Make a fifo called targetpath.
        tmkfifosfifo not supported by systemN(RzRuR�Rj(R}R�R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�	scCs�ttd�s ttd�r/td��n|j}|j�rT|tjO}n
|tjO}tj||tj	|j
|j��dS(s<Make a character or block device called targetpath.
        tmknodR�s'special devices not supported by systemN(RzRuRjRaRWR�tS_IFBLKtS_IFCHRR�R�R�R�(R}R�R�Ra((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�	s 	
cCs�yj|j�r%tj|j|�nDtjj|j�rPtj|j|�n|j|j	|�|�WnPt
k
r�|j�r�tjjtjj|j
�|j�}q�|j}n>Xy|j|j	|�|�Wntk
r�td��nXdS(s�Make a (symbolic) link called targetpath. If it cannot be created
          (platform limitation), we try to make a copy of the referenced file
          instead of a link.
        s%unable to resolve link inside archiveN(RQRutsymlinkR�RRgR�tlinkR�R�tsymlink_exceptionR`R�R~R�Rj(R}R�R�R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�'	s"


cCstrttd�rtj�dkrytj|j�d}Wntk
r]|j}nXytj	|j
�d}Wntk
r�|j}nXyZ|j�r�ttd�r�tj
|||�n%tjdkr�tj|||�nWqtk
r}td��qXndS(s6Set owner of targetpath according to tarinfo.
        tgeteuidiitlchowntos2emxscould not change ownerN(R�RzRuR�R�tgetgrnamRR�RtgetpwnamRRRQR�tsystplatformR�R�Rj(R}R�R�RtuRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�D	s '



cCsOttd�rKytj||j�WqKtk
rG}td��qKXndS(sASet file permissions of targetpath according to tarinfo.
        R�scould not change modeN(RzRuR�RaR�Rj(R}R�R�Rr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�Z	s
cCsYttd�sdSy tj||j|jf�Wntk
rT}td��nXdS(sBSet modification time of targetpath according to tarinfo.
        R�Ns"could not change modification time(RzRuR�RR�Rj(R}R�R�Rr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�c	s cCs�|jd�|jdk	r2|j}d|_|S|jj|j�d}xktr�y|jj|�}WnGt	k
r�}|j
r�|jdd|j|f�|jt7_qNq�n�t
k
r+}|j
r|jdd|j|f�|jt7_qNq�|jdkr�tt|���q�n�tk
rY|jdkr�td��q�n[tk
r�}|jdkr�tt|���q�n%tk
r�}tt|���nXPqNW|dk	r�|jj|�n	t|_|S(s�Return the next member of the archive as a TarInfo object, when
           TarFile is opened for reading. Return None if there is no more
           available.
        trais0x%X: %sis
empty fileN(R�RqRIR�R�R�RJR�R&RqRkR�R�R0RkRRoRpRrRnR_Ro(R}tmR�Rr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR0n	sF
						
	cCs�|j�}|dk	r.||j|� }n|rItjj|�}nxKt|�D]=}|rztjj|j�}n	|j}||krV|SqVWdS(s}Find an archive member by name from bottom to top.
           If tarinfo is given, it is used as the starting point.
        N(R�RItindexRuRtnormpathtreversedR~(R}R~R�t	normalizeRnR�tmember_name((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	s	cCs6x&tr(|j�}|dkrPqqWt|_dS(sWRead through the entire archive file and look for readable
           members.
        N(RJR0RIRo(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	s
	cCsW|jr"td|jj��n|dk	rS|j|krStd|j��ndS(snCheck if TarFile is still open, and if the operation's mode
           corresponds to TarFile's mode.
        s%s is closedsbad operation for mode %rN(R�RNR�RgRIRa(R}Ra((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	s	cCs�|j�r5tjj|j�d|j}d}n|j}|}|j|d|dt�}|dkr~t	d|��n|S(sZFind the target member of a symlink or hardlink member in the
           archive.
        R�R�R�slinkname %r not foundN(
RQRuRR�R~R�RIR�RJR�(R}R�R�tlimitR�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	s 		cCs$|jrt|j�St|�SdS(s$Provide an iterator object.
        N(RotiterRntTarIter(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	s	
cCs)||jkr%t|dtj�ndS(s.Write debugging output to sys.stderr.
        tfileN(RlR�R�tstderr(R}tleveltmsg((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	scCs|j�|S(N(R�(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt	__enter__�	s
cCs?|dkr|j�n"|js2|jj�nt|_dS(N(RIR�R�R�RJR�(R}R�Rt	traceback((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__exit__�	s

	N(9RgRhRiRlR�RjRkRmR^R>R_R$RIR%RR�R�R�RR`R�R{RwR�R�RvR�R�R�R�R�RJRAR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R0R�R�R�R�R�R�RR(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR,sniK
			
	b>&#	&0											1	
					R�cBs/eZdZd�Zd�Zd�ZeZRS(sMIterator Class.

       for tarinfo in TarFile(...):
           suite...
    cCs||_d|_dS(s$Construct a TarIter object.
        iN(R�R�(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR
s	cCs|S(s Return iterator object.
        ((R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR�
scCs}|jjs9|jj�}|sjt|j_t�qjn1y|jj|j}Wntk
rit�nX|jd7_|S(s�Return the next item using TarFile's next() method.
           When all members have been read, set TarFile as _loaded.
        i(R�RoR0RJt
StopIterationRnR�t
IndexError(R}R�((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__next__

s

(RgRhRiRR�RR0(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR��	s
			cCs7yt|�}|j�tSWntk
r2tSXdS(sfReturn True if name points to a tar archive that we
       are able to handle, else return False.
    N(R{R�RJRR�(R~R[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR#
s

(xt
__future__Rt__version__tversiont
__author__t__date__t	__cvsid__t__credits__R�RuR�R�R�R8R�R3R�R�R�RIR~tNotImplementedErrorR�tWindowsErrort	NameErrort__all__tversion_infot__builtin__tbuiltinsR{t_openR!R�R�R�R�R�R�RR�RRRRPRTRVR�RXtCONTTYPER�R�RRRR)R�R7R�R^R-RNRRItsetR;RR.RJtS_IFLNKtS_IFREGR�tS_IFDIRR�tS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECR~R_tgetfilesystemencodingR&R*R5R?RHRUR^Rft	ExceptionRRjRkRlRmRnRoRpRqR0RrtobjectRsR�R�R�R�R�RRR�RRh(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt<module>s.

	
					
					
					
	
	
		�?K��������*