Efc @s=dZdZdZdZdZdZdZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZyddlZddlZWnek reZZnXd d d d 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#ZIejJZKeKekrejLZKnd>ZMd?ZNd@ZOd<e0dAZPdBZQdCZRedDZSe8dEfe9dFfe:dGfe;dHfe<dIfe=dJffeAdKffeBdLffeCe>BdMfe>dfeCdffeDdKffeEdLffeFe?BdMfe?dfeFdffeGdKffeHdLffeIe@BdNfe@dOfeIdfff ZTdPZUd eVfdQYZWdReWfdSYZXdTeWfdUYZYdVeWfdWYZZdXeWfdYYZ[dZeWfd[YZ\d\e\fd]YZ]d^e\fd_YZ^d`e\fdaYZ_dbe\fdcYZ`dde\fdeYZadffdgYZbdhfdiYZcdjedfdkYZedledfdmYZfdnedfdoYZgdpedfdqYZhd edfdrYZid edfdsYZjdtfduYZkdvfdwYZldxelfdyYZmdzelfd{YZnd|eofd}YZpd"Zqd<Zrd~fdYZsdZteuZvejjuZudS(s,Read from and write to tar format archives. s$Revision: 85213 $s0.9.0s!Lars Gustbel (lars@gustaebel.de)s$Date$s$Id$s3Gustavo Niemeyer, Niels Gustbel, Richard Townsend.iNtTarFiletTarInfot is_tarfiletTarErrortiisustar tustar00idit0t1t2t3t4t5t6t7tLtKtStxtgtXiiitpathtlinkpathtsizetmtimetuidtgidtunametgnametatimetctimeiii`i@i iiiiii@i iiicCs|| |t|tS(s@Convert a python string to a null-terminated string buffer. (tlentNUL(tstlength((s/usr/lib64/python2.7/tarfile.pytstnscCs'|jd}|dkr|S|| S(s?Convert a null-terminated string field to a python string. Ri(tfind(R tp((s/usr/lib64/python2.7/tarfile.pytntss cCs|dtdkrXytt|p+dd}Wqtk rTtdqXnId}x@tt|dD](}|dK}|t||d7}quW|S(s/Convert a number field to a python number. iiRisinvalid headerli(tchrtintR%t ValueErrortInvalidHeaderErrortxrangeRtord(R tnti((s/usr/lib64/python2.7/tarfile.pytntis  cCsd|kod|dknr?d|d|ft}n|tks_|d|dkrntdn|dkrtjdtjd|d}nd }x6t|dD]$}t|d @|}|dL}qWtd |}|S( s/Convert a python number to a number field. iiis%0*oisoverflow in number fieldRtltii(Rt GNU_FORMATR(tstructtunpacktpackR*R&(R,tdigitstformatR R-((s/usr/lib64/python2.7/tarfile.pytitns $  %cCs|dkry|j|dSWqtk rg}xU|D]M}y|j|j|dWq=tk r|j|jdq=Xq=Wdj|SXn|j||SdS(s*Convert a unicode object to a string. sutf-8tstricttutf8R0N(tencodetUnicodeEncodeErrortappendtjoin(R tencodingterrorsRtc((s/usr/lib64/python2.7/tarfile.pytutss    cCsxdttjd|d tjd|dd!}dttjd|d tjd|dd!}||fS( sCalculate 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. it148Bit356Biit148bt356b(tsumR2R3(tbuftunsigned_chksumt signed_chksum((s/usr/lib64/python2.7/tarfile.pyt calc_chksumss 77cCs|dkrdS|dkr0tj||dSd}t||\}}xQt|D]C}|j|}t||krtdn|j|qXW|dkr|j|}t||krtdn|j|ndS(sjCopy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. iNiisend of file reachedi@( tNonetshutilt copyfileobjtdivmodR*treadRtIOErrortwrite(tsrctdstR!tBUFSIZEtblockst remaindertbRG((s/usr/lib64/python2.7/tarfile.pyRMs$   R/t-RWtdR@R$trtwR tttTcCsig}xStD]K}xB|D]-\}}||@|kr|j|PqqW|jdq Wdj|S(scConvert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() RXR0(tfilemode_tableR<R=(tmodetpermttabletbittchar((s/usr/lib64/python2.7/tarfile.pytfilemode7s  cBseZdZRS(sBase exception.(t__name__t __module__t__doc__(((s/usr/lib64/python2.7/tarfile.pyRFst ExtractErrorcBseZdZRS(s%General exception for extract errors.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRhIst ReadErrorcBseZdZRS(s%Exception for unreadble tar archives.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRiLstCompressionErrorcBseZdZRS(s.Exception for unavailable compression methods.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRjOst StreamErrorcBseZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRkRst HeaderErrorcBseZdZRS(s!Base exception for header errors.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRlUstEmptyHeaderErrorcBseZdZRS(sException for empty headers.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRmXstTruncatedHeaderErrorcBseZdZRS(s Exception for truncated headers.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRn[stEOFHeaderErrorcBseZdZRS(s"Exception for end of file headers.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRo^sR)cBseZdZRS(sException for invalid headers.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyR)astSubsequentHeaderErrorcBseZdZRS(s3Exception for missing and invalid extended headers.(ReRfRg(((s/usr/lib64/python2.7/tarfile.pyRpdst _LowLevelFilecBs2eZdZdZdZdZdZRS(sLow-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. cCsgitjd6tjtjBtjBd6|}ttdrK|tjO}ntj||d|_dS(NRZR[tO_BINARYi( tostO_RDONLYtO_WRONLYtO_CREATtO_TRUNCthasattrRrtopentfd(tselftnameR_((s/usr/lib64/python2.7/tarfile.pyt__init__qs cCstj|jdS(N(RstcloseRz(R{((s/usr/lib64/python2.7/tarfile.pyR~zscCstj|j|S(N(RsRORz(R{R((s/usr/lib64/python2.7/tarfile.pyRO}scCstj|j|dS(N(RsRQRz(R{R ((s/usr/lib64/python2.7/tarfile.pyRQs(ReRfRgR}R~RORQ(((s/usr/lib64/python2.7/tarfile.pyRqks   t_StreamcBseZdZdZdZdZdZdZdZdZ dZ d d Z dd Z d Zd ZRS(sClass 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. cCst|_|dkr0t||}t|_n|dkrWt|}|j}n|p`d|_||_||_ ||_ ||_ d|_ d|_ t|_|dkr&yddl}Wntk rtdnX||_|jdd@|_|d kr|jq&|jn|d kryddl}Wntk ratd nX|d krd|_|j|_q|j|_ndS( s$Construct a _Stream object. t*R0ltgziNszlib module is not availablelRZtbz2sbz2 module is not available(tTruet _extfileobjRKRqtFalset _StreamProxyt getcomptypeR|R_tcomptypetfileobjtbufsizeRGtpostclosedtzlibt ImportErrorRjtcrc32tcrct _init_read_gzt_init_write_gzRtdbuftBZ2Decompressortcmpt BZ2Compressor(R{R|R_RRRRR((s/usr/lib64/python2.7/tarfile.pyR}sD                      cCs*t|dr&|j r&|jndS(NR(RxRR~(R{((s/usr/lib64/python2.7/tarfile.pyt__del__scCs|jjd|jj|jj |jjd|_tjdtt j }|j d|t |j t kr|j jdd|_ n|j jdr|j d |_ n|j |j td S( s6Initialize for writing with gzip compression. i is(t __class__ReR|tid(R{((s/usr/lib64/python2.7/tarfile.pyt__repr__scCs i |jd6|jd@d6|jd6|jd6|jd6|jd6|jd6|jd 6|jd 6|j d 6|j d 6|j d 6|j d6}|d t kr|djd r|dcd7R?tinfotkey((s/usr/lib64/python2.7/tarfile.pytget_infos(            $ !R8cCss|j||}|tkr+|j|S|tkrD|j|S|tkrc|j|||StddS(s<Return a tar header as a string of 512 byte blocks. sinvalid formatN(Rt USTAR_FORMATtcreate_ustar_headerR1tcreate_gnu_headert PAX_FORMATtcreate_pax_headerR((R{R6R>R?R((s/usr/lib64/python2.7/tarfile.pyttobufs     cCsyt|dn||j||}y|jd Wntk r|||nXt|||kr>|||q>WxddddfD]\}} ||kr d||R?RR|thnameR!tvalR5RG((s/usr/lib64/python2.7/tarfile.pyRs6       4cCs|j|dtS(sAReturn the object as a pax global header block sequence. R(RtXGLTYPE(tclsR((s/usr/lib64/python2.7/tarfile.pytcreate_pax_global_header8scCs|td }x$|r4|ddkr4|d }qW|t|}|d }| sht|tkrwtdn||fS(sUSplit a name longer than 100 chars into a prefix and a name part. iiRsname is too long(t LENGTH_PREFIXRRR((R{R|R((s/usr/lib64/python2.7/tarfile.pyR>s cCst|jdddt|jddd@d|t|jddd|t|jd dd|t|jd dd |t|jd dd |d |jdtt|jdddt|jdtdt|jdddt|jdddt|jddd|t|jddd|t|jdddg}tjdtdj|}t |t d}|d d||d}|S(sReturn a header block. info is a dictionary with file information, format must be one of the *_FORMAT constants. R|R0idR_iiiRRRi Rs RRRRi RRRRis%dsis%06oi( R"tgetR7RRR2R4RR=RJ(RR6tpartsRGR((s/usr/lib64/python2.7/tarfile.pyRMs&cCs@tt|t\}}|dkr<|t|t7}n|S(sdReturn the string payload filled with zero bytes up to the next 512 byte border. i(RNRRR(tpayloadRURV((s/usr/lib64/python2.7/tarfile.pyt_create_payloadis cCs[|t7}i}d|d<||d|j|S|jtttfkrc|j |S|j |SdS(sYChoose the right processing method depending on the type and call it. N( RRRt _proc_gnulongtGNUTYPE_SPARSEt _proc_sparsetXHDTYPERtSOLARIS_XHDTYPEt _proc_paxt _proc_builtin(R{R((s/usr/lib64/python2.7/tarfile.pyRs   cCsx|jj|_|j}|js6|jtkrO||j|j7}n||_|j |j |j |j |S(sfProcess a builtin type or an unknown type which will be treated as a regular file. ( RRRtisregRtSUPPORTED_TYPESt_blockRRt_apply_pax_infoRR>R?(R{RR((s/usr/lib64/python2.7/tarfile.pyRs  cCs|jj|j|j}y|j|}Wntk rPtdnX|j|_|jt kr~t ||_ n!|jt krt ||_ n|S(sSProcess the blocks that hold a GNU longname or longlink member. s missing or bad subsequent header(RROR RRRlRpRRRR%R|RR(R{RRGtnext((s/usr/lib64/python2.7/tarfile.pyRs  c Css|j}t}d}d}d}xtdD]}y6t|||d!}t||d|d!} Wntk rPnX||kr|jt|||n|jt|| ||| 7}|| }|d7}q1Wt|d} t|dd!} x| d kr|j j t }d }xtd D]}y6t|||d!}t||d|d!} Wntk rPnX||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. ilii iiiiiiii(RGt _ringbufferR*R.R(R<t_holeRR+RRORRRRR RR( R{RRGtspRtlastposRR-Rtnumbytest isextendedtorigsize((s/usr/lib64/python2.7/tarfile.pyRsT             c Cs|jj|j|j}|jtkr9|j}n|jj}tj dtj }d}xt r!|j ||}|sPn|j \}}t|}|dkrtdn||jdd|jd|d!} |jd}| jd} | ||<||7}qfWy|j|} Wntk rTtdnX|jttfkr| j||j|j|j| _d|kr| j} | js| jtkr| | j| j7} n| |_qn| S( sVProcess an extended or global header as described in POSIX.1-2001. s(\d+) ([^=]+)=isinvalid headeriiR9s missing or bad subsequent headerR(RROR RRRRRtretcompiletURtmatchtgroupsR'R)tendtstartRRRlRpRRR!R>R?RRRR( R{RRGRtregexRR-R!R R R"R((s/usr/lib64/python2.7/tarfile.pyRSs@    +     cCsx|jD]\}}|tkr+q n|dkrI|jd}n|tkryt||}Wqtk rd}qXnt|||}t|||q W|j|_dS(soReplace fields with supplemental information from a previous pax extended or global header. RRiN( R t PAX_FIELDSRtPAX_NUMBER_FIELDSR(RAtsetattrRR(R{RR>R?R R ((s/usr/lib64/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/usr/lib64/python2.7/tarfile.pyR s cCs |jtkS(N(Rt REGULAR_TYPES(R{((s/usr/lib64/python2.7/tarfile.pyRscCs |jS(N(R(R{((s/usr/lib64/python2.7/tarfile.pytisfilescCs |jtkS(N(RR(R{((s/usr/lib64/python2.7/tarfile.pyRscCs |jtkS(N(RtSYMTYPE(R{((s/usr/lib64/python2.7/tarfile.pytissymscCs |jtkS(N(RtLNKTYPE(R{((s/usr/lib64/python2.7/tarfile.pytislnkscCs |jtkS(N(RtCHRTYPE(R{((s/usr/lib64/python2.7/tarfile.pytischrscCs |jtkS(N(RtBLKTYPE(R{((s/usr/lib64/python2.7/tarfile.pytisblkscCs |jtkS(N(RtFIFOTYPE(R{((s/usr/lib64/python2.7/tarfile.pytisfifoscCs |jtkS(N(RR(R{((s/usr/lib64/python2.7/tarfile.pytissparsescCs|jtttfkS(N(RR;R=R?(R{((s/usr/lib64/python2.7/tarfile.pytisdevs(/ReRfRgR}RRtpropertyRRRRRRtDEFAULT_FORMATtENCODINGRRRRt classmethodRRt staticmethodRRRRRRRRRRRRR!R RR6RR8R:R<R>R@RARB(((s/usr/lib64/python2.7/tarfile.pyRsP         3  .   8 <          c BsHeZdZdZeZeZdZeZ e Z d2Z eZeZd2dd2d2d2d2d2d2d2d2d2d2d ZdZdZeeeZed2dd2edZedd2dZedd2d d Zedd2d d Zid d 6dd6dd6ZdZdZdZ dZ!d2d2d2dZ"e#dZ$d2e#d2d2dZ%d2dZ&dd2dZ'ddZ(dZ)dZ*d Z+d!Z,d"Z-d#Z.d$Z/d%Z0d&Z1d'Z2d(Z3d)Z4d2ed*Z5d+Z6d2d,Z7d-Z8d.Z9d/Z:d0Z;d1Z<RS(3s=The TarFile Class provides an interface to tar archives. iiRZc Cst|dks|dkr-tdn||_idd6dd6dd 6||_|s|jdkrtjj| rd |_d|_nt||j}t|_ nN|dkrt |d r|j }nt |d r|j|_nt |_ |rtjj|nd|_ ||_|dk rC||_n|dk r[||_n|dk rs||_n|dk r||_n|dk r||_n| dk r| |_n!|dkrd |_n d |_| dk r|jtkr| |_n i|_| dk r$| |_n| dk r<| |_nt|_g|_t|_|jj|_i|_y9|jdkrd|_ |j!|_ n|jdkrCxt r?|jj"|jy&|jj#|}|jj$|Wqt%k r|jj"|jPqt&k r;} t't(| qXqWn|jdkrt |_|jr|jj)|jj*}|jj+||jt|7_qnWn,|j s|jj,nt |_nXdS(sOpen 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. iRsmode must be 'r', 'a' or 'w'trbRZsr+btatwbR[R|R_sutf-8R8tawN(-RR(R_t_modeRsRtexistst bltn_openRRRKRxR|RtabspathRR6Rt dereferencet ignore_zerosR>R?RRtdebugt errorlevelRtmemberst_loadedRRtinodest firstmemberR"RRR<RoRlRiR RRRQR~(R{R|R_RR6RRPRQR>R?RRRRSteRG((s/usr/lib64/python2.7/tarfile.pyR}s  ""     !                                 cCs |jtkS(N(R6R(R{((s/usr/lib64/python2.7/tarfile.pyt _getposixEscCs>ddl}|jdtd|r1t|_n t|_dS(Nis use the format attribute insteadi(twarningstwarntDeprecationWarningRR6R1(R{R RZ((s/usr/lib64/python2.7/tarfile.pyt _setposixGs    c Ks| r| rtdn|dkrx|jD]}t||j|}|dk rj|j}ny||d||SWq3ttfk r} |dk r3|j|q3q3q3Xq3Wtdn4d|krV|jdd\} }| pd} |pd}||jkr3t||j|}ntd|||| ||Sd |kr|jd d\} }| pd} |pd}| d krtd n||| t || ||||} t | _ | S|d kr|j ||||Std dS(s|Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. mode: 'r' or 'r:*' open for reading with transparent compression 'r:' open for reading exclusively uncompressed 'r:gz' open for reading with gzip compression 'r:bz2' open for reading with bzip2 compression 'a' or 'a:' open for appending, creating the file if necessary 'w' or 'w:' open for writing without compression 'w:gz' open for writing with gzip compression 'w:bz2' open for writing with bzip2 compression 'r|*' open a stream of tar blocks with transparent compression 'r|' open an uncompressed stream of tar blocks for reading 'r|gz' open a gzip compressed stream of tar blocks 'r|bz2' open a bzip2 compressed stream of tar blocks 'w|' open an uncompressed stream for writing 'w|gz' open a gzip compressed stream for writing 'w|bz2' open a bzip2 compressed stream for writing snothing to openRZsr:*s%file could not be opened successfullyt:iRsunknown compression type %rt|trwsmode must be 'r' or 'w'RKsundiscernible modeN(RZsr:*( R(t OPEN_METHRRKRRiRjRtsplitRRRttaropen( RR|R_RRtkwargsRtfunct saved_posRXRdR\((s/usr/lib64/python2.7/tarfile.pyRy\sH               cKs@t|dks|dkr-tdn|||||S(sCOpen uncompressed tar archive name for reading or writing. iRsmode must be 'r', 'a' or 'w'(RR((RR|R_RRd((s/usr/lib64/python2.7/tarfile.pyRcsi c Kst|dks|dkr-tdnyddl}|jWn#ttfk ritdnX|dkrt||d}ny.|j |||j|||||}Wnt k rt dnXt |_ |S( skOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. iR`smode must be 'r' or 'w'iNsgzip module is not availableRWsnot a gzip file(RR(tgziptGzipFileRtAttributeErrorRjRKRNRcRPRiRR(RR|R_Rt compresslevelRdRgR\((s/usr/lib64/python2.7/tarfile.pytgzopens"       cKst|dks|dkr-tdnyddl}Wntk r\tdnX|dk r{t||}n|j||d|}y|j||||}Wn#t t fk rt dnXt |_ |S( slOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. iR`smode must be 'r' or 'w'.iNsbz2 module is not availableRjsnot a bzip2 file(RR(RRRjRKRtBZ2FileRcRPtEOFErrorRiRR(RR|R_RRjRdRR\((s/usr/lib64/python2.7/tarfile.pytbz2opens   RcRRkRRnRcCs|jr dS|jdkr|jjttd|jtd7_t|jt\}}|dkr|jjtt|qn|j s|jj nt |_dS(slClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NRKii( RR_RRQRRRRNt RECORDSIZERR~R(R{RURV((s/usr/lib64/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/usr/lib64/python2.7/tarfile.pyt getmembers cCs'|j|js |jn|jS(sReturn 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/usr/lib64/python2.7/tarfile.pyt getmembers s   cCs g|jD]}|j^q S(sReturn 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/usr/lib64/python2.7/tarfile.pytgetnamessc Cs\|jd|d k r%|j}n|d kr:|}ntjj|\}}|jtjd}|jd}|j }||_ |d krt tdr|j rtj |}qtj|}ntj|j}d}|j}tj|r|j|jf} |j rj|jdkrj| |jkrj||j| krjt} |j| }qt} | dr||j| slink toN(RsRdR_RRRRR<R>RRRRt localtimeRR|RR8RR:(R{tverboseR((s/usr/lib64/python2.7/tarfile.pytlist{s&      c Cs|jd|dkr"|}n|dk rtddl}|jdtd||rt|jdd|dSn|jdk rtjj ||jkr|jdd|dS|jd||j ||}|dkr|jdd |dS|dk r;||}|dkr;|jdd|dSn|j rrt |d }|j ||WdQXn|jr|j ||rxQtj|D]=}|jtjj||tjj|||||qWqn |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. RKiNsuse the filter argument insteadistarfile: Excluded %rstarfile: Skipped %ristarfile: Unsupported type %rRH(RsRKRZR[R\t_dbgR|RsRRORRRNtaddfileRtlistdirtaddR=( R{R|Rt recursivetexcludetfilterRZRtf((s/usr/lib64/python2.7/tarfile.pyRsB        *       *cCs|jdtj|}|j|j|j|j}|jj||jt |7_|dk rt ||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(RsRRR6R>R?RRQRRRKRMRRNRRRTR<(R{RRRGRURV((s/usr/lib64/python2.7/tarfile.pyRs    t.cCs3g}|dkr|}nxR|D]J}|jr\|j|tj|}d|_n|j||q"W|jdtjd|j x|D]}t j j ||j }y4|j|||j|||j||Wqtk r*}|jdkrq+|jdd|qXqWdS(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(). iRR|is tarfile: %sN(RKRR<RR_textracttsorttoperatort attrgettertreverseRsRR=R|tchowntutimetchmodRhRSR(R{RRTt directoriesRtdirpathRX((s/usr/lib64/python2.7/tarfile.pyt extractalls*        R0cCs7|jdt|tr.|j|}n|}|jr^tjj||j|_ ny&|j |tjj||j Wnt k r}|j dkrq3|jdkr|jdd|jq3|jdd|j|jfn<tk r2}|j dkrq3|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'. RZiis tarfile: %sstarfile: %s %rN(RsRt basestringRrR:RsRR=Rt _link_targett_extract_memberR|tEnvironmentErrorRStfilenameRKRtstrerrorRh(R{tmemberRRRX((s/usr/lib64/python2.7/tarfile.pyRs$  &#cCs|jdt|tr.|j|}n|}|jrP|j||S|jtkro|j||S|js|j rt|j t rt dq|j |j|SndSdS(sExtract 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(RsRRRrRt fileobjectRRR:R8RRRkt extractfilet_find_link_targetRK(R{RR((s/usr/lib64/python2.7/tarfile.pyR5s  cCs|jd}|jdtj}tjj|}|r_tjj| r_tj|n|jsw|j r|j dd|j |j fn|j d|j |j r|j||n|jr|j||n|jr |j||n|js"|jr5|j||n]|jsM|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. Ris%s -> %sN(RRRsR{RtdirnameRMtmakedirsR:R8RR|RRtmakefileRtmakedirR@tmakefifoR<R>tmakedevtmakelinkRRt makeunknownRRR(R{Rt targetpatht upperdirs((s/usr/lib64/python2.7/tarfile.pyR[s2#    cCsFytj|dWn+tk rA}|jtjkrBqBnXdS(s,Make a directory called targetpath. iN(RstmkdirRterrnotEEXIST(R{RRRX((s/usr/lib64/python2.7/tarfile.pyRs cCsJ|j|}z)t|d}t||WdQXWd|jXdS(s'Make a file called targetpath. RJN(RRNRMR~(R{RRtsourcettarget((s/usr/lib64/python2.7/tarfile.pyRs cCs+|j|||jdd|jdS(sYMake a file from a TarInfo object with an unknown type at targetpath. is9tarfile: Unknown file type %r, extracted as regular file.N(RRR(R{RR((s/usr/lib64/python2.7/tarfile.pyRs cCs/ttdrtj|n tddS(s'Make a fifo called targetpath. tmkfifosfifo not supported by systemN(RxRsRRh(R{RR((s/usr/lib64/python2.7/tarfile.pyRscCsttd s ttd r/tdn|j}|jrT|tjO}n |tjO}tj||tj |j |j dS(s<Make a character or block device called targetpath. tmknodRs'special devices not supported by systemN( RxRsRhR_R>R}tS_IFBLKtS_IFCHRRRRR(R{RRR_((s/usr/lib64/python2.7/tarfile.pyRs     cCs ttdrttdr|jrbtjj|rLtj|ntj|j|qtjj|j rtjj|rtj|ntj |j |q|j |j ||n=y|j |j ||Wnt k rtdnXdS(sMake 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(RxRsR8RtlexiststunlinkRRRMRRRRRqRh(R{RR((s/usr/lib64/python2.7/tarfile.pyRs  cCstrttdrtjdkrytj|jd}Wntk r]|j}nXytj |j d}Wntk r|j }nXyZ|j rttdrtj |||n%tjdkrtj|||nWqtk r}tdqXndS(s6Set owner of targetpath according to tarinfo. tgeteuidiitlchowntos2emxscould not change ownerN(RRxRsRRtgetgrnamRRqRtgetpwnamRRR8RtsystplatformRRRh(R{RRRtuRX((s/usr/lib64/python2.7/tarfile.pyRs '    cCsOttdrKytj||jWqKtk rG}tdqKXndS(sASet file permissions of targetpath according to tarinfo. Rscould not change modeN(RxRsRR_RRh(R{RRRX((s/usr/lib64/python2.7/tarfile.pyRs cCsYttdsdSy tj||j|jfWntk rT}tdnXdS(sBSet modification time of targetpath according to tarinfo. RNs"could not change modification time(RxRsRRRRh(R{RRRX((s/usr/lib64/python2.7/tarfile.pyRs  cCs|jd|jdk r2|j}d|_|S|jj|jd}xktry|jj|}WnGt k r}|j r|j dd|j|f|jt 7_qNqnt k r+}|j r|j dd|j|f|jt 7_qNq|jdkrtt|qntk rY|jdkrtdqn[tk r}|jdkrtt|qn%tk r}tt|nXPqNW|dk r|jj|n t|_|S(sReturn 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(RsRWRKRRRRRRRoRQRRR)RiR RmRnRpRTR<RU(R{tmRRX((s/usr/lib64/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|Rt normalizeRTRt member_name((s/usr/lib64/python2.7/tarfile.pyRp2 s    cCs6x&tr(|j}|dkrPqqWt|_dS(sWRead through the entire archive file and look for readable members. N(RR"RKRU(R{R((s/usr/lib64/python2.7/tarfile.pyRtI s    cCsW|jr"td|jjn|dk rS|j|krStd|jndS(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(RRPRReRKR_(R{R_((s/usr/lib64/python2.7/tarfile.pyRsS s cCs|jrEdjtdtjj|j|jf}d}n|j}|}|j |d|dt }|dkrt d|n|S(sZFind the target member of a symlink or hardlink member in the archive. RRRslinkname %r not foundN( R8R=RRKRsRRR|RRpRRq(R{RRtlimitR((s/usr/lib64/python2.7/tarfile.pyR\ s 0   cCs$|jrt|jSt|SdS(s$Provide an iterator object. N(RUtiterRTtTarIter(R{((s/usr/lib64/python2.7/tarfile.pyRo s  cCs#||jkrtj|IJndS(s.Write debugging output to sys.stderr. N(RRRtstderr(R{tleveltmsg((s/usr/lib64/python2.7/tarfile.pyRw scCs|j|S(N(Rs(R{((s/usr/lib64/python2.7/tarfile.pyt __enter__} s cCs?|dkr|jn"|js2|jjnt|_dS(N(RKR~RRRR(R{RR t traceback((s/usr/lib64/python2.7/tarfile.pyt__exit__ s    N(=ReRfRgRRRRPRQRSRDR6RER>RKR?RRRRR}RYR]RCtposixRFRoRyRcRkRnRaR~RrRuRvRRRRRRRRRRRRRRRRRRR"RpRtRsRRRRR(((s/usr/lib64/python2.7/tarfile.pyRst  d   H   b = % ! & /      1    RcBs)eZdZdZdZdZRS(sMIterator Class. for tarinfo in TarFile(...): suite... cCs||_d|_dS(s$Construct a TarIter object. iN(RR(R{R((s/usr/lib64/python2.7/tarfile.pyR} s cCs|S(s Return iterator object. ((R{((s/usr/lib64/python2.7/tarfile.pyR scCs|jdkr3|jjdk r3|jj}np|jt|jjkrd|jj|j}n?|jjs|jj}|st|j_t qnt |jd7_|S(sReturn the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. iiN( RRRWRKR"RRTRURt StopIteration(R{R((s/usr/lib64/python2.7/tarfile.pyR" s!   (ReRfRgR}RR"(((s/usr/lib64/python2.7/tarfile.pyR s  t_sectioncBs eZdZdZdZRS(s$Base class for _data and _hole. cCs||_||_dS(N(RR(R{RR((s/usr/lib64/python2.7/tarfile.pyR} s cCs%|j|ko"|j|jkSS(N(RR(R{R((s/usr/lib64/python2.7/tarfile.pyt __contains__ s(ReRfRgR}R(((s/usr/lib64/python2.7/tarfile.pyR s RcBseZdZdZRS(s/Represent a data section in a sparse file. cCs tj|||||_dS(N(RR}R(R{RRR((s/usr/lib64/python2.7/tarfile.pyR} s(ReRfRgR}(((s/usr/lib64/python2.7/tarfile.pyR sR$cBseZdZRS(s/Represent a hole section in a sparse file. (ReRfRg(((s/usr/lib64/python2.7/tarfile.pyR$ sR#cBs eZdZdZdZRS(sMRingbuffer class which increases performance over a regular list. cCs d|_dS(Ni(tidx(R{((s/usr/lib64/python2.7/tarfile.pyR} scCsu|j}x\trg||}||kr,Pn|d7}|t|krQd}n||jkr dSq W||_|S(Nii(RRRRK(R{RRtitem((s/usr/lib64/python2.7/tarfile.pyR# s       (ReRfRgR}R#(((s/usr/lib64/python2.7/tarfile.pyR# s t TarFileCompatcBsteZdZdedZdZdZdZdZdZ dZ d d d Z d Z d ZRS( sRTarFile class compatible with standard module zipfile's ZipFile class. RZcCsddlm}|ddd|tkrDtj|||_n0|tkrhtj|||_n td|dd!d kr|jj }xB|D]7}|j |_ |j |_ tj|jd |_qWndS( Ni(twarnpy3ks6the TarFileCompat class has been removed in Python 3.0t stacklevelisunknown compression constantiiRZi(RZRt TAR_PLAINRRcRt TAR_GZIPPEDRkR(RuR|RRt file_sizeRtgmtimeRt date_time(R{tfileR_t compressionRRTR((s/usr/lib64/python2.7/tarfile.pyR} s       cCstd|jS(NcSs|jS(N(R|(R((s/usr/lib64/python2.7/tarfile.pyt s(tmaptinfolist(R{((s/usr/lib64/python2.7/tarfile.pytnamelist scCstd|jjS(NcSs |jtkS(N(RR5(R((s/usr/lib64/python2.7/tarfile.pyR s(RRRu(R{((s/usr/lib64/python2.7/tarfile.pyR s cCs|jjdS(N(RR(R{((s/usr/lib64/python2.7/tarfile.pytprintdir scCsdS(N((R{((s/usr/lib64/python2.7/tarfile.pyttestzip scCs|jj|S(N(RRr(R{R|((s/usr/lib64/python2.7/tarfile.pytgetinfo scCs"|jj|jj|jS(N(RRRrRO(R{R|((s/usr/lib64/python2.7/tarfile.pyRO scCs|jj||dS(N(RR(R{RRt compress_type((s/usr/lib64/python2.7/tarfile.pyRQ scCsyddlm}Wn!tk r7ddlm}nXddl}t|j}t||_|j|j |_ |j j |||dS(Ni(tStringIO( t cStringIORRtcalendarRRRRttimegmRRRR(R{tzinfotbytesRRttinfo((s/usr/lib64/python2.7/tarfile.pytwritestr s  cCs|jjdS(N(RR~(R{((s/usr/lib64/python2.7/tarfile.pyR~ sN(ReRfRgRR}RRRRRRORKRQR R~(((s/usr/lib64/python2.7/tarfile.pyR s       cCs7yt|}|jtSWntk r2tSXdS(sfReturn True if name points to a tar archive that we are able to handle, else return False. N(RyR~RRR(R|R\((s/usr/lib64/python2.7/tarfile.pyR s    (wRgt __version__tversiont __author__t__date__t __cvsid__t __credits__RRsRLR}RRR2RR*RRRRRKt__all__RRRoRRRRRRRR9R7R;R=RR?tCONTTYPERRRRRRRR1RRDRR5RR2RR'R3tS_IFLNKtS_IFREGRtS_IFDIRRtS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECtgetfilesystemencodingREtgetdefaultencodingR"R%R.R7RARJRMR^Rdt ExceptionRRhRiRjRkRlRmRnRoR)RpRqRtobjectRRRRRRRRRR$RR#RRRRRyRN(((s/usr/lib64/python2.7/tarfile.pyts.                                               AL7' 4