Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/tarfile.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c
@s=dZdZdZdZdZdZdZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZyddlZddlZWnek
r�eZZnXd	d
ddgZd
ZdZedZdZdZdZdZdZdZd
ZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*d Z+d!Z,d"Z-d#Z.d$Z/e.Z0eee e!e$e%e&e"e#e'e(e)fZ1eee&e)fZ2e'e(e)fZ3d%d&d'd(d)d*d+d,fZ4ie5d-6e5d.6e5d(6e6d)6e6d*6e6d'6Z7d/Z8d0Z9d1Z:d2Z;d3Z<d4Z=d5Z>d6Z?dZ@d7ZAd8ZBd9ZCd:ZDd;ZEd<ZFd=ZGd$ZHd#ZIejJ�ZKeKekr�ejL�ZKnd>�ZMd?�ZNd@�ZOd<e0dA�ZPdB�ZQdC�ZRedD�ZSe8dEfe9dFfe:dGfe;dHfe<dIfe=dJffeAdKffeBdLffeCe>BdMfe>dfeCdffeDdKffeEdLffeFe?BdMfe?dfeFdffeGdKffeHdLffeIe@BdNfe@dOfeIdfff
ZTdP�ZUdeVfdQ��YZWdReWfdS��YZXdTeWfdU��YZYdVeWfdW��YZZdXeWfdY��YZ[dZeWfd[��YZ\d\e\fd]��YZ]d^e\fd_��YZ^d`e\fda��YZ_dbe\fdc��YZ`dde\fde��YZadffdg��YZbdhfdi��YZcdjedfdk��YZedledfdm��YZfdnedfdo��YZgdpedfdq��YZhd
edfdr��YZid	edfds��YZjdtfdu��YZkdvfdw��YZldxelfdy��YZmdzelfd{��YZnd|eofd}��YZpd"Zqd<Zrd~fd��YZsd��ZteuZvejjuZudS(�s,Read from and write to tar format archives.
s$Revision: 85213 $s0.9.0s!Lars Gust�l ([email protected])s$Date$s$Id$s3Gustavo Niemeyer, Niels Gust�l, Richard Townsend.i�NtTarFiletTarInfot
is_tarfiletTarErrortiisustar  tustar00idi�t0t1t2t3t4t5t6t7tLtKtStxtgtXiiitpathtlinkpathtsizetmtimetuidtgidtunametgnametatimetctimei�i�i`i@i iiiii�i@i iiicCs|| |t|�tS(s@Convert a python string to a null-terminated string buffer.
    (tlentNUL(tstlength((s/sys/lib/python2.7/tarfile.pytstn�scCs'|jd�}|dkr|S|| S(s?Convert a null-terminated string field to a python string.
    Ri�(tfind(R tp((s/sys/lib/python2.7/tarfile.pytnts�scCs�|dtd�krXytt|�p+dd�}Wq�tk
rTtd��q�XnId}x@tt|�d�D](}|dK}|t||d�7}quW|S(s/Convert a number field to a python number.
    ii�Risinvalid headerli(tchrtintR%t
ValueErrortInvalidHeaderErrortxrangeRtord(R tnti((s/sys/lib/python2.7/tarfile.pytnti�s

cCs�d|kod|dknr?d|d|ft}n�|tks_|d|dkrntd��n|dkr�tjdtjd|��d}nd	}x6t|d�D]$}t|d
@�|}|dL}q�Wtd�|}|S(s/Convert a python number to a number field.
    iiis%0*oisoverflow in number fieldRtlti�i�(Rt
GNU_FORMATR(tstructtunpacktpackR*R&(R,tdigitstformatR R-((s/sys/lib/python2.7/tarfile.pytitn�s	$ %cCs�|dkr�y|j|d�SWq�tk
r�g}xU|D]M}y|j|j|d��Wq=tk
r�|j|jd��q=Xq=Wdj|�SXn|j||�SdS(s*Convert a unicode object to a string.
    sutf-8tstricttutf8R0N(tencodetUnicodeEncodeErrortappendtjoin(R tencodingterrorsRtc((s/sys/lib/python2.7/tarfile.pytuts�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(tsumR2R3(tbuftunsigned_chksumt
signed_chksum((s/sys/lib/python2.7/tarfile.pytcalc_chksums�s	77cCs�|dkrdS|dkr0tj||�dSd}t||�\}}xQt|�D]C}|j|�}t|�|kr�td��n|j|�qXW|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@(	tNonetshutiltcopyfileobjtdivmodR*treadRtIOErrortwrite(tsrctdstR!tBUFSIZEtblockst	remaindertbRG((s/sys/lib/python2.7/tarfile.pyRMs$R/t-RWtdR@R$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()
    RXR0(tfilemode_tableR<R=(tmodetpermttabletbittchar((s/sys/lib/python2.7/tarfile.pytfilemode6s

cBseZdZRS(sBase exception.(t__name__t
__module__t__doc__(((s/sys/lib/python2.7/tarfile.pyREstExtractErrorcBseZdZRS(s%General exception for extract errors.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRhHst	ReadErrorcBseZdZRS(s&Exception for unreadable tar archives.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRiKstCompressionErrorcBseZdZRS(s.Exception for unavailable compression methods.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRjNstStreamErrorcBseZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRkQstHeaderErrorcBseZdZRS(s!Base exception for header errors.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRlTstEmptyHeaderErrorcBseZdZRS(sException for empty headers.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRmWstTruncatedHeaderErrorcBseZdZRS(s Exception for truncated headers.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRnZstEOFHeaderErrorcBseZdZRS(s"Exception for end of file headers.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRo]sR)cBseZdZRS(sException for invalid headers.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyR)`stSubsequentHeaderErrorcBseZdZRS(s3Exception for missing and invalid extended headers.(ReRfRg(((s/sys/lib/python2.7/tarfile.pyRpcst
_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(NRZR[tO_BINARYi�(	tostO_RDONLYtO_WRONLYtO_CREATtO_TRUNCthasattrRrtopentfd(tselftnameR_((s/sys/lib/python2.7/tarfile.pyt__init__ps
cCstj|j�dS(N(RstcloseRz(R{((s/sys/lib/python2.7/tarfile.pyR~yscCstj|j|�S(N(RsRORz(R{R((s/sys/lib/python2.7/tarfile.pyRO|scCstj|j|�dS(N(RsRQRz(R{R ((s/sys/lib/python2.7/tarfile.pyRQs(ReRfRgR}R~RORQ(((s/sys/lib/python2.7/tarfile.pyRqjs
				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|_|dkr&yddl}Wntk
r�td��nX||_|jd�d@|_|d	kr|j�q&|j�n|d
kr�yddl}Wntk
ratd��nX|d	kr�d|_|j�|_q�|j�|_ndS(s$Construct a _Stream object.
        t*R0ltgzi�Nszlib module is not availablel�RZtbz2sbz2 module is not available(tTruet_extfileobjRKRqtFalset_StreamProxytgetcomptypeR|R_tcomptypetfileobjtbufsizeRGtpostclosedtzlibtImportErrorRjtcrc32tcrct
_init_read_gzt_init_write_gzR�tdbuftBZ2Decompressortcmpt
BZ2Compressor(R{R|R_R�R�R�R�R�((s/sys/lib/python2.7/tarfile.pyR}�sD								
	


	cCs*t|d�r&|jr&|j�ndS(NR�(RxR�R~(R{((s/sys/lib/python2.7/tarfile.pyt__del__�scCs�|jjd|jj|jj|jjd�|_tjdtt	j	���}|j
d|�t|j�t
kr�|jjdd�|_n|jjd�r�|jd |_n|j
|jt�d	S(
s6Initialize for writing with gzip compression.
        i	is<Ls�%s�iso-8859-1treplaces.gzi�N(R�tcompressobjtDEFLATEDt	MAX_WBITSt
DEF_MEM_LEVELR�R2R4tlongttimet_Stream__writettypeR|tunicodeR:tendswithR(R{t	timestamp((s/sys/lib/python2.7/tarfile.pyR��s
	cCs{|jdkr1|jj||j�d@|_n|jt|�7_|jdkrj|jj|�}n|j|�dS(s&Write string s to the stream.
        R�l�ttarN(	R�R�R�R�R�RR�tcompressR�(R{R ((s/sys/lib/python2.7/tarfile.pyRQ�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(RGRR�R�RQ(R{R ((s/sys/lib/python2.7/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.
        NR[R�R0R�s<Ll�(R�R_R�RGR�tflushR�RQR2R4R�R�R�R~R�(R{((s/sys/lib/python2.7/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�q��n|d@rUx3t
rQ|jd�}|sJ|tkr"Pq"q"Wn|d@ro|jd�nd
S(s:Initialize for reading a gzip compressed fileobj.
        R0is�not a gzip fileissunsupported compression methodiiiiiN(R�t
decompressobjR�R�R�t
_Stream__readRiRjR+ROR�R(R{tflagtxlenR ((s/sys/lib/python2.7/tarfile.pyR��s.	

,
	
	
cCs|jS(s3Return the stream's file pointer position.
        (R�(R{((s/sys/lib/python2.7/tarfile.pyttellsicCs|||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�RNR�R*RORk(R{R�RURVR-((s/sys/lib/python2.7/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.
        R0N(RKR�t_readR�R<R=R�R(R{RR\RG((s/sys/lib/python2.7/tarfile.pyRO.s	cCs�|jdkr|j|�St|j�}|jg}x||kr�|j|j�}|sbPny|jj|�}Wntk
r�td��nX|j	|�|t|�7}q:Wdj
|�}|||_|| S(s+Return size bytes from the stream.
        R�sinvalid compressed dataR0(R�R�RR�R�R�t
decompressRPRiR<R=(R{RR@R\RG((s/sys/lib/python2.7/tarfile.pyR�@s"



cCs�t|j�}|jg}xL||kri|jj|j�}|sIPn|j|�|t|�7}qWdj|�}|||_|| S(ssReturn size bytes from stream. If internal buffer is empty,
           read another block from the stream.
        R0(RRGR�ROR�R<R=(R{RR@R\RG((s/sys/lib/python2.7/tarfile.pyt__readVs

N(ReRfRgR}R�R�RQR�R~R�R�R�RKROR�R�(((s/sys/lib/python2.7/tarfile.pyR�s		.			
					
	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�ROt	BLOCKSIZERG(R{R�((s/sys/lib/python2.7/tarfile.pyR}ls	cCs|jj|_|jS(N(R�RORG(R{R((s/sys/lib/python2.7/tarfile.pyROpscCsJ|jjd�rdS|jdd!dkrF|jdd!dkrFd	Sd
S(Ns�R�iitBZhii
s1AY&SYR�R�(RGt
startswith(R{((s/sys/lib/python2.7/tarfile.pyR�ts
,cCs|jj�dS(N(R�R~(R{((s/sys/lib/python2.7/tarfile.pyR~{s(ReRfRgR}ROR�R~(((s/sys/lib/python2.7/tarfile.pyR�gs
			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�R_tgetattrRKR|tinit(R{R�R_((s/sys/lib/python2.7/tarfile.pyR}�s		cCsbddl}d|_|jdkrO|j�|_|jjd�d|_n|j�|_dS(Ni�iRZR0(	R�R�R_R�tbz2objR�R�RGR�(R{R�((s/sys/lib/python2.7/tarfile.pyR��s	cCs�|jg}t|j�}x^||kr{|jj|j�}|sIPn|jj|�}|j|�|t|�7}qWdj|�|_|j| }|j||_|j	t|�7_	|S(NR0(
RGRR�ROt	blocksizeR�R�R<R=R�(R{RRWRtrawtdataRG((s/sys/lib/python2.7/tarfile.pyRO�s

cCs4||jkr|j�n|j||j�dS(N(R�R�RO(R{R�((s/sys/lib/python2.7/tarfile.pyR��s
cCs|jS(N(R�(R{((s/sys/lib/python2.7/tarfile.pyR��scCs;|jt|�7_|jj|�}|jj|�dS(N(R�RR�R�R�RQ(R{R�R�((s/sys/lib/python2.7/tarfile.pyRQ�scCs5|jdkr1|jj�}|jj|�ndS(NR[(R_R�R�R�RQ(R{R�((s/sys/lib/python2.7/tarfile.pyR~�si@(ReRfRgR�R}R�ROR�R�RQR~(((s/sys/lib/python2.7/tarfile.pyR�s		
				t_FileInFilecBsSeZdZdd�Zd�Zd�Zdd�Zd�Zd�Z	d�Z
RS(	sA thin wrapper around an existing file object that
       provides a part of its data as an individual file
       object.
    cCs1||_||_||_||_d|_dS(Ni(R�toffsetRtsparsetposition(R{R�R�RR�((s/sys/lib/python2.7/tarfile.pyR}�s
				cCs|jS(s*Return the current file position.
        (R�(R{((s/sys/lib/python2.7/tarfile.pyR��scCs
||_dS(s(Seek to a position in the file.
        N(R�(R{R�((s/sys/lib/python2.7/tarfile.pyR��scCse|dkr|j|j}nt||j|j�}|jdkrT|j|�S|j|�SdS(s!Read data from the file.
        N(RKRR�tminR�t
readnormalt
readsparse(R{R((s/sys/lib/python2.7/tarfile.pyRO�s
cCs9|jj|j|j�|j|7_|jj|�S(s*Read operation for regular files.
        (R�R�R�R�RO(R{R((s/sys/lib/python2.7/tarfile.pyR��scCs\g}xF|dkrN|j|�}|s.Pn|t|�8}|j|�q	Wdj|�S(s)Read operation for sparse files.
        iR0(treadsparsesectionRR<R=(R{RR�RG((s/sys/lib/python2.7/tarfile.pyR��scCs�|jj|j�}|dkr%dSt||j|j|j�}t|t�r�|j	|j|j}|j
j|j|�|j|7_|j
j|�S|j|7_t
|SdS(s0Read a single section of a sparse file.
        R0N(R�R#R�RKR�R�Rt
isinstancet_datatrealposR�R�ROR(R{RtsectionR�((s/sys/lib/python2.7/tarfile.pyR��s N(ReRfRgRKR}R�R�ROR�R�R�(((s/sys/lib/python2.7/tarfile.pyR��s		
		tExFileObjectcBsheZdZdZd�Zdd�Zdd�Zd�Zd�Z	e
jd�Zd	�Z
d
�ZRS(saFile-like object for reading an archive member.
       Is returned by TarFile.extractfile().
    icCsmt|j|j|jt|dd��|_|j|_d|_t|_	|j|_d|_
d|_dS(NR�RZiR0(R�R�toffset_dataRR�RKR|R_R�R�R�tbuffer(R{ttarfilettarinfo((s/sys/lib/python2.7/tarfile.pyR}s				cCs�|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 fileR0N(R�R(R�RKR�RORR�(R{RRG((s/sys/lib/python2.7/tarfile.pyROs			
 i�cCs,|jrtd��nd|jkr@|jjd�d}n�|jg}x�tr�|jj|j�}|j|�|s�d|krOdj	|�|_|jjd�d}|dkr�t
|j�}nPqOqOW|dkr�||�}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
iR0ii�(
R�R(R�R#R�R�ROR�R<R=RR�R�(R{RR�tbuffersRG((s/sys/lib/python2.7/tarfile.pytreadline7s(		

cCs:g}x-tr5|j�}|s%Pn|j|�q	W|S(s0Return a list with all remaining lines.
        (R�R�R<(R{tresulttline((s/sys/lib/python2.7/tarfile.pyt	readlinesVs	cCs|jrtd��n|jS(s*Return the current file position.
        sI/O operation on closed file(R�R(R�(R{((s/sys/lib/python2.7/tarfile.pyR�`s	cCs|jrtd��n|tjkrHtt|d�|j�|_n�|tjkr�|dkrt|j|d�|_q�|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 argumentR0N(
R�R(RstSEEK_SETR�tmaxRR�tSEEK_CURtSEEK_ENDR�R�R�(R{R�twhence((s/sys/lib/python2.7/tarfile.pyR�hs	!(	cCs
t|_dS(sClose the file object.
        N(R�R�(R{((s/sys/lib/python2.7/tarfile.pyR~}sccs,x%tr'|j�}|sPn|VqWdS(s/Get an iterator over the file's lines.
        N(R�R�(R{R�((s/sys/lib/python2.7/tarfile.pyt__iter__�s
	N(ReRfRgR�R}RKROR�R�R�RsR�R�R~R�(((s/sys/lib/python2.7/tarfile.pyR�s	
	
		cBs�eZdZdd�Zd�Zd�Zeee�Zd�Zd�Z	eee	�Z
d�Zd�Ze
ed	d
�Zd�Zd�Zd
�Zed��Zd�Zed��Zed��Zed��Zeed��Zed��Zed��Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd �Z(d!�Z)d"�Z*d#�Z+d$�Z,d%�Z-d&�Z.RS('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.
    R0cCs�||_d|_d|_d|_d|_d|_d|_t|_d|_	d|_
d|_d|_d|_
d|_d|_i|_dS(sXConstruct a TarInfo object. name is the optional name
           of the member.
        i�iR0N(R|R_RRRRtchksumtREGTYPER�tlinknameRRtdevmajortdevminorR�R�tpax_headers(R{R|((s/sys/lib/python2.7/tarfile.pyR}�s 															cCs|jS(N(R|(R{((s/sys/lib/python2.7/tarfile.pyt_getpath�scCs
||_dS(N(R|(R{R|((s/sys/lib/python2.7/tarfile.pyt_setpath�scCs|jS(N(R�(R{((s/sys/lib/python2.7/tarfile.pyt_getlinkpath�scCs
||_dS(N(R�(R{R�((s/sys/lib/python2.7/tarfile.pyt_setlinkpath�scCs d|jj|jt|�fS(Ns<%s %r at %#x>(t	__class__ReR|tid(R{((s/sys/lib/python2.7/tarfile.pyt__repr__�scCsi
|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<nxAdD]9}t||�tkr�||j||�||<q�q�W|S(s9Return the TarInfo's attributes as a dictionary.
        R|i�R_RRRRR�R�R�RRR�R�t/(snameslinknamesunamesgname(R|R_RRRRR�R�R�RRR�R�tDIRTYPER�R�R:(R{R>R?tinfotkey((s/sys/lib/python2.7/tarfile.pytget_info�s(











$
!R8cCss|j||�}|tkr+|j|�S|tkrD|j|�S|tkrc|j|||�Std��dS(s<Return a tar header as a string of 512 byte blocks.
        sinvalid formatN(R�tUSTAR_FORMATtcreate_ustar_headerR1tcreate_gnu_headert
PAX_FORMATtcreate_pax_headerR((R{R6R>R?R�((s/sys/lib/python2.7/tarfile.pyttobuf�s

cCsyt|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_MAGICRtLENGTH_LINKR(tLENGTH_NAMEt_posix_split_namet_create_headerR�(R{R�((s/sys/lib/python2.7/tarfile.pyR��s
$cCs�t|d<d}t|d�tkrC||j|dt�7}nt|d�tkrv||j|dt�7}n||j|t�S(s:Return the object as a GNU header block sequence.
        R�R0R�R|(	t	GNU_MAGICRR�t_create_gnu_long_headertGNUTYPE_LONGLINKR�tGNUTYPE_LONGNAMER�R1(R{R�RG((s/sys/lib/python2.7/tarfile.pyR��s
cCs�t|d<|jj�}x�ddtfddtfddfD]�\}}}||kr_q>n||j||�}y|jd	�Wntk
r�|||<q>nXt||�|kr>|||<q>q>Wx�ddddfD]�\}}	||kr	d||<q�||}d|ko2d|	dknsGt	|t
�r�|�||<d||<q��|r�|j|�}
nd}
|
|j
|t�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 RtasciiRiRRiRiiR0(sunamesunamei (sgnamesgnamei (suidi(sgidi(ssizei(smtimei(R�R�tcopyR�R�tdecodeR:R;RR�tfloatR�t_create_pax_generic_headerR�R�(R{R�R>R?R�R|thnameR!tvalR5RG((s/sys/lib/python2.7/tarfile.pyR�s6




4cCs|j|dt�S(sAReturn the object as a pax global header block sequence.
        R�(R�tXGLTYPE(tclsR�((s/sys/lib/python2.7/tarfile.pytcreate_pax_global_header7scCs�|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_PREFIXRR�R((R{R|R�((s/sys/lib/python2.7/tarfile.pyR�=s
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�t|jdt�d�t|jdd�d�t|jdd�d�t|jdd�d|�t|jdd�d|�t|jdd�d�g}tjdtdj|��}t	|t�d}|d d||d}|S(s�Return a header block. info is a dictionary with file
           information, format must be one of the *_FORMAT constants.
        R|R0idR_ii�iRRRiRs        R�R�R�Ri RR�R�R�i�s%dsi��%06oi��R"tgetR7R�R�R2R4R�R=RJ(R�R6tpartsRGR�((s/sys/lib/python2.7/tarfile.pyR�Ls&cCs@tt|�t�\}}|dkr<|t|t7}n|S(sdReturn the string payload filled with zero bytes
           up to the next 512 byte border.
        i(RNRR�R(tpayloadRURV((s/sys/lib/python2.7/tarfile.pyt_create_payloadhscCs[|t7}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�(RRR�R�R�R(RR|R�R�((s/sys/lib/python2.7/tarfile.pyR�rs



c
Csg}x�|j�D]�\}}|jd�}|jd�}t|�t|�d}d}}x6tr�|tt|��}||kr�Pn|}qdW|jd|||f�qWdj|�}i}	d|	d<||	d<t|�|	d	<t|	d
<|j|	t	�|j
|�S(s�Return a POSIX.1-2001 extended or global header sequence
           that contains a list of keyword, value pairs. The values
           must be unicode objects.
        R9iis	%d %s=%s
R0s././@PaxHeaderR|R�RR�(t	iteritemsR:RR�tstrR<R=R�R�R�R(
RR�R�trecordstkeywordtvalueR/R,R$R�((s/sys/lib/python2.7/tarfile.pyR��s(
	



cCsKt|�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�jjd�r�|_n|j�r|jjd�|_n|rG|jtkrG|d|j|_n|S(sBConstruct a TarInfo object from a 512 byte string buffer.
        isempty headerstruncated headersend of file headeri�i�sbad checksumidiliti|i�i�ii	i)iIiQiYi�R�(RRmR�RntcountRRoR.RJR)RGR%R|R_RRRRR�R�R�RRR�R�tAREGTYPER�R�tisdirtrstript	GNU_TYPES(RRGR�tobjR�((s/sys/lib/python2.7/tarfile.pytfrombuf�s@			!cCsD|jjt�}|j|�}|jj�t|_|j|�S(sOReturn the next TarInfo object from TarFile object
           tarfile.
        (R�ROR�RR�R�t_proc_member(RR�RGR((s/sys/lib/python2.7/tarfile.pytfromtarfile�scCst|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_gnulongtGNUTYPE_SPARSEt_proc_sparsetXHDTYPERtSOLARIS_XHDTYPEt	_proc_paxt
_proc_builtin(R{R�((s/sys/lib/python2.7/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�((s/sys/lib/python2.7/tarfile.pyR�s		cCs�|jj|j|j��}y|j|�}Wntk
rPtd��nX|j|_|jt	kr~t
|�|_n!|jtkr�t
|�|_
n|S(sSProcess the blocks that hold a GNU longname
           or longlink member.
        s missing or bad subsequent header(R�ROR RRRlRpR�R�R�R%R|R�R�(R{R�RGtnext((s/sys/lib/python2.7/tarfile.pyRs
cCss|j}t�}d}d}d}x�td�D]�}y6t|||d!�}t||d|d!�}	Wntk
r�PnX||kr�|jt|||��n|jt||	|��||	7}||	}|d7}q1Wt|d�}
t|dd!�}x�d	kr|j	j
t�}d
}x�td�D]�}y6t|||d!�}t||d|d!�}	Wntk
r�PnX||kr�|jt|||��n|jt||	|��||	7}||	}|d7}q=Wt|d�}
qW||kr/|jt|||��n||_|j	j
�|_|j|j|j�|_||_|S(
s8Process a GNU sparse header plus extra headers.
        i�liiii�i�i�iiii�(RGt_ringbufferR*R.R(R<t_holeR�R+R�ROR�R�R�R�R RR�(R{R�RGtspR�tlastposR�R-R�tnumbytest
isextendedtorigsize((s/sys/lib/python2.7/tarfile.pyRsT		





		cCs�|jj|j|j��}|jtkr9|j}n|jj�}tj	dtj
�}d}x�tr|j||�}|s�Pn|j
�\}}t|�}||jd�d|jd�|d!}	|jd�}|	jd�}	|	||<||7}qfWy|j|�}
Wntk
r9td��nX|jttfkr�|
j||j|j�|j|
_d|kr�|
j}|
j�s�|
jtkr�||
j|
j�7}n||_q�n|
S(sVProcess an extended or global header as described in
           POSIX.1-2001.
        s(\d+) ([^=]+)=iiiR9s missing or bad subsequent headerR(R�ROR RR�RR�R�tretcompiletUR�tmatchtgroupsR'tendtstartR�RRlRpRRR!R>R?R�R�RR(R{R�RGR�tregexR�R-R!RR
R"R�((s/sys/lib/python2.7/tarfile.pyRRs<	+

	cCs�x�|j�D]�\}}|tkr+q
n|dkrI|jd�}n|tkr�yt||�}Wq�tk
r�d}q�Xnt|||�}t|||�q
W|j�|_dS(soReplace fields with supplemental information from a previous
           pax extended or global header.
        RR�iN(	R	t
PAX_FIELDSRtPAX_NUMBER_FIELDSR(RAtsetattrR�R�(R{R�R>R?RR
((s/sys/lib/python2.7/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(RNR�(R{RRURV((s/sys/lib/python2.7/tarfile.pyR �s
cCs
|jtkS(N(R�t
REGULAR_TYPES(R{((s/sys/lib/python2.7/tarfile.pyR�scCs
|j�S(N(R(R{((s/sys/lib/python2.7/tarfile.pytisfile�scCs
|jtkS(N(R�R�(R{((s/sys/lib/python2.7/tarfile.pyR�scCs
|jtkS(N(R�tSYMTYPE(R{((s/sys/lib/python2.7/tarfile.pytissym�scCs
|jtkS(N(R�tLNKTYPE(R{((s/sys/lib/python2.7/tarfile.pytislnk�scCs
|jtkS(N(R�tCHRTYPE(R{((s/sys/lib/python2.7/tarfile.pytischr�scCs
|jtkS(N(R�tBLKTYPE(R{((s/sys/lib/python2.7/tarfile.pytisblk�scCs
|jtkS(N(R�tFIFOTYPE(R{((s/sys/lib/python2.7/tarfile.pytisfifo�scCs
|jtkS(N(R�R(R{((s/sys/lib/python2.7/tarfile.pytissparse�scCs|jtttfkS(N(R�R;R=R?(R{((s/sys/lib/python2.7/tarfile.pytisdev�s(/ReRfRgR}R�R�tpropertyRR�R�RR�R�tDEFAULT_FORMATtENCODINGR�R�R�R�tclassmethodRR�tstaticmethodR�RR�RR�RRRRRRRR!R RR6RR8R:R<R>R@RARB(((s/sys/lib/python2.7/tarfile.pyR�sP							
		3	
.	
			8	:												c
BsHeZdZdZeZeZdZeZ	e
Zd2Z
eZeZd2dd2d2d2d2d2d2d2d2d2d2d�Zd�Zd�Zeee�Zed2dd2ed��Zedd2d��Zedd2d	d
��Zedd2d	d��Zidd
6dd6dd6Zd�Zd�Zd�Z d�Z!d2d2d2d�Z"e#d�Z$d2e#d2d2d�Z%d2d�Z&dd2d�Z'dd�Z(d�Z)d�Z*d �Z+d!�Z,d"�Z-d#�Z.d$�Z/d%�Z0d&�Z1d'�Z2d(�Z3d)�Z4d2ed*�Z5d+�Z6d2d,�Z7d-�Z8d.�Z9d/�Z:d0�Z;d1�Z<RS(3s=The TarFile Class provides an interface to tar archives.
    iiRZc
Cs�idd6dd6dd6}
||
kr6td��n||_|
||_|s�|jdkr�tjj|�r�d|_d|_nt||j�}t|_nN|d
kr�t
|d�r�|j}nt
|d	�r�j|_nt|_|r
tjj
|�nd
|_||_|d
k	r7||_n|d
k	rO||_n|d
k	rg||_n|d
k	r||_n|d
k	r�||_n|	d
k	r�|	|_n!|dkr�d
|_n	d|_|
d
k	r�jtkr�|_n	i|_|d
k	r||_n|d
k	r0||_nt|_g|_t|_|jj�|_i|_y9|jdkr�d
|_|j �|_n|jdkr7x�tr3|jj!|j�y&|jj"|�}|jj#|�Wq�t$k
r|jj!|j�Pq�t%k
r/}t&t'|���q�Xq�Wn|jdkr�t|_|jr�|jj(|jj)��}|jj*|�|jt+|�7_q�nWn,|js�|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.
        trbRZsr+btatwbR[smode must be 'r', 'a' or 'w'R|R_sutf-8R8tawN(-R(R_t_modeRsRtexistst	bltn_openR�R�RKRxR|R�tabspathR�R6R�tdereferencetignore_zerosR>R?R�R�tdebugt
errorlevelR�tmemberst_loadedR�R�tinodestfirstmemberR"R�RR<RoRlRiR
RR�RQRR~(R{R|R_R�R6R�RPRQR>R?R�RRRStmodesteRG((s/sys/lib/python2.7/tarfile.pyR}�s�	
"		!									
				cCs
|jtkS(N(R6R�(R{((s/sys/lib/python2.7/tarfile.pyt	_getposixCscCs>ddl}|jdtd�|r1t|_n	t|_dS(Ni�s use the format attribute insteadi(twarningstwarntDeprecationWarningR�R6R1(R{R
R[((s/sys/lib/python2.7/tarfile.pyt	_setposixEsc	Ks|r|rtd��n|dkr�x�|jD]�}t||j|�}|dk	rj|j�}ny||d||�SWq3ttfk
r�}	|dk	r3|j|�q3q3q3Xq3Wtd��n4d|krV|jdd�\}
}|
p�}
|pd}||jkr3t||j|�}ntd|��|||
||�Sd	|kr�jd	d�\}
}|
p�d}
|p�d}|
dkr�td��n|||
t	||
|||�|�}t
|_|S|dkr|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 openRZsr:*s%file could not be opened successfullyt:iR�sunknown compression type %rt|R[smode must be 'r' or 'w'RIsundiscernible modeN(RZsr:*(RZR[(RIR[(
R(t	OPEN_METHR�RKR�RiRjR�tsplitRR�R�ttaropen(RR|R_R�R�tkwargsR�tfunct	saved_posRYRdR\((s/sys/lib/python2.7/tarfile.pyRyZsH			cKs.|dkrtd��n|||||�S(sCOpen uncompressed tar archive name for reading or writing.
        RZRIR[smode must be 'r', 'a' or 'w'(RZRIR[(R((RR|R_R�Rd((s/sys/lib/python2.7/tarfile.pyRc�si	cKs�|d	krtd��nyddl}|jWn#ttfk
rWtd��nX|dkrzt||d�}ny.|j|||j||||�|�}Wn/t	k
r�|dkr�t
d��n�nXt|_|S(
skOpen gzip compressed tar archive name for reading or writing.
           Appending is not allowed.
        RZR[smode must be 'r' or 'w'i�Nsgzip module is not availableRWsnot a gzip file(RZR[(
R(tgziptGzipFileR�tAttributeErrorRjRKRNRcRPRiR�R�(RR|R_R�t
compresslevelRdRgR\((s/sys/lib/python2.7/tarfile.pytgzopen�s&

	cKs�|d	krtd��nyddl}Wntk
rJtd��nX|dk	rit||�}n|j||d|�}y|j||||�}Wn5tt	fk
r�|dkr�t
d��n�nXt|_|S(
slOpen bzip2 compressed tar archive name for reading or writing.
           Appending is not allowed.
        RZR[smode must be 'r' or 'w'.i�Nsbz2 module is not availableRjsnot a bzip2 file(RZR[(
R(R�R�RjRKR�tBZ2FileRcRPtEOFErrorRiR�R�(RR|R_R�RjRdR�R\((s/sys/lib/python2.7/tarfile.pytbz2open�s"
	RcR�RkR�RnR�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.
        NRKii(R�R_R�RQRR�R�RNt
RECORDSIZER�R~R�(R{RURV((s/sys/lib/python2.7/tarfile.pyR~�s		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
_getmemberRKtKeyError(R{R|R�((s/sys/lib/python2.7/tarfile.pyt	getmembers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_checkRUt_loadRT(R{((s/sys/lib/python2.7/tarfile.pyt
getmemberss
	
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().
        (RuR|(R{R�((s/sys/lib/python2.7/tarfile.pytgetnamesscCs\|jd�|d
k	r%|j}n|d
kr:|}ntjj|�\}}|jtjd�}|jd�}|j	�}||_
|d
kr�ttd�r�|jr�tj
|�}q�j|�}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�}
tj|�}n4tj |�r�}
ntj"|�rt#}
nd
S||_||_$|j%|_&|j'|_(|
tkr]|j)|_*n	d|_*|j+|_,|
|_-||_.t/r�yt/j0|j&�d|_1Wq�t2k
r�q�Xnt3r�t3j4|j(�d|_5Wq�2k
r�q�|
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.
        RKR�tlstatR0iiltmajortminorN(;RsRKR|RsRt
splitdriveR�tseptlstripR�R�RxRPRwtstattfstattfilenotst_modetS_ISREGtst_inotst_devtst_nlinkRVR9R�tS_ISDIRR�tS_ISFIFOR?tS_ISLNKR7treadlinktS_ISCHRR;tS_ISBLKR=R_tst_uidRtst_gidRtst_sizeRtst_mtimeRR�R�tpwdtgetpwuidRRqtgrptgetgrgidRRxtst_rdevR�RyR�(R{R|tarcnameR�tdrvR�tstatresR�tstmdtinodeR�((s/sys/lib/python2.7/tarfile.pyt
gettarinfos~
			"
									

cCs|j�x�D]�|r�t|j�Gd|jp<|j|jpK|jfG|j�sh|j�r�dd|j	|j
fGnd|jGdtj
|j�d Gn|j|j�r�dndG|r|j�r�	G|jGn|j�rd
G|jGqnHqWdS(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.
        s%s/%ss%10ss%d,%ds%10ds%d-%02d-%02d %02d:%02d:%02diR�R0s->slink toN(RsRdR_RRRRR<R>R�R�RR�t	localtimeRR|RR8R�R:(R{tverboseR�((s/sys/lib/python2.7/tarfile.pytlist}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�rrt|d
��}|j
||�WdQXn�|j�r�j
|�|r�tj|�D]=}|jtjj||�tjj||�|||�q�Wq�|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.
        RKi�Nsuse the filter argument insteadistarfile: Excluded %rstarfile: Skipped %ristarfile: Unsupported type %rRH(RsRKR[R\R]t_dbgR|RsRROR�RRNtaddfileRtlistdirtaddR=(	R{R|R�t	recursivetexcludetfilterR[R�tf((s/sys/lib/python2.7/tarfile.pyR��sB
		
*
*cCs�|jd�tj|�}|j|j|j|j�}|jj|�|jt	|�7_|dk	r�||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.
        RKiiN(RsR�R�R6R>R?R�RQR�RRKRMRRNR�RRTR<(R{R�R�RGRURV((s/sys/lib/python2.7/tarfile.pyR��s

t.cCs3g}|dkr|}nxR|D]J}|j�r\|j|�tj|�}d|_n|j||�q"W|jdtjd��|j	�x�|D]�}t
jj||j
�}y4|j||�|j||�|j||�Wq�tk
r*}|jdkr�q+|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�R�R|istarfile: %sN(RKRR<R�R_textracttsorttoperatort
attrgettertreverseRsRR=R|tchowntutimetchmodRhRSR�(R{RRTtdirectoriesR�tdirpathRY((s/sys/lib/python2.7/tarfile.pyt
extractall�s*	



R0cCs7|jd�t|t�r.|j|�}n|}|j�r^tjj||j�|_	ny&|j
|tjj||j��Wn�tk
r�|j
dkr��q3|jdkr�|jdd|j�q3|jdd|j|jf�n<tk
r2}|j
dkr�q3|jdd|�nXdS(s#Extract 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'.
        RZiistarfile: %sstarfile: %s %rN(RsR�t
basestringRrR:RsRR=R�t_link_targett_extract_memberR|tEnvironmentErrorRStfilenameRKR�tstrerrorRh(R{tmemberRR�RY((s/sys/lib/python2.7/tarfile.pyR�s$
&#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()
        RZs'cannot extract (sym)link as file objectN(RsR�R�RrRt
fileobjectR�RR:R8R�RRktextractfilet_find_link_targetRK(R{R�R�((s/sys/lib/python2.7/tarfile.pyR�7s	
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||�|j||�|j	�s�|j||�|j||�ndS(s\Extract the TarInfo object tarinfo to a physical
           file called targetpath.
        R�is%s -> %sN(RR�RsR{RtdirnameRMtmakedirsR:R8R�R|R�RtmakefileRtmakedirR@tmakefifoR<R>tmakedevtmakelinkR�RtmakeunknownR�R�R�(R{R�t
targetpatht	upperdirs((s/sys/lib/python2.7/tarfile.pyR�]s2#cCsFytj|d�Wn+tk
rA}|jtjkrB�qBnXdS(s,Make a directory called targetpath.
        i�N(RstmkdirR�terrnotEEXIST(R{R�R�RY((s/sys/lib/python2.7/tarfile.pyR��s
cCsJ|j|�}z)t|d��}t||�WdQXWd|j�XdS(s'Make a file called targetpath.
        RJN(R�RNRMR~(R{R�R�tsourcettarget((s/sys/lib/python2.7/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�((s/sys/lib/python2.7/tarfile.pyR��scCs/ttd�rtj|�ntd��dS(s'Make a fifo called targetpath.
        tmkfifosfifo not supported by systemN(RxRsR�Rh(R{R�R�((s/sys/lib/python2.7/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(RxRsRhR_R>R}tS_IFBLKtS_IFCHRR�R�R�R�(R{R�R�R_((s/sys/lib/python2.7/tarfile.pyR��s 	
cCsttd�r�ttd�r�|j�rbtjj|�rLtj|�ntj|j|�qtjj|j	�r�tjj|�r�tj|�ntj
|j	|�q|j|j|�|�n=y|j|j|�|�Wnt
k
rtd��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.
        tsymlinktlinks%unable to resolve link inside archiveN(RxRsR8RtlexiststunlinkR�R�RMR�R�R�R�RqRh(R{R�R�((s/sys/lib/python2.7/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�j|||�nWqtk
r}td��qXndS(s6Set owner of targetpath according to tarinfo.
        tgeteuidiitlchowntos2emxscould not change ownerN(R�RxRsR�R�tgetgrnamRRqRtgetpwnamRRR8R�tsystplatformR�R�Rh(R{R�R�RtuRY((s/sys/lib/python2.7/tarfile.pyR��s '



cCsOttd�rKytj||j�WqKtk
rG}td��qKXndS(sASet file permissions of targetpath according to tarinfo.
        R�scould not change modeN(RxRsR�R_R�Rh(R{R�R�RY((s/sys/lib/python2.7/tarfile.pyR��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(RxRsR�RR�Rh(R{R�R�RY((s/sys/lib/python2.7/tarfile.pyR��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�
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(RsRWRKR�R�R�R�R�RRoRQR�R�R)RiR
RmRnRpRTR<RU(R{tmR�RY((s/sys/lib/python2.7/tarfile.pyR"	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(RuRKtindexRsRtnormpathtreversedR|(R{R|R�t	normalizeRTR�tmember_name((s/sys/lib/python2.7/tarfile.pyRp4	s	cCs6x&tr(|j�}|dkrPqqWt|_dS(sWRead through the entire archive file and look for readable
           members.
        N(R�R"RKRU(R{R�((s/sys/lib/python2.7/tarfile.pyRtK	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�RPR�ReRKR_(R{R_((s/sys/lib/python2.7/tarfile.pyRsU	s	cCs�|j�rEdjtdtjj|j�|jf��}d}n|j}|}|j	|d|dt
�}|dkr�td|��n|S(sZFind the target member of a symlink or hardlink member in the
           archive.
        R�R�R�slinkname %r not foundN(R8R=R�RKRsRR�R|R�RpR�Rq(R{R�R�tlimitR�((s/sys/lib/python2.7/tarfile.pyR�^	s0		cCs$|jrt|j�St|�SdS(s$Provide an iterator object.
        N(RUtiterRTtTarIter(R{((s/sys/lib/python2.7/tarfile.pyR�q	s	
cCs#||jkrtj|IJndS(s.Write debugging output to sys.stderr.
        N(RRR�tstderr(R{tleveltmsg((s/sys/lib/python2.7/tarfile.pyR�y	scCs|j�|S(N(Rs(R{((s/sys/lib/python2.7/tarfile.pyt	__enter__	s
cCs?|dkr|j�n"|js2|jj�nt|_dS(N(RKR~R�R�R�R�(R{R�R
t	traceback((s/sys/lib/python2.7/tarfile.pyt__exit__�s

	N(=ReRfRgRRR�RPRQRSRDR6RER>RKR?RR�R�R�R}RZR^RCtposixRFRoRyRcRkRnRaR~RrRuRvR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R"RpRtRsR�R�R�R�R�(((s/sys/lib/python2.7/tarfile.pyR�ste		
H
			
	b=%!	&	/		
									1	
					R�cBs)eZdZd�Zd�Zd�ZRS(sMIterator Class.

       for tarinfo in TarFile(...):
           suite...
    cCs||_d|_dS(s$Construct a TarIter object.
        iN(R�R�(R{R�((s/sys/lib/python2.7/tarfile.pyR}�s	cCs|S(s Return iterator object.
        ((R{((s/sys/lib/python2.7/tarfile.pyR��scCs�|jdkr3|jjdk	r3|jj�}np|jt|jj�krd|jj|j}n?|jjs�|jj�}|s�t|j_t	�q�nt	�|jd7_|S(s�Return the next item using TarFile's next() method.
           When all members have been read, set TarFile as _loaded.
        iiN(
R�R�RWRKR"RRTRUR�t
StopIteration(R{R�((s/sys/lib/python2.7/tarfile.pyR"�s!(ReRfRgR}R�R"(((s/sys/lib/python2.7/tarfile.pyR��s		t_sectioncBs eZdZd�Zd�ZRS(s$Base class for _data and _hole.
    cCs||_||_dS(N(R�R(R{R�R((s/sys/lib/python2.7/tarfile.pyR}�s	cCs%|j|ko"|j|jkSS(N(R�R(R{R�((s/sys/lib/python2.7/tarfile.pyt__contains__�s(ReRfRgR}R�(((s/sys/lib/python2.7/tarfile.pyR��s	R�cBseZdZd�ZRS(s/Represent a data section in a sparse file.
    cCs tj|||�||_dS(N(R�R}R�(R{R�RR�((s/sys/lib/python2.7/tarfile.pyR}�s(ReRfRgR}(((s/sys/lib/python2.7/tarfile.pyR��sR$cBseZdZRS(s/Represent a hole section in a sparse file.
    (ReRfRg(((s/sys/lib/python2.7/tarfile.pyR$�sR#cBs eZdZd�Zd�ZRS(sMRingbuffer class which increases performance
       over a regular list.
    cCs
d|_dS(Ni(tidx(R{((s/sys/lib/python2.7/tarfile.pyR}�scCsu|j}x\trg||}||kr,Pn|d7}|t|�krQd}n||jkrdSqW||_|S(Nii(R�R�RRK(R{R�R�titem((s/sys/lib/python2.7/tarfile.pyR#�s		

		(ReRfRgR}R#(((s/sys/lib/python2.7/tarfile.pyR#�s	t
TarFileCompatcBsteZdZded�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ddd	�Zd
�Z
d�ZRS(
sRTarFile class compatible with standard module zipfile's
       ZipFile class.
    RZcCs�ddlm}|ddd�|tkrDtj||�|_n0|tkrhtj||�|_ntd��|dd!d	kr�|jj	�}xB|D]7}|j
|_|j|_
tj|j�d
 |_q�WndS(Ni�(twarnpy3ks6the TarFileCompat class has been removed in Python 3.0t
stacklevelisunknown compression constantiiRZi(R[R�t	TAR_PLAINRRcR�tTAR_GZIPPEDRkR(RuR|R�Rt	file_sizeR�tgmtimeRt	date_time(R{tfileR_tcompressionR�RTR�((s/sys/lib/python2.7/tarfile.pyR}�s	
cCstd�|j��S(NcSs|jS(N(R|(R�((s/sys/lib/python2.7/tarfile.pyt<lambda>�s(tmaptinfolist(R{((s/sys/lib/python2.7/tarfile.pytnamelist�scCstd�|jj��S(NcSs
|jtkS(N(R�R5(R�((s/sys/lib/python2.7/tarfile.pyR��s(R�R�Ru(R{((s/sys/lib/python2.7/tarfile.pyR��s	cCs|jj�dS(N(R�R�(R{((s/sys/lib/python2.7/tarfile.pytprintdir�scCsdS(N((R{((s/sys/lib/python2.7/tarfile.pyttestzip�scCs|jj|�S(N(R�Rr(R{R|((s/sys/lib/python2.7/tarfile.pytgetinfo
scCs"|jj|jj|��j�S(N(R�R�RrRO(R{R|((s/sys/lib/python2.7/tarfile.pyRO
scCs|jj||�dS(N(R�R�(R{R�R�t
compress_type((s/sys/lib/python2.7/tarfile.pyRQ
scCs�yddlm}Wn!tk
r7ddlm}nXddl}t|j�}t|�|_|j|j	�|_
|jj|||��dS(Ni�(tStringIO(
t	cStringIORR�tcalendarRR�RRttimegmR�RR�R�(R{tzinfotbytesRRttinfo((s/sys/lib/python2.7/tarfile.pytwritestr
s
cCs|jj�dS(N(R�R~(R{((s/sys/lib/python2.7/tarfile.pyR~
sN(ReRfRgR�R}R�R�R�R�RRORKRQR	R~(((s/sys/lib/python2.7/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(RyR~R�RR�(R|R\((s/sys/lib/python2.7/tarfile.pyR
s

(wRgt__version__tversiont
__author__t__date__t	__cvsid__t__credits__R�RsRLR}R�R�R2R�R*R�R�R�R�RKt__all__RR�RoR�R�R�R�RR�RR9R7R;R=R�R?tCONTTYPER�R�RRRRR�R1R�RDRR5RR2R�R'R3tS_IFLNKtS_IFREGR�tS_IFDIRR�tS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECtgetfilesystemencodingREtgetdefaultencodingR"R%R.R7RARJRMR^Rdt	ExceptionRRhRiRjRkRlRmRnRoR)RpRqRtobjectR�R�R�R�RRR�R�R�R$R�R#R�R�R�RRyRN(((s/sys/lib/python2.7/tarfile.pyt<module>s.

					
						
					
	
	
		�AL��5��'	4	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].