Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 N”ªjù¯ã'@s:dZdZdZdZdZdZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZy ddlZWnek r˜dZYnXy ddlZWnek r¾dZYnXeefZyeef7ZWnek rêYnXd d d d d ddddddddddgZdZdZedZdZdZ dZ!dZ"dZ#dZ$dZ%d Z&d!Z'd"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d)Z/d*Z0d+Z1d,Z2dZ3d-Z4d.Z5e4Z6e$e%e&e'e*e+e,e(e)e-e.e/f Z7e$e%e,e/fZ8e-e.e/fZ9d„Z:d/d0d5d6hZ;ee j?d8k�räd9Z@ne jAƒZ@d:d;„ZBdd?„ZDd@e6fdAdB„ZEdCdD„ZFdedfdEdF„ZGdGdH„ZHdIdJ„ZIGdKd „d eJƒZKGdLd„deKƒZLGdMd „d eKƒZMGdNd„deKƒZNGdOd„deKƒZOGdPd„deKƒZPGdQdR„dRePƒZQGdSdT„dTePƒZRGdUdV„dVePƒZSGdWdX„dXePƒZTGdYdZ„dZePƒZUGd[d\„d\ƒZVGd]d^„d^ƒZWGd_d`„d`eXƒZYGdadb„dbeXƒZZGdcdd„dde j[ƒZ\ej]deƒZ^Gdfdg„dgeKƒZ_Gdhdi„die_ƒZ`Gdjdk„dke_ƒZaGdldm„dme_ƒZbGdndo„doe_ƒZcGdpdq„dqe_ƒZdGdrds„dse_ƒZee_eeLfZfd…dudv„Zgdwdx„Zhdydz„Zid{d|„Zjeheiejd}œZkeXƒZlGd~d „d eXƒZmGdd „d eXƒZnd€d „ZoenjZd�d‚„Zpeqdƒk�r6epƒdS)†z,Read from and write to tar format archives. z0.9.0u"Lars Gustäbel (lars@gustaebel.de)z5$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $z?$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $u4Gustavo Niemeyer, Niels Gustäbel, Richard Townsend.é)ÚopenNÚTarFileÚTarInfoÚ is_tarfileÚTarErrorÚ ReadErrorÚCompressionErrorÚ StreamErrorÚ ExtractErrorÚ HeaderErrorÚENCODINGÚ USTAR_FORMATÚ GNU_FORMATÚ PAX_FORMATÚDEFAULT_FORMATróiésustar sustar00édé›ó0ó1ó2ó3ó4ó5ó6ó7óLóKóSóxógóXééÚpathÚlinkpathÚsizeÚmtimeÚuidÚgidÚunameÚgname)ZatimeZctimer(r)r*r'Úntzutf-8cCs8|dkrtdƒ‚|j||ƒ}|d|…|t|ƒtS)z8Convert a string to a null-terminated bytes object. Nzmetadata cannot contain None)Ú ValueErrorÚencodeÚlenÚNUL)ÚsÚlengthÚencodingÚerrors©r6ú/usr/lib64/python3.6/tarfile.pyÚstn¢s r8cCs*|jdƒ}|dkr|d|…}|j||ƒS)z8Convert a null-terminated bytes object to a string. rr#Néÿÿÿÿ)ÚfindÚdecode)r2r4r5Úpr6r6r7Úntsªs  r=c Csª|dd krfd}x0tt|ƒdƒD]}|dK}|||d7}q"W|ddkr¦dt|ƒd| }n@y"t|ddƒ}t|jƒp€d dƒ}Wntk r¤td ƒ‚YnX|S) z/Convert a number field to a python number. ré€éÿr#ééÚasciiÚstrictÚ0zinvalid header)r>r?)Úranger0r=ÚintÚstripr.ÚInvalidHeaderError)r2ÚnÚir6r6r7Únti²s   rKr@cCsÜt|ƒ}d|ko"d|dknrDtd|d|fdƒt}n”|tkrÐd|d |kopd|dknrÐ|dkrŠtdgƒ}ntdgƒ}d||}x6t|dƒD]}|jd|d@ƒ|dL}q®Wntd ƒ‚|S) z/Convert a python number to a number field. rr@r#z%0*orBrAr>r?zoverflow in number field)rFÚbytesr1rÚ bytearrayrEÚinsertr.)rIÚdigitsÚformatr2rJr6r6r7ÚitnÆs  2   rQcCs0dttjd|ƒƒ}dttjd|ƒƒ}||fS)a¨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. rAZ 148B8x356BZ 148b8x356b)ÚsumÚstructÚ unpack_from)ÚbufZunsigned_chksumZ signed_chksumr6r6r7Ú calc_chksumsãs rVc Csª|pd}|dkrdS|dkr.tj|||ƒdSt||ƒ\}}x8t|ƒD],}|j|ƒ}t|ƒ|krh|dƒ‚|j|ƒqFW|dkr¦|j|ƒ}t|ƒ|krœ|dƒ‚|j|ƒdS)zjCopy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. éirNzunexpected end of datai@)ÚshutilÚ copyfileobjÚdivmodrEÚreadr0Úwrite) ÚsrcÚdstr3Ú exceptionÚbufsizeÚblocksÚ remainderÚbrUr6r6r7rYðs$     rYcCs ddl}|jdtdƒtj|ƒS)z/Deprecated in this location; use stat.filemode.rNz$deprecated in favor of stat.filemoder$)ÚwarningsÚwarnÚDeprecationWarningÚstatÚfilemode)Úmoderdr6r6r7rh srhcCs8ttjddƒ}|dk r(|j|dƒj|ƒ}t|dd�dS)Nr4Úbackslashreplaceú )Úend)ÚgetattrÚsysÚstdoutr/r;Úprint)r2r4r6r6r7Ú _safe_printsrqc@seZdZdZdS)rzBase exception.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r6r6r6r7rsc@seZdZdZdS)r z%General exception for extract errors.N)rrrsrtrur6r6r6r7r sc@seZdZdZdS)rz&Exception for unreadable tar archives.N)rrrsrtrur6r6r6r7rsc@seZdZdZdS)rz.Exception for unavailable compression methods.N)rrrsrtrur6r6r6r7r sc@seZdZdZdS)r z=Exception for unsupported operations on stream-like TarFiles.N)rrrsrtrur6r6r6r7r #sc@seZdZdZdS)r z!Base exception for header errors.N)rrrsrtrur6r6r6r7r &sc@seZdZdZdS)ÚEmptyHeaderErrorzException for empty headers.N)rrrsrtrur6r6r6r7rv)srvc@seZdZdZdS)ÚTruncatedHeaderErrorz Exception for truncated headers.N)rrrsrtrur6r6r6r7rw,srwc@seZdZdZdS)ÚEOFHeaderErrorz"Exception for end of file headers.N)rrrsrtrur6r6r6r7rx/srxc@seZdZdZdS)rHzException for invalid headers.N)rrrsrtrur6r6r6r7rH2srHc@seZdZdZdS)ÚSubsequentHeaderErrorz3Exception for missing and invalid extended headers.N)rrrsrtrur6r6r6r7ry5sryc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú _LowLevelFilez‰Low-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. cCsFtjtjtjBtjBdœ|}ttdƒr2|tjO}tj||dƒ|_dS)N)ÚrÚwÚO_BINARYi¶) ÚosÚO_RDONLYÚO_WRONLYÚO_CREATÚO_TRUNCÚhasattrr}rÚfd)ÚselfÚnamerir6r6r7Ú__init__Bs   z_LowLevelFile.__init__cCstj|jƒdS)N)r~Úcloser„)r…r6r6r7rˆKsz_LowLevelFile.closecCstj|j|ƒS)N)r~r[r„)r…r'r6r6r7r[Nsz_LowLevelFile.readcCstj|j|ƒdS)N)r~r\r„)r…r2r6r6r7r\Qsz_LowLevelFile.writeN)rrrsrtrur‡rˆr[r\r6r6r6r7rz<s  rzc@steZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z ddd„Z ddd„Z dd„Zdd„ZdS)Ú_Streama˜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. c Csäd|_|dkrt||ƒ}d|_|dkr6t|ƒ}|jƒ}|pt|jƒ|jkrL|jj|jd|j…ƒ|j|jd…|_qWdS)z]Write string s to the stream if a whole new block is ready to be written. N)rUr0r`r•r\)r…r2r6r6r7Z__writeÁsz_Stream.__writec Cs²|jr dSd|_zŠ|jdkr:|jdkr:|j|jjƒ7_|jdkr˜|jr˜|jj|jƒd|_|jdkr˜|jjtj d|j ƒƒ|jjtj d|j d@ƒƒWd|j s¬|jj ƒXdS) z[Close the _Stream object. No operation should be done on it afterwards. NTr|r�rŒr�zd|fg}d|_g|_d}|j}xT|D]L\}}||kr~|jj d||dfƒ|jj d||||fƒ||7}||}qZW||jkrÊ|jj d||jdfƒdS)Nrr†FT) r•Úoffsetr'Úpositionrmr†r—Ú map_indexÚmaprº)r…r•rÄr'Z blockinfoZlastposZrealposr6r6r7r‡ps(   z_FileInFile.__init__cCsdS)Nr6)r…r6r6r7r¯‰sz_FileInFile.flushcCsdS)NTr6)r…r6r6r7ÚreadableŒsz_FileInFile.readablecCsdS)NFr6)r…r6r6r7Úwritable�sz_FileInFile.writablecCs |jjƒS)N)r•Úseekable)r…r6r6r7rÊ’sz_FileInFile.seekablecCs|jS)z*Return the current file position. )rÅ)r…r6r6r7r¶•sz_FileInFile.tellcCs�|tjkr tt|dƒ|jƒ|_nj|tjkr\|dkrFt|j|dƒ|_qŠt|j||jƒ|_n.|tjkr‚tt|j||jƒdƒ|_ntdƒ‚|jS)z(Seek to a position in the file. rzInvalid argument) ÚioÚSEEK_SETÚminÚmaxr'rÅÚSEEK_CURÚSEEK_ENDr.)r…rÅÚwhencer6r6r7r¸šs   z_FileInFile.seekc Cs|dkr|j|j}nt||j|jƒ}d}xà|dk�r xZ|j|j\}}}}||jkob|knrlPq:|jd7_|jt|jƒkr:d|_q:Wt|||jƒ}|rè|jj||j|ƒ|jj|ƒ}t|ƒ|krÞt dƒ‚||7}n |t |7}||8}|j|7_q.W|S)z!Read data from the file. NrŒrr#zunexpected end of data) r'rÅrÍrÇrÆr0r•r¸r[rr1) r…r'rUr·ÚstartÚstoprÄr3rcr6r6r7r[ªs.      z_FileInFile.readcCs&|jt|ƒƒ}||dt|ƒ…<t|ƒS)N)r[r0)r…rcrUr6r6r7ÚreadintoÉsz_FileInFile.readintocCs d|_dS)NT)r—)r…r6r6r7rˆÎsz_FileInFile.close)N)N)rrrsrtrur‡r¯rÈrÉrÊr¶rËrÌr¸r[rÔrˆr6r6r6r7rÃjs  rÃcseZdZ‡fdd„Z‡ZS)Ú ExFileObjectcs&t|j|j|j|jƒ}tƒj|ƒdS)N)rÃr•Ú offset_datar'ÚsparseÚsuperr‡)r…ÚtarfileÚtarinfor•)Ú __class__r6r7r‡Ôs  zExFileObject.__init__)rrrsrtr‡Ú __classcell__r6r6)rÛr7rÕÒsrÕs([0-9]{1,20}) c@s eZdZdS)Ú FilterErrorN)rrrsrtr6r6r6r7rÝâsrÝcseZdZ‡fdd„Z‡ZS)ÚAbsolutePathErrorcs ||_tƒjd|j›d�ƒdS)Nzmember z has an absolute path)rÚrØr‡r†)r…rÚ)rÛr6r7r‡æszAbsolutePathError.__init__)rrrsrtr‡rÜr6r6)rÛr7rÞåsrÞcseZdZ‡fdd„Z‡ZS)ÚOutsideDestinationErrorcs.||_||_tƒj|j›d|›d�dƒdS)Nz would be extracted to z, z which is outside the destination)rÚÚ_pathrØr‡r†)r…rÚr%)rÛr6r7r‡ësz OutsideDestinationError.__init__)rrrsrtr‡rÜr6r6)rÛr7rßêsrßcseZdZ‡fdd„Z‡ZS)ÚSpecialFileErrorcs||_tƒj|j›d�ƒdS)Nz is a special file)rÚrØr‡r†)r…rÚ)rÛr6r7r‡òszSpecialFileError.__init__)rrrsrtr‡rÜr6r6)rÛr7ráñsrácseZdZ‡fdd„Z‡ZS)ÚAbsoluteLinkErrorcs||_tƒj|j›d�ƒdS)Nz is a link to an absolute path)rÚrØr‡r†)r…rÚ)rÛr6r7r‡÷szAbsoluteLinkError.__init__)rrrsrtr‡rÜr6r6)rÛr7râösrâcseZdZ‡fdd„Z‡ZS)ÚLinkOutsideDestinationErrorcs.||_||_tƒj|j›d|›d�dƒdS)Nz would link to z, z which is outside the destination)rÚràrØr‡r†)r…rÚr%)rÛr6r7r‡üsz$LinkOutsideDestinationError.__init__)rrrsrtr‡rÜr6r6)rÛr7rãûsrãcseZdZ‡fdd„Z‡ZS)ÚLinkFallbackErrorcs2||_||_tƒjd|j›d�d|›d�ƒdS)Nzlink z would be extracted as a zcopy of z, which was rejected)rÚràrØr‡r†)r…rÚr%)rÛr6r7r‡szLinkFallbackError.__init__)rrrsrtr‡rÜr6r6)rÛr7räsräTcCs$i}|j}tjj|tjjd�}|jdtjfƒrH|jjdtjƒ}|d<tjj|ƒr\t |ƒ‚tjjtjj ||ƒtjjd�}tjj ||gƒ|kr˜t ||ƒ‚|j }|dk �r|d@}|�rþ|jƒsÆ|jƒrà|d@sÖ|dM}|dO}n|jƒsð|jƒröd}nt|ƒ‚||j k�r||d<|�r |jdk �r,d|d <|jdk �r@d|d <|jdk �rTd|d <|jdk �rhd|d <|jƒ�s||jƒ�r tjj|jƒ�r”t|ƒ‚tjj|jƒ}||jk�r¶||d <|jƒ�rÜtjj |tjj|ƒ|jƒ}ntjj ||jƒ}tjj|tjjd�}tjj ||gƒ|k�r t||ƒ‚|S)N)rCú/r†iíé@éIi€rir)r*r+r,Úlinknamei¶ÿÿÿ)r†r~r%ÚrealpathÚ ALLOW_MISSINGrÂÚsepÚlstripÚisabsrÞr»Ú commonpathrßriÚisregÚislnkÚisdirÚissymrár)r*r+r,rèrâÚnormpathÚdirnamerã)ÚmemberÚ dest_pathZfor_dataÚ new_attrsr†Z target_pathriZ normalizedr6r6r7Ú_get_filtered_attrssd                røcCs|S)Nr6)rõrör6r6r7Úfully_trusted_filterRsrùcCs(t||dƒ}|r$|jf|ddi—ŽS|S)NFÚdeep)rør§)rõrör÷r6r6r7Ú tar_filterUs rûcCs(t||dƒ}|r$|jf|ddi—ŽS|S)NTrúF)rør§)rõrör÷r6r6r7Ú data_filter[s rü)Z fully_trustedr�r·c@sÒeZdZdZdrZdsdd„Zdd„Zdd„ZeeeƒZ dd„Z dd „Z ee e ƒZ d!d"„Z eeeeeeeed#ed$œ d%d&„Zd'd(„Zeed)fd*d+„Zd,d-„Zd.d/„Zd0d1„Zed2d3„ƒZd4d5„Zed6d7„ƒZed8d9„ƒZed:d;„ƒZedd?„ƒZed#d@œdAdB„ƒZ edCdD„ƒZ!ed#d@œdEdF„ƒZ"dGdH„Z#dIdJ„Z$dKdL„Z%dMdN„Z&dOdP„Z'dQdR„Z(dSdT„Z)dUdV„Z*dWdX„Z+dYdZ„Z,d[d\„Z-d]d^„Z.d_d`„Z/dadb„Z0dcdd„Z1dedf„Z2dgdh„Z3didj„Z4dkdl„Z5dmdn„Z6dodp„Z7dqS)traInformational 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†rir)r*r'r(ÚchksumÚtyperèr+r,ÚdevmajorÚdevminorrÄrÖÚ pax_headersr×rÙÚ_sparse_structsÚ _link_targetr‹cCsj||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_i|_dS)zXConstruct a TarInfo object. name is the optional name of the member. i¤rr‹N)r†rir)r*r'r(rýÚREGTYPErþrèr+r,rÿrrÄrÖr×r)r…r†r6r6r7r‡|s"zTarInfo.__init__cCs|jS)N)r†)r…r6r6r7Ú_getpath–szTarInfo._getpathcCs ||_dS)N)r†)r…r†r6r6r7Ú_setpath˜szTarInfo._setpathcCs|jS)N)rè)r…r6r6r7Ú _getlinkpathœszTarInfo._getlinkpathcCs ||_dS)N)rè)r…rèr6r6r7Ú _setlinkpathžszTarInfo._setlinkpathcCsd|jj|jt|ƒfS)Nz<%s %r at %#x>)rÛrrr†Úid)r…r6r6r7Ú__repr__¢szTarInfo.__repr__T) r†r(rirèr)r*r+r,rúÚ_KEEPc CsŽ| rtj|ƒ} n tj|ƒ} || k r(|| _|| k r6|| _|| k rD|| _|| k rR|| _|| k r`|| _|| k rn|| _|| k r||| _|| k rŠ|| _ | S)zGReturn a deep copy of self with the given attributes replaced. ) ÚcopyÚdeepcopyr†r(rirèr)r*r+r,) r…r†r(rirèr)r*r+r,rúr Úresultr6r6r7r§¥s(  zTarInfo.replacecCs‚|jdkrd}n |jd@}|j||j|j|j|j|j|j|j|j |j |j |j dœ }|dt kr~|djdƒ r~|dd7<|S)z9Return the TarInfo's attributes as a dictionary. Niÿ) r†rir)r*r'r(rýrþrèr+r,rÿrrþr†rå)rir†r)r*r'r(rýrþrèr+r,rÿrÚDIRTYPEr­)r…riÚinfor6r6r7Úget_infoÁs&   zTarInfo.get_infoÚsurrogateescapecCs~|jƒ}x(|jƒD]\}}|dkrtd|ƒ‚qW|tkrH|j|||ƒS|tkr^|j|||ƒS|tkrr|j||ƒStdƒ‚dS)ztdƒ‚t|dd…ƒ}|t|ƒkrbt dƒ‚|ƒ}t |dd…||ƒ|_ t|dd …ƒ|_ t|d d …ƒ|_ t|d d …ƒ|_t|d d …ƒ|_t|d d…ƒ|_||_|dd …|_t |d d…||ƒ|_t |dd…||ƒ|_t |dd…||ƒ|_t|dd…ƒ|_t|dd…ƒ|_t |dd…||ƒ}|�rŒ|jtk�rŒ|j jdƒ�rŒt|_|jtk�rs zTarInfo._proc_builtinc CsŠ|jj|j|jƒƒ}y|j|dd�}Wntk rBtdƒ‚YnX|j|_|jt krjt ||j |j ƒ|_ n|jtkr†t ||j |j ƒ|_|S)zSProcess the blocks that hold a GNU longname or longlink member. F)rBz missing or bad subsequent header)r•r[r_r'rVr ryrÄrþr#r=r4r5r†r"rè)r…rÙrUÚnextr6r6r7rYOs  zTarInfo._proc_gnulongc CsÞ|j\}}}|`xœ|r¬|jjtƒ}d}xvtdƒD]j}y0t|||d…ƒ}t||d|d…ƒ} Wntk rzPYnX|r’| r’|j|| fƒ|d7}q0Wt|dƒ}qW||_ |jj ƒ|_ |j |j |j ƒ|_||_ |S)z8Process a GNU sparse header plus extra headers. rér%rJiø)rr•r[r¾rErKr.rºrNr×r¶rÖr_r'rÄ) r…rÙrRrTrUrUr–rJrÄrSr6r6r7rZes(    zTarInfo._proc_sparsec CsÚ|jj|j|jƒƒ}|jtkr&|j}n |jjƒ}d}d}g}�x0t|ƒ|koV||dk�rnt j ||ƒ}|srt dƒ‚yt |j dƒƒ}Wntk r t dƒ‚YnX|dkr²t dƒ‚||t|ƒkrÊt dƒ‚|jdƒ|d} ||jdƒd| …} | jdƒ\} } } | �s"| dk�s"|| dk�r*t dƒ‚|j|| | fƒ| dk�rd|dk�rd| d k�r`|j}nd }||7}q@W|dk�r~d }x`|D]X\}} } |j| d d |jƒ}|tk�rÀ|j| ||j|jƒ}n|j| d d |jƒ}|||<�q„Wy|j|d d �}Wntk �rtd ƒ‚YnXd|k�r*|j||ƒnFd|k�rB|j||ƒn.|jdƒdk�rp|jdƒdk�rp|j|||ƒ|jttfk�rÖ|j ||j|jƒ|j!|_!d|k�rÖ|j"}|j#ƒ�sÀ|jt$k�rÐ||j|jƒ7}||_!|S)zVProcess an extended or global header as described in POSIX.1-2008. rNzinvalid headerr#ér<r¿s hdrcharsetsBINARYzutf-8F)rBz missing or bad subsequent headerzGNU.sparse.mapzGNU.sparse.sizezGNU.sparse.majorÚ1zGNU.sparse.minorrDr')%r•r[r_r'rþr1rr r0Ú_header_length_prefix_reÚmatchrHrFÚgroupr.rÒrlÚ partitionrºr4Ú_decode_pax_fieldr5ÚPAX_NAME_FIELDSrVr ryÚ_proc_gnusparse_01Ú_proc_gnusparse_00r6Ú_proc_gnusparse_10r/r[r`rÄrÖrïr^)r…rÙrUrr–r4Ú raw_headersrfr3Zheader_value_end_offsetZkeyword_and_valueZ raw_keywordZequalsZ raw_valuer>rrarÄr6r6r7r\�sx                 zTarInfo._proc_paxc Csªg}g}xŒ|D]„\}}}|dkrVy|jt|jƒƒƒWq’tk rRtdƒ‚Yq’Xq|dkry|jt|jƒƒƒWqtk r�tdƒ‚YqXqWtt||ƒƒ|_dS)z?Process a GNU tar extended sparse header, version 0.0. sGNU.sparse.offsetzinvalid headersGNU.sparse.numbytesN)rºrFr;r.rHÚlistÚzipr×)r…rarnZoffsetsrSÚ_r>rr6r6r7rlûszTarInfo._proc_gnusparse_00cCs@dd„|djdƒDƒ}tt|ddd…|ddd…ƒƒ|_dS)z?Process a GNU tar extended sparse header, version 0.1. cSsg|] }t|ƒ‘qSr6)rF)Ú.0Úxr6r6r7ú sz.TarInfo._proc_gnusparse_01..zGNU.sparse.mapú,Nr$r#)r4rorpr×)r…rarr×r6r6r7rkszTarInfo._proc_gnusparse_01cCs¬d}g}|jjtƒ}|jddƒ\}}t|ƒ}xJt|ƒ|dkrvd|krV||jjtƒ7}|jddƒ\}}|jt|ƒƒq.W|jjƒ|_t t |ddd…|ddd…ƒƒ|_ dS)z?Process a GNU tar extended sparse header, version 1.0. Nr=r#r$) r•r[r¾r4rFr0rºr¶rÖrorpr×)r…rarrÙZfieldsr×rUZnumberr6r6r7rms  zTarInfo._proc_gnusparse_10c CsÆx¶|jƒD]ª\}}|dkr(t|d|ƒq |dkrBt|dt|ƒƒq |dkr\t|dt|ƒƒq |tkr |tkr–yt||ƒ}Wntk r”d}YnX|dkr¨|jdƒ}t|||ƒq W|jƒ|_dS) zoReplace fields with supplemental information from a previous pax extended or global header. zGNU.sparse.namer%zGNU.sparse.sizer'zGNU.sparse.realsizerråN) rÚsetattrrFÚ PAX_FIELDSÚPAX_NUMBER_FIELDSr.rOr r)r…rr4r5r>rr6r6r7r`%s"  zTarInfo._apply_pax_infoc Cs.y |j|dƒStk r(|j||ƒSXdS)z1Decode a single field from a pax record. rCN)r;ÚUnicodeDecodeError)r…rr4Zfallback_encodingZfallback_errorsr6r6r7ri<s zTarInfo._decode_pax_fieldcCs2|dkrtdƒ‚t|tƒ\}}|r*|d7}|tS)z_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. rzinvalid offsetr#)rHrZr¾)r…rKrarbr6r6r7r_Ds zTarInfo._blockcCs |jtkS)N)rþÚ REGULAR_TYPES)r…r6r6r7rïPsz TarInfo.isregcCs|jƒS)N)rï)r…r6r6r7ÚisfileRszTarInfo.isfilecCs |jtkS)N)rþr)r…r6r6r7rñTsz TarInfo.isdircCs |jtkS)N)rþÚSYMTYPE)r…r6r6r7ròVsz TarInfo.issymcCs |jtkS)N)rþÚLNKTYPE)r…r6r6r7rðXsz TarInfo.islnkcCs |jtkS)N)rþr7)r…r6r6r7ÚischrZsz TarInfo.ischrcCs |jtkS)N)rþr8)r…r6r6r7Úisblk\sz TarInfo.isblkcCs |jtkS)N)rþÚFIFOTYPE)r…r6r6r7Úisfifo^szTarInfo.isfifocCs |jdk S)N)r×)r…r6r6r7Úissparse`szTarInfo.issparsecCs|jtttfkS)N)rþr7r8r€)r…r6r6r7Úisdevbsz TarInfo.isdevN)r†rir)r*r'r(rýrþrèr+r,rÿrrÄrÖrr×rÙrr)r‹)8rrrsrtruÚ __slots__r‡rrÚpropertyr%rrr&r r r§rrr rrrrÚ classmethodr3rÚ staticmethodrr:r!r.rAr@rWrVrXr]rYrZr\rlrkrmr`rir_rïr{rñròrðr~rr�r‚rƒr6r6r6r7rnsn    1  *  3 C  z c @sþeZdZdZdZdZdZdZeZ e Z dZ e ZeZdZdkdd „Zedddefd d „ƒZedld d „ƒZedmdd„ƒZedndd„ƒZedodd„ƒZdddddœZdd„Zdd„Zdd„Zd d!„Zdpd"d#„Zdqdd%œd&d'„Z drdd(œd)d*„Z!dsd+d,„Z"d-d.„Z#dtddd0œd1d2„Z$d3d4„Z%duddd0œd6d7„Z&d8d9„Z'dvd:d;„Z(dd?„Z*d@dA„Z+dwdddBœdCdD„Z,dEdF„Z-dGdH„Z.dIdJ„Z/dKdL„Z0dMdN„Z1dOdP„Z2dQdR„Z3dSdT„Z4dUdV„Z5dWdX„Z6dYdZ„Z7dxd[d\„Z8d]d^„Z9dyd_d`„Z:dadb„Z;dcdd„Zdidj„Z?dS)zrz=The TarFile Class provides an interface to tar archives. rFr#Nr{rcCs°dddddœ}||krtdƒ‚||_|||_|sj|jdkrVtjj|ƒ rVd|_d|_t||jƒ}d |_n@|d kr’t|d ƒr’t |j t t fƒr’|j }t|d ƒr¤|j|_d |_|rºtjj |ƒnd |_ ||_|d k rÔ||_|d k râ||_|d k rð||_|d k �r||_|d k �r||_| |_| d k �r4|jtk�r4| |_ni|_| d k �rJ| |_| d k �rZ| |_| |_d |_g|_d |_|jjƒ|_i|_�yþ|jdk�r¤d |_ |j!ƒ|_ |jdk�r8x†|jj"|jƒy|jj#|ƒ}|jj$|ƒWnTt%k �r|jj"|jƒPYn0t&k �r0}zt't |ƒƒ‚WYd d }~XnX�q²W|jdk�r‚d |_|j�r‚|jj(|jj)ƒƒ}|jj*|ƒ|jt+|ƒ7_Wn&|j�sž|jj,ƒd |_‚YnXd S)aÖ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. Úrbzr+bÚwbZxb)r{Úar|rsz!mode must be 'r', 'a', 'w' or 'x'rŠr|FNr†riTr{rs)rŠr|rs)-r.riÚ_moder~r%ÚexistsÚ bltn_openr‘rƒr+r†r-rLÚabspathr•rPrÚÚ dereferenceÚ ignore_zerosr4r5rrÚdebugÚ errorlevelÚ copybufsizer—ÚmembersÚ_loadedr¶rÄÚinodesÚ firstmemberrar¸rWrºrxr rr3r r\r0rˆ)r…r†rir•rPrÚr�r�r4r5rr‘r’r“ZmodesÚerUr6r6r7r‡‚sŠ             $   zTarFile.__init__c sº| r| rtdƒ‚|dkrª‡fdd„}xttˆj|d�D]b}tˆˆj|ƒ}|dk r\|jƒ} y||d|f|ŽSttfk r˜|dk r’|j| ƒw8Yq8Xq8Wtdƒ‚�nd |k�r |jd d ƒ\} }| pÊd} |pÒd }|ˆjkrðtˆˆj|ƒ}n td |ƒ‚||| |f|ŽSd |k�r’|jd d ƒ\} }| �p.d} |�p8d }| dk�rLtdƒ‚t || |||ƒ} yˆ|| | f|Ž} Wn| j ƒ‚YnXd| _ | S|dk�r®ˆj |||f|ŽStdƒ‚dS)a¥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 'r:xz' open for reading with lzma 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 'w:xz' open for writing with lzma compression 'x' or 'x:' create a tarfile exclusively without compression, raise an exception if the file is already created 'x:gz' create a gzip compressed tarfile, raise an exception if the file is already created 'x:bz2' create a bzip2 compressed tarfile, raise an exception if the file is already created 'x:xz' create an lzma compressed tarfile, raise an exception if the file is already created '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 'r|xz' open an lzma 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 'w|xz' open an lzma compressed stream for writing znothing to openr{úr:*csˆj|dkS)NÚtaropen)Ú OPEN_METH)r”)r2r6r7Únot_compressedsz$TarFile.open..not_compressed)ÚkeyNz%file could not be opened successfullyú:r#r�zunknown compression type %rú|r|zmode must be 'r' or 'w'FrŠrszundiscernible mode)r{r™)r{r|)rŠr|rs) r.Úsortedr›rmr¶rrr¸r4r‰rˆr‘rš) r2r†rir•r`Úkwargsrœr”ÚfuncZ saved_posrhÚstreamr¼r6)r2r7rñsP%             z TarFile.opencKs |dkrtdƒ‚||||f|ŽS)zCOpen uncompressed tar archive name for reading or writing. r{rŠr|rsz!mode must be 'r', 'a', 'w' or 'x')r{rŠr|rs)r.)r2r†rir•r¡r6r6r7ršLszTarFile.taropenr¥cKsð|d krtdƒ‚yddl}|jWn ttfk rBtdƒ‚YnXy|j||d||ƒ}Wn.tk rŠ|dk r„|dkr„td ƒ‚‚YnXy|j|||f|Ž}WnBtk rÐ|j ƒ|dkrÊtd ƒ‚‚Yn|j ƒ‚YnXd |_ |S) zkOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. r{r|rszmode must be 'r', 'w' or 'x'rNzgzip module is not availablercznot a gzip fileF)r{r|rs) r.ÚgzipZGzipFiler™ÚAttributeErrorrr¡rršrˆr‘)r2r†rir•Ú compresslevelr¡r¤r¼r6r6r7ÚgzopenTs2 zTarFile.gzopencKs¶|d krtdƒ‚y ddl}Wntk r8tdƒ‚YnX|j|pD|||d�}y|j|||f|Ž}WnFttfk r–|jƒ|dkr�t d ƒ‚‚Yn|jƒ‚YnXd |_ |S) zlOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. r{r|rszmode must be 'r', 'w' or 'x'rNzbz2 module is not available)r¦znot a bzip2 fileF)r{r|rs) r.rŽr™rZBZ2Fileršr¡ÚEOFErrorrˆrr‘)r2r†rir•r¦r¡rŽr¼r6r6r7Úbz2openvs(  zTarFile.bz2opencKs¸|d krtdƒ‚y ddl}Wntk r8tdƒ‚YnX|j|pD|||d�}y|j|||f|Ž}WnH|jtfk r˜|jƒ|dkr’t d ƒ‚‚Yn|jƒ‚YnXd |_ |S) zkOpen lzma compressed tar archive name for reading or writing. Appending is not allowed. r{r|rszmode must be 'r', 'w' or 'x'rNzlzma module is not available)Úpresetznot an lzma fileF)r{r|rs) r.r¢r™rZLZMAFileršr£r¨rˆrr‘)r2r†rir•rªr¡r¢r¼r6r6r7Úxzopen“s& zTarFile.xzopenršr§r©r«)r�r�rŽr�c Csˆ|jr dSd|_z`|jdkrn|jjttdƒ|jtd7_t|jtƒ\}}|dkrn|jjtt|ƒWd|j s‚|jj ƒXdS) zlClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NTrŠr|rsr$r)rŠr|rs) r—rir•r\r1r¾rÄrZÚ RECORDSIZEr‘rˆ)r…rarbr6r6r7rˆºs z TarFile.closecCs"|j|ƒ}|dkrtd|ƒ‚|S)aReturn 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. Nzfilename %r not found)Ú _getmemberÚKeyError)r…r†rÚr6r6r7Ú getmemberÏs  zTarFile.getmembercCs|jƒ|js|jƒ|jS)zŽReturn the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive. )Ú_checkr•Ú_loadr”)r…r6r6r7Ú getmembersÚszTarFile.getmemberscCsdd„|jƒDƒS)z‹Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). cSsg|] }|j‘qSr6)r†)rrrÚr6r6r7rtèsz$TarFile.getnames..)r²)r…r6r6r7ÚgetnamesäszTarFile.getnamesc Csp|jdƒ|dk r|j}|dkr$|}tjj|ƒ\}}|jtjdƒ}|jdƒ}|jƒ}||_ |dkrŒt tdƒr€|j r€tj |ƒ}qštj |ƒ}ntj|jƒƒ}d}|j}t j|ƒ�r|j|jf} |j rö|jdkrö| |jkrö||j| kröt} |j| }nt} | d�rx||j| <nht j|ƒ�r"t} nVt j|ƒ�r4t} nDt j|ƒ�rPt} tj|ƒ}n(t j|ƒ�rbt } nt j!|ƒ�rtt"} ndS||_||_#|j$|_%|j&|_'| tk�r¨|j(|_)nd|_)|j*|_+| |_,||_-t.�röyt.j/|j%ƒd|_0Wnt1k �rôYnXt2�r*yt2j3|j'ƒd|_4Wnt1k �r(YnX| t t"fk�rlt tdƒ�rlt td ƒ�rltj5|j6ƒ|_7tj8|j6ƒ|_9|S) aÒCreate a TarInfo object from the result of os.stat or equivalent on an existing file. The file is either named by `name', or specified as a file object `fileobj' with a file descriptor. If given, `arcname' specifies an alternative name for the file in the archive, otherwise, the name is taken from the 'name' attribute of 'fileobj', or the 'name' argument. The name should be a text string. ÚawxNråÚlstatr‹r#rÚmajorÚminor):r°r†r~r%Ú splitdriver§rërìrÚrÙrƒr�rµrgÚfstatÚfilenoÚst_modeÚS_ISREGÚst_inoÚst_devÚst_nlinkr–r}rÚS_ISDIRrÚS_ISFIFOr€ÚS_ISLNKr|ÚreadlinkÚS_ISCHRr7ÚS_ISBLKr8riÚst_uidr)Úst_gidr*Úst_sizer'Úst_mtimer(rþrèÚpwdÚgetpwuidr+r®ÚgrpZgetgrgidr,r¶Úst_rdevrÿr·r) r…r†Úarcnamer•ZdrvrÚZstatresrèZstmdÚinoderþr6r6r7Ú gettarinfoês~                 zTarFile.gettarinfoT)r”cCs0|jƒ|dkr|}�x|D�] }|rÒ|jdkr:tdƒnttj|jƒƒtd|jpX|j|jpb|jfƒ|j ƒsz|j ƒr”tdd|j |j fƒntd|j ƒ|jdkr¶tdƒntdtj|jƒdd …ƒt|j|jƒräd nd ƒ|�r"|jƒ�r td |jƒ|jƒ�r"td |jƒtƒqWdS)aPrint 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. `members' is optional and must be a subset of the list returned by getmembers(). Nz ??????????z%s/%sz%10sz%d,%dz%10dz????-??-?? ??:??:??z%d-%02d-%02d %02d:%02d:%02dr±rår‹z-> zlink to )r°rirqrgrhr+r)r,r*r~rrÿrr'r(r«Z localtimer†rñròrèrðrp)r…Úverboser”rÚr6r6r7roNs2      z TarFile.list)Úfilterc Csv|jdƒ|dkr|}|dk rPddl}|jdtdƒ||ƒrP|jdd|ƒdS|jdk r€tjj|ƒ|jkr€|jdd|ƒdS|jd|ƒ|j ||ƒ}|dkr´|jdd |ƒdS|dk rà||ƒ}|dkrà|jdd|ƒdS|j ƒ�rt |d ƒ�}|j ||ƒWdQRXnd|j ƒ�rh|j |ƒ|�rrxHtj|ƒD].}|jtjj||ƒtjj||ƒ|||d ��q4Wn |j |ƒdS) a~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. r´Nrzuse the filter argument insteadr$ztarfile: Excluded %rztarfile: Skipped %rr#ztarfile: Unsupported type %rrˆ)rÒ)r°rdrerfÚ_dbgr†r~r%rŽrÐrïr�ÚaddfilerñÚlistdirÚaddr») r…r†rÎÚ recursiveZexcluderÒrdrÚÚfr6r6r7rÖtsB       z TarFile.addcCs¾|jdƒtj|ƒ}|j|j|j|jƒ}|jj|ƒ|jt |ƒ7_|j }|dk r®t ||j|j |d�t |j tƒ\}}|dkrœ|jjtt|ƒ|d7}|j|t7_|jj|ƒdS)aAdd the TarInfo object `tarinfo' to the archive. If `fileobj' is given, it should be a binary file, and tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects directly, or by using gettarinfo(). r´N)r`rr#)r°r rrPr4r5r•r\rÄr0r“rYr'rZr¾r1r”rº)r…rÚr•rUr`rarbr6r6r7rÔ±s   zTarFile.addfilec Csp|dkr0|j}|dkrtSt|tƒr,tdƒ‚|St|ƒr<|Syt|Stk rjtd|›d�ƒd‚YnXdS)Nz#String names are not supported for z2TarFile.extraction_filter. Use a function such as ztarfile.data_filter directly.zfilter z not foundzUString names are not supported for TarFile.extraction_filter. Use a function such as zrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.) Úextraction_filterrùr+r-Ú TypeErrorÚcallableÚ_NAMED_FILTERSr®r.)r…rÒr6r6r7Ú_get_filter_functionÊs zTarFile._get_filter_functionÚ.)Ú numeric_ownerrÒc"Cs®g}|j|ƒ}|dkr|}xT|D]L}|j|||ƒ\}} |dkr@q |jƒrR|j| ƒ|j|||jƒ ||d�q W|jdd„dd��x$|D�]} yæy|| |ƒ}Wn4tk rÔ} z|j| t| ƒƒwŠWYdd} ~ XnX|dkrì|j| dƒwŠt j j ||j ƒ} yt j | ƒ} Wn$tk �r.|j|dƒwŠYnXtj| jƒ�sL|j|d ƒwŠ|j|| |d �|j|| ƒ|j|| ƒWqŠtk �r¤} z|j| ƒWYdd} ~ XqŠXqŠWdS) a˜Extract 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(). If `numeric_owner` is True, only the numbers for user/group names are used and not the names. The `filter` function will be called on each member just before extraction. It can return a changed TarInfo or None to skip the member. String names of common filters are accepted. N)Ú set_attrsrßÚfilter_functioncSs|jS)N)r†)rŠr6r6r7Úÿsz$TarFile.extractall..T)r�Úreversezexcluded by filterZmissingznot a directory)rß)rÝÚ_get_extract_tarinforñrºÚ _extract_oneÚsortÚ_FILTER_ERRORSÚ_log_no_directory_fixupÚreprr~r%r»r†rµÚFileNotFoundErrorrgrÀr»ÚchownÚutimeÚchmodr Ú_handle_nonfatal_error)r…r%r”rßrÒZ directoriesrárõrÚÚ unfilteredÚexcÚdirpathrµr˜r6r6r7Ú extractallÜsP       zTarFile.extractallcCs|jdd|j|fƒdS)Nr$z(tarfile: Not fixing up directory %r (%s))rÓr†)r…rõÚreasonr6r6r7rè! szTarFile._log_no_directory_fixupr‹c Cs8|j|ƒ}|j|||ƒ\}}|dk r4|j||||ƒdS)a¯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'. File attributes (owner, mtime, mode) are set unless `set_attrs' is False. If `numeric_owner` is True, only the numbers for user/group names are used and not the names. The `filter` function will be called before extraction. It can return a changed TarInfo or None to skip the member. String names of common filters are accepted. N)rÝrärå) r…rõr%ràrßrÒrárÚrïr6r6r7Úextract% s  zTarFile.extractcCsÒt|tƒr|j|ƒ}n|}d}y|||ƒ}WnZttfk r\}z|j|ƒWYdd}~Xn,tk r†}z|j|ƒWYdd}~XnX|dkr¦|jdd|j ƒdS|j ƒrÊt j |ƒ}t j j||jƒ|_||fS)zŠGet (filtered, unfiltered) TarInfos from *member* *member* might be a string. Return (None, None) if not found. Nr$ztarfile: Excluded %r)NN)r+r-r¯r¡rÝÚ_handle_fatal_errorr rîrÓr†rðr r~r%r»rèr)r…rõrár%rïÚfilteredr˜r6r6r7rä9 s"   zTarFile._get_extract_tarinfocCsŒ|jdƒy&|j|tjj||jƒ||||d�WnVtk r\}z|j|ƒWYdd}~Xn,tk r†}z|j |ƒWYdd}~XnXdS)z±Extract from filtered tarinfo to disk. filter_function is only used when extracting a *different* member (e.g. as fallback to creating a symlink) r{)ràrßráÚextraction_rootN) r°Ú_extract_memberr~r%r»r†r¡rõr rî)r…rÚr%ràrßrár˜r6r6r7råW s  zTarFile._extract_onecCs"|jdkr‚n|jdd|ƒdS)z=Handle non-fatal error (ExtractError) according to errorlevelr#z tarfile: %sN)r’rÓ)r…r˜r6r6r7rîk s zTarFile._handle_nonfatal_errorcCsn|jdkr‚n\t|tƒrP|jdkr6|jdd|jƒqj|jdd|j|jfƒn|jddt|ƒj|fƒdS)z1Handle "fatal" error according to self.errorlevelrNr#z tarfile: %sztarfile: %s %rztarfile: %s %s)r’r+r¡ÚfilenamerÓÚstrerrorrþrr)r…r˜r6r6r7rõr s   zTarFile._handle_fatal_errorcCs‚|jdƒt|tƒr |j|ƒ}n|}|jƒs6|jtkrB|j||ƒS|jƒsR|j ƒrzt|j t ƒrht dƒ‚q~|j |j|ƒƒSndSdS)zü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 or a link, an io.BufferedReader object is returned. Otherwise, None is returned. r{z'cannot extract (sym)link as file objectN)r°r+r-r¯rïrþr^Ú fileobjectrðròr•r‰r Ú extractfileÚ_find_link_target)r…rõrÚr6r6r7rü~ s      zTarFile.extractfile)rár÷cCs\|jdƒ}|jdtjƒ}tjj|ƒ}|r@tjj|ƒ r@tj|ƒ|jƒsP|j ƒrj|j dd|j |j fƒn|j d|j ƒ|j ƒrŽ|j||ƒn”|jƒr¤|j||ƒn~|jƒrº|j||ƒnh|jƒsÊ|jƒrØ|j||ƒnJ|jƒsè|j ƒrü|j||||d�n&|jtk�r|j||ƒn |j||ƒ|�rX|j|||ƒ|j ƒ�sX|j||ƒ|j||ƒdS)zçExtract the filtered TarInfo object tarinfo to a physical file called targetpath. filter_function is only used when extracting a *different* member (e.g. as fallback to creating a symlink) rår#z%s -> %s)rár÷N)rOr§r~rër%rôrŒÚmakedirsrðròrÓr†rèrïÚmakefilerñÚmakedirr�Úmakefifor~rÚmakedevÚmakelink_with_filterrþr^Ú makeunknownrërírì)r…rÚÚ targetpathràrßrár÷Z upperdirsr6r6r7rø� s:        zTarFile._extract_memberc Cs@y&|jdkrtj|ƒn tj|dƒWntk r:YnXdS)z,Make a directory called targetpath. NiÀ)rir~ÚmkdirÚFileExistsError)r…rÚrr6r6r7rÕ s   zTarFile.makedircCs’|j}|j|jƒ|j}t|dƒ�f}|jdk rrx,|jD]"\}}|j|ƒt|||t|ƒq6W|j|jƒ|j ƒnt|||jt|ƒWdQRXdS)z'Make a file called targetpath. r‰N) r•r¸rÖr“r�r×rYrr'Útruncate)r…rÚrÚsourcer`ÚtargetrÄr'r6r6r7rÿã s      zTarFile.makefilecCs"|j||ƒ|jdd|jƒdS)zYMake a file from a TarInfo object with an unknown type at targetpath. r#z9tarfile: Unknown file type %r, extracted as regular file.N)rÿrÓrþ)r…rÚrr6r6r7ró s zTarFile.makeunknowncCs"ttdƒrtj|ƒntdƒ‚dS)z'Make a fifo called targetpath. Úmkfifozfifo not supported by systemN)rƒr~r r )r…rÚrr6r6r7rû s  zTarFile.makefifocCsnttdƒ sttdƒ r tdƒ‚|j}|dkr2d}|jƒrF|tjO}n |tjO}tj||tj |j |j ƒƒdS)zzFilter for extraction)ÚmetavarÚchoicesr-z-lz--listú zShow listing of a tarfile)r.r-z-ez --extractú+ú zExtract tarfile into target dir)Únargsr.r-z-cz--createúúzCreate tarfile from sourcesz-tz--testzTest if a tarfile is validr#z&--filter is only valid for extraction r{)r"z{!r} is a tar archive.z{!r} is not a tar archive. zr:*)rÑr$)r%rÒrÞz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.r�r�rŽ)z.gzz.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:r|z{!r} file created.)r0r2)r4r5)ÚargparseÚArgumentParserÚ add_argumentrÜZadd_mutually_exclusive_groupÚ parse_argsrÒrôÚexitZtestrrr²rprnr#rÑrProrr0r~ÚcurdirZ format_helpròZcreateÚpopr%ÚsplitextrÖ)r6r)ÚparserrgÚargsr]r�Ztfr;r%Ztar_namerqZextZ compressionsZtar_modeZ tar_filesÚ file_namer6r6r7ÚmainM s’                  rAÚ__main__)r%r&r'r(r)r*r+r,)T)rruÚversionÚ __author__Z__date__Z __cvsid__Ú __credits__Úbuiltinsrr�rnr~rËrXrgr«rSr ÚrerdrÊr™rÌr¥ÚNotImplementedErrorrr¡Ú NameErrorÚ__all__r1r¾r¬r rrrr5rrLr}r|r7r8rr€ZCONTTYPEr#r"rMr/r1r[r rrrr^rzrPrwrjr,rFrxr†r Úgetfilesystemencodingr8r=rKrQrVrYrhrqÚ Exceptionrr rrr r rvrwrxrHryrzr‰Úobjectr’rÃÚBufferedReaderrÕÚcompilererÝrÞrßrárârãrärçrørùrûrürÜr rrrrArrr6r6r6r7Ús          yh   D}b b