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
 lŽŒY‚kã@sÔdZdZdZdZdZdZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZyddlZddlZWnek rÚdZZYnXeefZyeef7ZWnek r YnXd d d d gZd ZdZedZdZdZdZ dZ!dZ"dZ#d Z$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/d Z0d!Z1dZ2d"Z3d#Z4e3Z5e#e$e%e&e)e*e+e'e(e,e-e.f Z6e#e$e+e.fZ7e,e-e.fZ8d$d%d&d'd(d)d*d+fZ9d$d%d*d+hZ:d,e;d-e;d'e;d(e<d)e<d&e<iZ=e j>d.d/fkrˆd0Z?n e j@ƒZ?d1d2„ZAd3d4„ZBd5d6„ZCd7e5d8d9„ZDd:d;„ZEded<d=„ZFd>d?„ZGd@dA„ZHGdBd „d eIƒZJGdCdD„dDeJƒZKGdEdF„dFeJƒZLGdGdH„dHeJƒZMGdIdJ„dJeJƒZNGdKdL„dLeJƒZOGdMdN„dNeOƒZPGdOdP„dPeOƒZQGdQdR„dReOƒZRGdSdT„dTeOƒZSGdUdV„dVeOƒZTGdWdX„dXƒZUGdYdZ„dZƒZVGd[d\„d\eWƒZXGd]d^„d^eWƒZYGd_d`„d`e jZƒZ[Gdad „d eWƒZ\Gdbd „d eWƒZ]Gdcdd„ddƒZ^ded „Z_e]jZdfdg„Z`eadhkrÐe`ƒdS)iz,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ÚTarErrorsiésustar sustar00édé›ó0ó1ó2ó3ó4ó5ó6ó7óLóKóSóxógóXééÚpathÚlinkpathÚsizeÚmtimeÚuidÚgidÚunameÚgnameZatimeÚctimeÚntZcezutf-8cCs2|j||ƒ}|d|…|t|ƒtS)z8Convert a string to a null-terminated bytes object. N)ÚencodeÚlenÚNUL)ÚsÚlengthÚencodingÚerrors©r+ú&/opt/python35/lib/python3.5/tarfile.pyÚstn™sr-cCs;|jdƒ}|dkr+|d|…}|j||ƒS)z8Convert a null-terminated bytes object to a string. srNéÿÿÿÿ)ÚfindÚdecode)r'r)r*Úpr+r+r,ÚntsŸs r2c CsÕ|dd krd}x:tt|ƒdƒD]"}|dK}|||d7}q-W|ddkrÑdt|ƒd| }nRy1t|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)r3r4)Úranger%r2ÚintÚstripÚ ValueErrorÚInvalidHeaderError)r'ÚnÚir+r+r,Únti§s  rAr5cCsd|kod|dknrNtd|dt|ƒfdƒt}n¼|tkrþd|d |ko‚d|dknrþ|dkr¥tdgƒ}ntdgƒ}d||}xEt|dƒD]$}|jd|d@ƒ|dL}qÓWn td ƒ‚|S) z/Convert a python number to a number field. rr5rz%0*or7r6r3r4zoverflow in number field)Úbytesr;r&Ú GNU_FORMATÚ bytearrayr:Úinsertr=)r?ÚdigitsÚformatr'r@r+r+r,Úitn»s $*9  rHcCsBdttjd|ƒƒ}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. r6Z 148B8x356BZ 148b8x356b)ÚsumÚstructÚ unpack_from)ÚbufZunsigned_chksumZ signed_chksumr+r+r,Ú calc_chksums×s rMc Csæ|dkrdS|dkr0tj||ƒdSd}t||ƒ\}}xNt|ƒD]@}|j|ƒ}t|ƒ|kr‹|dƒ‚|j|ƒqXW|dkrâ|j|ƒ}t|ƒ|krÕ|dƒ‚|j|ƒdS)zjCopy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. rNéizunexpected end of datai@)ÚshutilÚ copyfileobjÚdivmodr:Úreadr%Úwrite) ÚsrcÚdstr(Ú exceptionÚBUFSIZEÚblocksÚ remainderÚbrLr+r+r,rPäs$      rPcCs,ddl}|jdtdƒtj|ƒS)z/Deprecated in this location; use stat.filemode.rNz$deprecated in favor of stat.filemoder)ÚwarningsÚwarnÚDeprecationWarningÚstatÚfilemode)Úmoder[r+r+r,r_ýs   r_cCsPttjddƒ}|dk r<|j|dƒj|ƒ}t|ddƒdS)Nr)ÚbackslashreplaceÚendú )ÚgetattrÚsysÚstdoutr$r0Úprint)r'r)r+r+r,Ú _safe_prints rhc@seZdZdZdS)rzBase exception.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r+r+r+r,r s c@seZdZdZdS)Ú ExtractErrorz%General exception for extract errors.N)rirjrkrlr+r+r+r,rms rmc@seZdZdZdS)Ú ReadErrorz&Exception for unreadable tar archives.N)rirjrkrlr+r+r+r,rns rnc@seZdZdZdS)ÚCompressionErrorz.Exception for unavailable compression methods.N)rirjrkrlr+r+r+r,ros roc@seZdZdZdS)Ú StreamErrorz=Exception for unsupported operations on stream-like TarFiles.N)rirjrkrlr+r+r+r,rps rpc@seZdZdZdS)Ú HeaderErrorz!Base exception for header errors.N)rirjrkrlr+r+r+r,rqs rqc@seZdZdZdS)ÚEmptyHeaderErrorzException for empty headers.N)rirjrkrlr+r+r+r,rrs rrc@seZdZdZdS)ÚTruncatedHeaderErrorz Exception for truncated headers.N)rirjrkrlr+r+r+r,rs s rsc@seZdZdZdS)ÚEOFHeaderErrorz"Exception for end of file headers.N)rirjrkrlr+r+r+r,rt#s rtc@seZdZdZdS)r>zException for invalid headers.N)rirjrkrlr+r+r+r,r>&s r>c@seZdZdZdS)ÚSubsequentHeaderErrorz3Exception for missing and invalid extended headers.N)rirjrkrlr+r+r+r,ru)s ruc@sFeZdZdZdd„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. cCsbdtjdtjtjBtjBi|}ttdƒrF|tjO}tj||dƒ|_dS)NÚrÚwÚO_BINARYi¶) ÚosÚO_RDONLYÚO_WRONLYÚO_CREATÚO_TRUNCÚhasattrryrÚfd)ÚselfÚnamer`r+r+r,Ú__init__6s   z_LowLevelFile.__init__cCstj|jƒdS)N)rzÚcloser€)r�r+r+r,r„?sz_LowLevelFile.closecCstj|j|ƒS)N)rzrRr€)r�rr+r+r,rRBsz_LowLevelFile.readcCstj|j|ƒdS)N)rzrSr€)r�r'r+r+r,rSEsz_LowLevelFile.writeN)rirjrkrlrƒr„rRrSr+r+r+r,rv0s   rvc@s¬eZdZdZdd„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|_|dkr-t||ƒ}d|_|dkrQt|ƒ}|jƒ}|pZd|_||_||_||_||_d|_ d|_ d|_ y«|dkr,yddl }Wnt k rÞtd ƒ‚YnX||_ |jdƒ|_|d kr|jƒ|j|_qI|jƒn|d kr«yddl}Wnt k rhtd ƒ‚YnX|d kr™d|_|jƒ|_t|_qI|jƒ|_nž|d kr-yddl}Wnt k rçtdƒ‚YnX|d krd|_|jƒ|_|j|_qI|jƒ|_n|dkrItd|ƒ‚Wn*|jsf|jjƒd|_ ‚YnXdS)z$Construct a _Stream object. TNFÚ*ÚórÚgzzzlib module is not availablerwÚbz2zbz2 module is not availableÚxzzlzma module is not availableÚtarzunknown compression type %r) Ú _extfileobjrvÚ _StreamProxyÚ getcomptyper‚r`ÚcomptypeÚfileobjÚbufsizerLÚposÚclosedÚzlibÚ ImportErrorroÚcrc32ÚcrcÚ _init_read_gzÚerrorrVÚ_init_write_gzrŠÚdbufÚBZ2DecompressorÚcmpÚOSErrorÚ BZ2CompressorÚlzmaZLZMADecompressorÚ LZMAErrorZLZMACompressorr„) r�r‚r`r�r‘r’r•rŠr¡r+r+r,rƒSsl                                z_Stream.__init__cCs't|dƒr#|j r#|jƒdS)Nr”)rr”r„)r�r+r+r,Ú__del__™sz_Stream.__del__cCs³|jjd|jj|jj |jjdƒ|_tjdtt j ƒƒƒ}|j d|dƒ|j j dƒr�|j dd …|_ |j |j j d d ƒtƒdS) z6Initialize for writing with gzip compression. é rzd?„Zd@dA„Z dBdC„Z!dDdE„Z"dFdG„Z#dHdI„Z$dJdK„Z%dLdM„Z&dNdO„Z'dPdQ„Z(dRdS„Z)dTdU„Z*dVdW„Z+dXdY„Z,dZd[„Z-d\d]„Z.d^d_„Z/d`da„Z0dbdc„Z1ddde„Z2dfdg„Z3dhS)jraInformational 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‚r`rrrrÚchksumÚtypeÚlinknamer r!ÚdevmajorÚdevminorrÆrÙÚ pax_headersrÚrÜÚ_sparse_structsÚ _link_targetr‡cCs�||_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‚r`rrrrrßÚREGTYPEràrár r!rârãrÆrÙrÚrä)r�r‚r+r+r,rƒÛs"                zTarInfo.__init__cCs|jS)N)r‚)r�r+r+r,Ú_getpathõszTarInfo._getpathcCs ||_dS)N)r‚)r�r‚r+r+r,Ú_setpath÷szTarInfo._setpathcCs|jS)N)rá)r�r+r+r,Ú _getlinkpathûszTarInfo._getlinkpathcCs ||_dS)N)rá)r�rár+r+r,Ú _setlinkpathýszTarInfo._setlinkpathcCs d|jj|jt|ƒfS)Nz<%s %r at %#x>)rÞrir‚Úid)r�r+r+r,Ú__repr__szTarInfo.__repr__cCsµd|jd|jd@d|jd|jd|jd|jd|jd |jd |jd |j d |j d |j d|j i }|d t kr±|djdƒ r±|dd7<|S)z9Return the TarInfo's attributes as a dictionary. r‚r`iÿrrrrrßràrár r!rârãú/)r‚r`rrrrrßràrár r!rârãÚDIRTYPEr¯)r�Úinfor+r+r,Úget_infos             $zTarInfo.get_infoÚsurrogateescapecCsv|jƒ}|tkr+|j|||ƒS|tkrJ|j|||ƒS|tkrf|j||ƒStdƒ‚dS)zy||jd d ƒWn#tk r™||||YnXt||ƒ|kr>||||Wx…dD]}\}}||krîd||r2r‚r`rrrrrßràrár r!rârãÚAREGTYPEr¯rïÚGNUTYPE_SPARSEr:r=r»ÚboolråÚisdirÚrstripÚ GNU_TYPES)rrLr)r*rßÚobjrúr“Ústructsr@rÆÚnumbytesÚ isextendedÚorigsizer+r+r,ÚfrombufösZ      ! "  zTarInfo.frombufcCsP|jjtƒ}|j||j|jƒ}|jjƒt|_|j|ƒS)zOReturn the next TarInfo object from TarFile object tarfile. ) r‘rRrÀr6r)r*r¸rÆÚ _proc_member)rrÜrLr1r+r+r,Ú fromtarfile5szTarInfo.fromtarfilecCst|jttfkr"|j|ƒS|jtkr>|j|ƒS|jtttfkrc|j |ƒS|j |ƒSdS)zYChoose the right processing method depending on the type and call it. N) ràrrÚ _proc_gnulongr,Ú _proc_sparserrÚSOLARIS_XHDTYPEÚ _proc_paxÚ _proc_builtin)r�rÜr+r+r,r7Js   zTarInfo._proc_membercCsu|jjƒ|_|j}|jƒs6|jtkrL||j|jƒ7}||_|j |j |j |j ƒ|S)zfProcess a builtin type or an unknown type which will be treated as a regular file. ) r‘r¸rÙÚisregràÚSUPPORTED_TYPESÚ_blockrrÆÚ_apply_pax_inforär)r*)r�rÜrÆr+r+r,r=Ws  zTarInfo._proc_builtinc Cs¹|jj|j|jƒƒ}y|j|ƒ}Wntk rQtdƒ‚YnX|j|_|jt kr‹t ||j |j ƒ|_ n*|jtkrµt ||j |j ƒ|_|S)zSProcess the blocks that hold a GNU longname or longlink member. z missing or bad subsequent header)r‘rRr@rr8rqrurÆràrr2r)r*r‚rrá)r�rÜrLÚnextr+r+r,r9hs  zTarInfo._proc_gnulongc Cs#|j\}}}|`xÄ|rÞ|jjtƒ}d}x�tdƒD]�}y<t|||d…ƒ}t||d|d…ƒ} Wntk r�PYnX|r½| r½|j|| fƒ|d7}qFWt|dƒ}qW||_ |jj ƒ|_ |j |j |j ƒ|_||_ |S)z8Process a GNU sparse header plus extra headers. rérr)iø)rår‘rRrÀr:rAr=r»r-rÚr¸rÙr@rrÆ) r�rÜr2r4r5rLr“r@rÆr3r+r+r,r:~s( "    zTarInfo._proc_sparsec Csæ|jj|j|jƒƒ}|jtkr9|j}n|jjƒ}tj d|ƒ}|dk r‚|j dƒj dƒ|d<|j dƒ}|dkr©|j }nd}tjdƒ}d}xà|j||ƒ}|sàP|jƒ\} } t| ƒ} ||jd ƒd|jdƒ| d…} |j| dd|jƒ} | tkrt|j| ||j |jƒ} n|j| dd|jƒ} | || <|| 7}qÇWy|j|ƒ} Wntk rÚtd ƒ‚YnXd |krú|j| |ƒn_d |kr|j| ||ƒn=|j d ƒdkrY|j dƒdkrY|j| ||ƒ|jttfkrâ| j||j |jƒ|j | _ d|krâ| j!} | j"ƒsÃ| jt#krÙ| | j| jƒ7} | |_ | S)zVProcess an extended or global header as described in POSIX.1-2008. s\d+ hdrcharset=([^\n]+)\nNrzutf-8Ú hdrcharsetZBINARYs(\d+) ([^=]+)=rrz missing or bad subsequent headerzGNU.sparse.mapzGNU.sparse.sizezGNU.sparse.majorÚ1zGNU.sparse.minorr9r)$r‘rRr@rràrrär ÚreÚsearchÚgroupr0rr)ÚcompileÚmatchÚgroupsr;rbrÕÚ_decode_pax_fieldr*ÚPAX_NAME_FIELDSr8rqruÚ_proc_gnusparse_01Ú_proc_gnusparse_00Ú_proc_gnusparse_10rr;rArÆrÙr>r?)r�rÜrLrärJrDr)Zregexr“r(rrrBrÆr+r+r,r<šs`     .        *    zTarInfo._proc_paxcCsšg}x6tjd|ƒD]"}|jt|jdƒƒƒqWg}x6tjd|ƒD]"}|jt|jdƒƒƒqXWtt||ƒƒ|_dS)z?Process a GNU tar extended sparse header, version 0.0. s\d+ GNU.sparse.offset=(\d+)\nrs\d+ GNU.sparse.numbytes=(\d+)\nN)rFÚfinditerr»r;rHÚlistÚziprÚ)r�rBrärLZoffsetsrJr3r+r+r,rOs  zTarInfo._proc_gnusparse_00cCsVdd„|djdƒDƒ}tt|ddd…|ddd…ƒƒ|_dS)z?Process a GNU tar extended sparse header, version 0.1. cSsg|]}t|ƒ‘qSr+)r;)Ú.0Úxr+r+r,ú s z.TarInfo._proc_gnusparse_01..zGNU.sparse.mapú,Nrr)rrRrSrÚ)r�rBrärÚr+r+r,rN s zTarInfo._proc_gnusparse_01cCsôd}g}|jjtƒ}|jddƒ\}}t|ƒ}xgt|ƒ|dkr«d|kr}||jjtƒ7}|jddƒ\}}|jt|ƒƒqEW|jjƒ|_t t |ddd…|ddd…ƒƒ|_ dS)z?Process a GNU tar extended sparse header, version 1.0. Ns rr) r‘rRrÀrr;r%r»r¸rÙrRrSrÚ)r�rBrärÜZfieldsrÚrLZnumberr+r+r,rPs  zTarInfo._proc_gnusparse_10c Cs xõ|jƒD]ç\}}|dkr8t|d|ƒq |dkr]t|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.namerzGNU.sparse.sizerzGNU.sparse.realsizerrîN) rÚsetattrr;Ú PAX_FIELDSÚPAX_NUMBER_FIELDSr=r/r rä)r�rär)r*rrr+r+r,rA!s"        zTarInfo._apply_pax_infoc Cs=y|j|dƒSWn"tk r8|j||ƒSYnXdS)z1Decode a single field from a pax record. r8N)r0ÚUnicodeDecodeError)r�rr)Zfallback_encodingZfallback_errorsr+r+r,rL8s zTarInfo._decode_pax_fieldcCs-t|tƒ\}}|r%|d7}|tS)z_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. r)rQrÀ)r�r*rXrYr+r+r,r@@s zTarInfo._blockcCs |jtkS)N)ràÚ REGULAR_TYPES)r�r+r+r,r>Isz TarInfo.isregcCs |jƒS)N)r>)r�r+r+r,ÚisfileKszTarInfo.isfilecCs |jtkS)N)ràrï)r�r+r+r,r.Msz TarInfo.isdircCs |jtkS)N)ràÚSYMTYPE)r�r+r+r,ÚissymOsz TarInfo.issymcCs |jtkS)N)ràÚLNKTYPE)r�r+r+r,ÚislnkQsz TarInfo.islnkcCs |jtkS)N)ràÚCHRTYPE)r�r+r+r,ÚischrSsz TarInfo.ischrcCs |jtkS)N)ràÚBLKTYPE)r�r+r+r,ÚisblkUsz TarInfo.isblkcCs |jtkS)N)ràÚFIFOTYPE)r�r+r+r,ÚisfifoWszTarInfo.isfifocCs |jdk S)N)rÚ)r�r+r+r,ÚissparseYszTarInfo.issparsecCs|jtttfkS)N)ràrbrdrf)r�r+r+r,Úisdev[sz TarInfo.isdevN)r‚r`rrrrrßràrár r!rârãrÆrÙrärÚrÜråræ)4rirjrkrlÚ __slots__rƒrèréÚpropertyrrêrërrírñÚDEFAULT_FORMATÚENCODINGrørôrõr÷Ú classmethodrrþÚ staticmethodrÿrrrr6r8r7r=r9r:r<rOrNrPrArLr@r>r]r.r_rarcrergrhrir+r+r+r,rÍs`         1  3?    f             c@sÔeZdZdZdZdZdZdZeZ e Z dZ e ZeZdddddddddddddd „ Zeddded d „ƒZeddd d „ƒZeddddd„ƒZeddddd„ƒZeddddd„ƒZddddddddiZdd„Zdd „Zd!d"„Zd#d$„Zdddd%d&„Zd'd(dd)d*„Zdd'dd+dd,d-„Z dd.d/„Z!d0dd1dd2d3„Z"d4d'd1dd5d6„Z#d7d8„Z$d'dd9d:„Z%d;d<„Z&d=d>„Z'd?d@„Z(dAdB„Z)dCdD„Z*dEdF„Z+dGdH„Z,dIdJ„Z-dKdL„Z.dMdN„Z/dddOdP„Z0dQdR„Z1ddSdT„Z2dUdV„Z3dWdX„Z4dYdZ„Z5d[d\„Z6d]d^„Z7dS)_rz=The TarFile Class provides an interface to tar archives. rFrNrwròc Cs›ddddddddi} || kr6td ƒ‚||_| ||_|s¤|jdkr†tjj|ƒ r†d|_d|_t||jƒ}d |_n`|d kràt|d ƒràt |j t t fƒrà|j }t|d ƒrû|j|_d|_|rtjj |ƒnd |_ ||_|d k rC||_|d k rX||_|d k rm||_|d k r‚||_|d k r—||_| |_| d k rÇ|jtkrÇ| |_n i|_| d k rå| |_| d k rú| |_d |_g|_d |_|jjƒ|_i|_y:|jdkrZd |_|j ƒ|_|jdkrxœ|jj!|jƒy&|jj"|ƒ}|jj#|ƒWqlt$k rÍ|jj!|jƒPYqlt%k r}zt&t |ƒƒ‚WYd d }~XqlXqlW|jdkrid|_|jri|jj'|jj(ƒƒ}|jj)|ƒ|jt*|ƒ7_Wn*|js†|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. rwÚrbÚazr+brxÚwbrUÚxbz!mode must be 'r', 'a', 'w' or 'x'FNr‚r`T)rqrxrU),r=r`Ú_moderzrÚexistsÚ bltn_openr�rr r‚rrBÚabspathr‘rGrÝÚ dereferenceÚ ignore_zerosr)r*röräÚdebugÚ errorlevelr”ÚmembersÚ_loadedr¸rÆÚinodesÚ firstmemberrBr¹r8r»rtrqrnrr rSr%r„)r�r‚r`r‘rGrÝrxryr)r*rärzr{ZmodesÚerLr+r+r,rƒysˆ     "      !                        )     zTarFile.__init__c sY| r| rtdƒ‚|dkrö‡fdd†}x¬tˆjd|ƒD]•}tˆˆj|ƒ}|dk r‚|jƒ} y||d||�SWqNttfk râ} z!|dk rÍ|j| ƒwNWYdd} ~ XqNXqNWtdƒ‚nSd |kr}|jd d ƒ\} }| p#d} |p/d }|ˆjkrZtˆˆj|ƒ}ntd |ƒ‚||| ||�Sd |kr'|jd d ƒ\} }| pªd} |p¶d }| dkrÑtdƒ‚t || |||ƒ} yˆ|| | |�} Wn| j ƒ‚YnXd| _ | S|dkrIˆj ||||�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 openrwúr:*csˆj|dkS)NÚtaropen)Ú OPEN_METH)r�)rr+r,Únot_compressedsz$TarFile.open..not_compressedÚkeyNz%file could not be opened successfullyú:rrŒzunknown compression type %rú|rxzmode must be 'r' or 'w'FrqrUzundiscernible mode)rwr�)rwrx)rqrxrU) r=Úsortedrƒrdr¸rnror¹rr…r„r�r‚)rr‚r`r‘r’Úkwargsr„r�ÚfuncZ saved_posr€r_Ústreamr½r+)rr,ræsP%                 z TarFile.opencKs+|dkrtdƒ‚|||||�S)zCOpen uncompressed tar archive name for reading or writing. rwrqrxrUz!mode must be 'r', 'a', 'w' or 'x')rwrqrxrU)r=)rr‚r`r‘r‰r+r+r,r‚As  zTarFile.taropenr¤cKs)|d krtdƒ‚yddl}|jWn$ttfk rUtdƒ‚YnXy |j||d||ƒ}Wn9tk r±|dk rª|dkrªtd ƒ‚‚YnXy|j||||�}WnKtk r|j ƒ|dkrtd ƒ‚‚Yn|j ƒ‚YnXd |_ |S) zkOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. rwrxrUzmode must be 'r', 'w' or 'x'rNzgzip module is not availablerZznot a gzip fileF)rwrxrU) r=ÚgzipZGzipFiler–ÚAttributeErrorrorŸrnr‚r„r�)rr‚r`r‘Ú compresslevelr‰rŒr½r+r+r,ÚgzopenIs2             zTarFile.gzopencKsä|d krtdƒ‚yddl}Wntk rHtdƒ‚YnX|j|pX||d|ƒ}y|j||||�}WnQttfk rÂ|jƒ|dkr»t d ƒ‚‚Yn|jƒ‚YnXd |_ |S) zlOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. rwrxrUzmode must be 'r', 'w' or 'x'rNzbz2 module is not availablerŽznot a bzip2 fileF)rwrxrU) r=rŠr–roÚBZ2Filer‚rŸÚEOFErrorr„rnr�)rr‚r`r‘rŽr‰rŠr½r+r+r,Úbz2openks(         zTarFile.bz2opencKsç|d krtdƒ‚yddl}Wntk rHtdƒ‚YnX|j|pX||d|ƒ}y|j||||�}WnT|jtfk rÅ|jƒ|dkr¾t d ƒ‚‚Yn|jƒ‚YnXd |_ |S) zkOpen lzma compressed tar archive name for reading or writing. Appending is not allowed. rwrxrUzmode must be 'r', 'w' or 'x'rNzlzma module is not availableÚpresetznot an lzma fileF)rwrxrU) r=r¡r–roZLZMAFiler‚r¢r‘r„rnr�)rr‚r`r‘r“r‰r¡r½r+r+r,Úxzopenˆs&        zTarFile.xzopenrŒr‚r‰r�rŠr’r‹r”c Cs®|jr dSd|_zz|jdkr�|jjttdƒ|jtd7_t|jtƒ\}}|dkr�|jjtt|ƒWd|j s©|jj ƒXdS) zlClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NTrqrxrUrr)rqrxrU) r”r`r‘rSr&rÀrÆrQÚ RECORDSIZEr�r„)r�rXrYr+r+r,r„¯s    z TarFile.closecCs/|j|ƒ}|dkr+td|ƒ‚|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Ýr+r+r,Ú 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�r+r+r,Ú getmembersÏs   zTarFile.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‘qSr+)r‚)rTrÝr+r+r,rVÝs z$TarFile.getnames..)r›)r�r+r+r,ÚgetnamesÙszTarFile.getnamesc CsI|jdƒ|dk r"|j}|dkr4|}tjj|ƒ\}}|jtjdƒ}|jdƒ}|jƒ}||_ |dkrÎt tdƒr¼|j r¼tj |ƒ}qãtj |ƒ}ntj|jƒƒ}d}|j}t j|ƒr„|j|jf} |j rd|jdkrd| |jkrd||j| krdt} |j| }qt} | dr||j| zlink to )r™rhr^r_r`r rr!rrcrerârãrr­Ú localtimerr‚r.r_rárarg)r�Úverboser|rÝr+r+r,rRCs*   #  z TarFile.listÚfilterc Csñ|jdƒ|dkr|}|dk rnddl}|jdtdƒ||ƒrn|jdd|ƒdS|jdk r°tjj|ƒ|jkr°|jdd|ƒdS|jd|ƒ|j ||ƒ}|dkrö|jdd |ƒdS|dk r2||ƒ}|dkr2|jdd|ƒdS|j ƒrjt |d ƒ�}|j ||ƒWdQRXnƒ|j ƒrà|j |ƒ|ríxatj|ƒD]@}|jtjj||ƒtjj||ƒ||d |ƒq™Wn |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 insteadrztarfile: Excluded %rztarfile: Skipped %rrztarfile: Unsupported type %rrpr¿)r™r[r\r]Ú_dbgr‚rzrrwr¼r>rvÚaddfiler.ÚlistdirÚaddr¼) r�r‚rºZ recursiveZexcluder¿r[rÝÚfr+r+r,rÃcsB       *       *z TarFile.addcCsî|jdƒtj|ƒ}|j|j|j|jƒ}|jj|ƒ|jt |ƒ7_|dk rÚt ||j|j ƒt |j t ƒ\}}|dkrÇ|jjtt |ƒ|d7}|j|t 7_|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�Nrr)r™r rørGr)r*r‘rSrÆr%rPrrQrÀr&r|r»)r�rÝr‘rLrXrYr+r+r,rÁ s    zTarFile.addfileÚ.Ú numeric_ownercCsUg}|dkr|}xb|D]Z}|jƒrV|j|ƒtj|ƒ}d|_|j||d|jƒ d|ƒqW|jddd„ƒ|jƒx±|D]©}tjj ||j ƒ}y:|j ||d|ƒ|j ||ƒ|j ||ƒWq¤tk rL}z.|jdkr&‚n|jdd |ƒ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. NiÀÚ set_attrsrÆr…cSs|jS)N)r‚)rqr+r+r,ÚÑsz$TarFile.extractall..rz tarfile: %s)r.r»r r`ÚextractÚsortÚreverserzrr¼r‚ÚchownÚutimeÚchmodrmr{rÀ)r�rr|rÆZ directoriesrÝÚdirpathr€r+r+r,Ú extractall¹s,        zTarFile.extractallr‡cCsd|jdƒt|tƒr.|j|ƒ}n|}|jƒr[tjj||jƒ|_ y2|j |tjj||j ƒd|d|ƒWnÐt k r}zc|j dkr·‚nI|jdkrà|jdd|jƒn |jdd|j|jfƒWYdd}~XnNtk r_}z.|j dkr9‚n|jdd|ƒWYdd}~XnXdS) 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. rwrÇrÆrNrz tarfile: %sztarfile: %s %r)r™r rr˜rarzrr¼ráræÚ_extract_memberr‚rŸr{ÚfilenamerÀÚstrerrorrm)r�ÚmemberrrÇrÆrÝr€r+r+r,rÉás(  ! 2zTarFile.extractcCs¹|jdƒt|tƒr.|j|ƒ}n|}|jƒsO|jtkr_|j||ƒS|jƒsw|j ƒr±t|j t ƒr˜t 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. rwz'cannot extract (sym)link as file objectN)r™r rr˜r>ràr?Ú fileobjectrar_r‘r…rpÚ extractfileÚ_find_link_target)r�rÔrÝr+r+r,rÖs zTarFile.extractfilecCsØ|jdƒ}|jdtjƒ}tjj|ƒ}|r\tjj|ƒ r\tj|ƒ|jƒst|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ƒr2|j||ƒn]|jƒsJ|j ƒr]|j||ƒn2|jtkr|j||ƒn|j||ƒ|rÔ|j|||ƒ|j ƒsÔ|j||ƒ|j||ƒdS)z\Extract the TarInfo object tarinfo to a physical file called targetpath. rîrz%s -> %sN)r/r¦rzr¢rÚdirnameruÚmakedirsrar_rÀr‚rár>Úmakefiler.ÚmakedirrgÚmakefiforcreÚmakedevÚmakelinkràr?Ú makeunknownrÌrÎrÍ)r�rÝÚ targetpathrÇrÆZ upperdirsr+r+r,rÑ&s4 #    zTarFile._extract_memberc Cs-ytj|dƒWntk r(YnXdS)z,Make a directory called targetpath. iÀN)rzÚmkdirÚFileExistsError)r�rÝràr+r+r,rÛWs zTarFile.makedirc Cs²|j}|j|jƒt|dƒ�ƒ}|jdk r‘x7|jD],\}}|j|ƒt|||tƒqDW|j|jƒ|jƒnt|||jtƒWdQRXdS)z'Make a file called targetpath. rrN) r‘r¹rÙrvrÚrPrnrÚtruncate)r�rÝràÚsourceÚtargetrÆrr+r+r,rÚas   zTarFile.makefilecCs+|j||ƒ|jdd|jƒdS)zYMake a file from a TarInfo object with an unknown type at targetpath. rz9tarfile: Unknown file type %r, extracted as regular file.N)rÚrÀrà)r�rÝràr+r+r,rßps zTarFile.makeunknowncCs/ttdƒrtj|ƒn tdƒ‚dS)z'Make a fifo called targetpath. Úmkfifozfifo not supported by systemN)rrzrærm)r�rÝràr+r+r,rÜxszTarFile.makefifocCs‡ttdƒ s ttdƒ r,tdƒ‚|j}|jƒrQ|tjO}n |tjO}tj||tj |j |j ƒƒdS)zrrrrsrur|r»r})r�ÚmrÝr€r+r+r,rBÔsL      $ $%  z TarFile.nextcCs›|jƒ}|dk r1|d|j|ƒ…}|rItjj|ƒ}xKt|ƒD]=}|rztjj|jƒ}n |j}||krV|SqVWdS)z}Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. N)r›ÚindexrzrÚnormpathÚreversedr‚)r�r‚rÝÚ normalizer|rÔÚ member_namer+r+r,r– s    zTarFile._getmembercCs-x|jƒ}|dkrPqWd|_dS)zWRead through the entire archive file and look for readable members. NT)rBr})r�rÝr+r+r,rš! s   z TarFile._loadcCsQ|jrtd|jjƒ‚|dk rM|j|krMtd|jƒ‚dS)znCheck if TarFile is still open, and if the operation's mode corresponds to TarFile's mode. z %s is closedNzbad operation for mode %r)r”rŸrÞrir`)r�r`r+r+r,r™+ s zTarFile._checkcCs�|jƒrEdjtdtjj|jƒ|jfƒƒ}d}n|j}|}|j|d|ddƒ}|dkr‹t d|ƒ‚|S)zZFind the target member of a symlink or hardlink member in the archive. rîNrÝr÷Tzlinkname %r not found) r_r¼r¿rzrrØr‚rár–r—)r�rÝráÚlimitrÔr+r+r,r×4 s 0   zTarFile._find_link_targetcCs$|jrt|jƒSt|ƒSdS)z$Provide an iterator object. N)r}Úiterr|ÚTarIter)r�r+r+r,Ú__iter__G s  zTarFile.__iter__cCs&||jkr"t|dtjƒdS)z.Write debugging output to sys.stderr. ÚfileN)rzrgreÚstderr)r�ÚlevelÚmsgr+r+r,rÀO sz TarFile._dbgcCs|jƒ|S)N)r™)r�r+r+r,Ú __enter__U s zTarFile.__enter__cCs<|dkr|jƒn|js/|jjƒd|_dS)NT)r„r�r‘r”)r�ràrÚ tracebackr+r+r,Ú__exit__Y s     zTarFile.__exit__)8rirjrkrlrzrxryr{rlrGrmr)r*rrÝrØrÕrƒrnr•rr‚r�r’r”rƒr„r˜r›rœr¼rRrÃrÁrÐrÉrÖrÑrÛrÚrßrÜrÝrÞrÌrÎrÍrBr–ršr™r×rürÀrrr+r+r+r,r_st   kZ!   d =(& 0       6     c@s:eZdZdZdd„Zdd„Zdd„ZdS) rûzMIterator Class. for tarinfo in TarFile(...): suite... cCs||_d|_dS)z$Construct a TarIter object. rN)rÜrô)r�rÜr+r+r,rƒk s zTarIter.__init__cCs|S)z Return iterator object. r+)r�r+r+r,rüp szTarIter.__iter__cCs³|jdkr3|jjdk r3|jjƒ}nm|jt|jjƒkrd|jj|j}n<|jjsš|jjƒ}|s d|j_t‚nt‚|jd7_|S)z€Return the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. rNTr)rôrÜrrBr%r|r}Ú StopIteration)r�rÝr+r+r,Ú__next__t s!   zTarIter.__next__N)rirjrkrlrƒrürr+r+r+r,rûd s   rûc Cs;yt|ƒ}|jƒdSWntk r6dSYnXdS)zfReturn True if name points to a tar archive that we are able to handle, else return False. TFN)rr„r)r‚r½r+r+r,r� s    cCsîddl}d}|jd|ƒ}|jdddddd d d ƒ|jƒ}|jd d ddd dƒ|jdddddd9d dƒ|jdddddd:d dƒ|jddddd dƒ|jƒ}|jro|j}t|ƒrSt|dƒ�*}|jƒt |jƒd t j ƒWdQRX|j rlt d!j |ƒƒqê|jd"d#j |ƒƒn{|jrÛ|j}t|ƒr¿tj|d$ƒ�}|jd%|j ƒWdQRXqê|jd"d#j |ƒƒn|jrét|jƒd"kr|jd}tj}n=t|jƒd&kr9|j\}}n|jd"|jƒƒt|ƒrÍtj|d$ƒ�}|jd'|ƒWdQRX|j ræ|d(kr®d)j |ƒ} nd*j ||ƒ} t | ƒqê|jd"d#j |ƒƒn|jrÔ|jjdƒ} tjj| ƒ\} } d+d,d-d,d.d/d0d/d1d2d3d2d4d2d5d2i} | | krld6| | nd7}|j}tj| |ƒ�%}x|D]}|j|ƒq—WWdQRX|j rêt d8j | ƒƒn|jd"|jƒƒdS);Nrz3A simple command line interface for tarfile module.Ú descriptionz-vz --verboseÚactionÚ store_trueÚdefaultFÚhelpzVerbose outputz-lz--listÚmetavarú zShow listing of a tarfilez-ez --extractÚnargsú+ú zExtract tarfile into target dirz-cz--createúúzCreate tarfile from sourcesz-tz--testzTest if a tarfile is validrwrýz{!r} is a tar archive.rz{!r} is not a tar archive. zr:*r¾rrrÅz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.z.gzr‰z.tgzz.xzr‹z.txzz.bz2rŠz.tbzz.tbz2z.tb2zw:rxz{!r} file created.)r r)rr)ÚargparseÚArgumentParserÚ add_argumentÚadd_mutually_exclusive_groupÚ parse_argsZtestrrr›rgrerþr¾rGÚexitrRrrÉr%rzÚcurdirÚ format_helprÐZcreateÚpoprÚsplitextrÃ)rrÚparserrHÚargsrTrŒZtfrrZtar_nameÚ_ÚextZ compressionsZtar_modeZ tar_filesÚ file_namer+r+r,Úmain› sˆ                          r!Ú__main__)brlÚversionÚ __author__Ú__date__Z __cvsid__Ú __credits__ÚbuiltinsrrvrerzrÍrOr^r­rJr rFr·rµr–r�ÚNotImplementedErrorrìrŸÚ NameErrorÚ__all__r&rÀr•rrûrýrürrçr+r`r^rbrdrïrfZCONTTYPErrr,rrr;rórCrörlr?r\r0rYrMr r;rZr‚rmÚgetfilesystemencodingr-r2rArHrMrPr_rhÚ Exceptionrrmrnrorprqrrrsrtr>rurvr…ÚobjectrŽrÅÚBufferedReaderrØrrrûrr!rir+r+r+r,ÚsÞ                             ôh ÿÿ”ÿÿÿÿ )  Z