]c@sdZdZdZdZdZdZdZddkZddkZddk Z ddk Z ddk Z ddk Z ddk Z ddkZddkZddkZeid jo ed nyddkZddkZWnej oeZZnXd d d dgZdZdZedZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)d Z*d!Z+d"Z,d#Z-d$Z.d%Z/d&Z0e/Z1ee e!e"e%e&e'e#e$e(e)e*f Z2ee e'e*fZ3e(e)e*fZ4d'd(d)d*d+d,d-d.fZ5he6d/6e6d06e6d*6e7d+6e7d,6e7d)6Z8d1Z9d2Z:d3Z;d4Z<d5Z=d6Z>d7Z?d8Z@dZAd9ZBd:ZCd;ZDd<ZEd=ZFd>ZGd?ZHd&ZId%ZJeiKZLeLejoeiMZLnd@ZNdAZOdBZPd>e1dCZQdDZRdEZSedFZTe9dGfe:dHfe;dIfe<dJfe=dKfe>dLffeBdMffeCdNffeDe?BdOfe?d feDd!ffeEdMffeFdNffeGe@BdOfe@d feGd!ffeHdMffeIdNffeJeABdPfeAdQfeJd!fff ZUdRZVeiWdSjo dTZXn eiYiXZXdeZfdUYZ[dVe[fdWYZ\dXe[fdYYZ]dZe[fd[YZ^d\e[fd]YZ_d^e[fd_YZ`d`fdaYZadbfdcYZbddecfdeYZddfecfdgYZedhecfdiYZfdjecfdkYZgd ecfdlYZhd ecfdmYZidnfdoYZjdpfdqYZkdrekfdsYZldtekfduYZmdvenfdwYZod$Zpd>ZqdxfdyYZrdzZsetZueiitZtdS({s,Read from and write to tar format archives. s$Revision: 81664 $s0.9.0s!Lars Gustbel (lars@gustaebel.de)s5$Date: 2010-06-03 06:07:08 -0400 (Thu, 03 Jun 2010) $s;$Id: tarfile.py 81664 2010-06-03 10:07:08Z lars.gustaebel $s3Gustavo Niemeyer, Niels Gustbel, Richard Townsend.iNtmacs'tarfile does not work for platform==mactTarFiletTarInfot 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.6/tarfile.pytstnscCs)|id}|djo|S|| S(s?Convert a null-terminated string field to a python string. Ri(tfind(R!tp((s/usr/lib64/python2.6/tarfile.pytntss cCs|dtdjoFy tt|pdd}Wqtj otdqXnJd}x@tt|dD](}|dK}|t||d7}qzW|S(s/Convert a number field to a python number. iiRisinvalid headerli(tchrtintR&t ValueErrort HeaderErrortxrangeRtord(R!tnti((s/usr/lib64/python2.6/tarfile.pytntis  cCsd|jod|djnod|d|ft}n|tjp|d|djotdn|djo&tidtid|d}nd }x6t|dD]$}t|d @|}|dL}qWtd |}|S( s/Convert a python number to a number field. iiis%0*oisoverflow in number fieldRtltii(R t GNU_FORMATR)tstructtunpacktpackR+R'(R-tdigitstformatR!R.((s/usr/lib64/python2.6/tarfile.pytitns &" &cCs|djoy|i|dSWqtj oqg}xW|D]O}y|i|i|dWq?tj o|i|idq?Xq?Wdi|SXn|i||SdS(s*Convert a unicode object to a string. sutf-8tstricttutf8R1N(tencodetUnicodeEncodeErrortappendtjoin(R!tencodingterrorsRtc((s/usr/lib64/python2.6/tarfile.pytutss c Csxdttid|d tid|dd!}dttid|d tid|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(tsumR3R4(tbuftunsigned_chksumt signed_chksum((s/usr/lib64/python2.6/tarfile.pyt calc_chksumss 77cCs|djodS|djoti||dSd}t||\}}xSt|D]E}|i|}t||jotdn|i|q\W|djoC|i|}t||jotdn|i|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 remaindertbRH((s/usr/lib64/python2.6/tarfile.pyRN s&    R0t-RXtdRAR%trtwR!tttTcCskg}xUtD]M}xD|D]/\}}||@|jo|i|PqqW|idq Wdi|S(scConvert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() RYR1(tfilemode_tableR=R>(tmodetpermttabletbittchar((s/usr/lib64/python2.6/tarfile.pytfilemode=s   t/cCstii|itidS(Rf(tosRtnormpathtreplacetsep(R((s/usr/lib64/python2.6/tarfile.pytMscBseZdZRS(sBase exception.(t__name__t __module__t__doc__(((s/usr/lib64/python2.6/tarfile.pyRQst ExtractErrorcBseZdZRS(s%General exception for extract errors.(RlRmRn(((s/usr/lib64/python2.6/tarfile.pyRoTst ReadErrorcBseZdZRS(s%Exception for unreadble tar archives.(RlRmRn(((s/usr/lib64/python2.6/tarfile.pyRpWstCompressionErrorcBseZdZRS(s.Exception for unavailable compression methods.(RlRmRn(((s/usr/lib64/python2.6/tarfile.pyRqZst StreamErrorcBseZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(RlRmRn(((s/usr/lib64/python2.6/tarfile.pyRr]sR*cBseZdZRS(sException for invalid headers.(RlRmRn(((s/usr/lib64/python2.6/tarfile.pyR*`st _LowLevelFilecBs2eZdZdZdZdZdZRS(sLow-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. cCsihtid6titiBtiBd6|}ttdo|tiO}nti||d|_dS(NR[R\tO_BINARYi( RgtO_RDONLYtO_WRONLYtO_CREATtO_TRUNCthasattrRttopentfd(tselftnameR`((s/usr/lib64/python2.6/tarfile.pyt__init__ms cCsti|idS(N(RgtcloseR{(R|((s/usr/lib64/python2.6/tarfile.pyRvscCsti|i|S(N(RgRPR{(R|R((s/usr/lib64/python2.6/tarfile.pyRPyscCsti|i|dS(N(RgRRR{(R|R!((s/usr/lib64/python2.6/tarfile.pyRR|s(RlRmRnR~RRPRR(((s/usr/lib64/python2.6/tarfile.pyRsgs   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. c Cst|_|djot||}t|_n|djot|}|i}n|pd|_||_||_ ||_ ||_ d|_ d|_ t|_|djozyddk}Wntj otdnX||_|idd@|_|d jo|iq1|in|d jonyddk}Wntj otd nX|d jod|_|i|_q|i|_ndS( s$Construct a _Stream object. t*R1ltgziNszlib module is not availablelR[tbz2sbz2 module is not available(tTruet _extfileobjRLRstFalset _StreamProxyt getcomptypeR}R`tcomptypetfileobjtbufsizeRHtpostclosedtzlibt ImportErrorRqtcrc32tcrct _init_read_gzt_init_write_gzRtdbuftBZ2Decompressortcmpt BZ2Compressor(R|R}R`RRRRR((s/usr/lib64/python2.6/tarfile.pyR~sD                  cCs-t|do|i o|indS(NR(RyRR(R|((s/usr/lib64/python2.6/tarfile.pyt__del__scCs|iid|ii|ii |iid|_tidtt i }|i d||i i do|i d |_ n|i |i t dS(s6Initialize for writing with gzip compression. i isRR(R|RR]RH((s/usr/lib64/python2.6/tarfile.pyRP)s cCs|idjo|i|St|i}|ig}x||jow|i|i}|pPny|ii|}Wntj otdnX|i ||t|7}q<Wdi |}|||_|| S(s+Return size bytes from the stream. Rsinvalid compressed dataR1( RRRRRRt decompressRQRpR=R>(R|RRAR]RH((s/usr/lib64/python2.6/tarfile.pyR;s$    cCst|i}|ig}xP||joB|ii|i}|pPn|i||t|7}qWdi|}|||_|| S(ssReturn size bytes from stream. If internal buffer is empty, read another block from the stream. R1(RRHRRPRR=R>(R|RRAR]RH((s/usr/lib64/python2.6/tarfile.pyt__readQs    N(RlRmRnR~RRRRRRRRRRLRPRR(((s/usr/lib64/python2.6/tarfile.pyRs  .      RcBs2eZdZdZdZdZdZRS(ssSmall proxy class that enables transparent compression detection for the Stream interface (mode 'r|*'). cCs"||_|iit|_dS(N(RRPt BLOCKSIZERH(R|R((s/usr/lib64/python2.6/tarfile.pyR~gs cCs|ii|_|iS(N(RRPRH(R|R((s/usr/lib64/python2.6/tarfile.pyRPkscCs4|iidodS|iidodSdS(NsRtBZh91RR(RHt startswith(R|((s/usr/lib64/python2.6/tarfile.pyRos cCs|iidS(N(RR(R|((s/usr/lib64/python2.6/tarfile.pyRvs(RlRmRnR~RPRR(((s/usr/lib64/python2.6/tarfile.pyRbs    t _BZ2ProxycBsSeZdZd ZdZdZdZdZdZdZ 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|idd|_|idS(NR}(RR`tgetattrRLR}tinit(R|RR`((s/usr/lib64/python2.6/tarfile.pyR~s  cCsdddk}d|_|idjo,|i|_|iidd|_n|i|_dS(NiiR[R1( RRR`Rtbz2objRRRHR(R|R((s/usr/lib64/python2.6/tarfile.pyRs   cCs|ig}t|i}x}||joo|ii|i}|pPny|ii|}Wntj oPnX|i||t|7}qWdi ||_|i| }|i||_|i t|7_ |S(NR1( RHRRRPt blocksizeRRtEOFErrorR=R>R(R|RRXRtrawtdataRH((s/usr/lib64/python2.6/tarfile.pyRPs$    cCs6||ijo|in|i||idS(N(RRRP(R|R((s/usr/lib64/python2.6/tarfile.pyRscCs|iS(N(R(R|((s/usr/lib64/python2.6/tarfile.pyRscCs;|it|7_|ii|}|ii|dS(N(RRRRRRR(R|RR((s/usr/lib64/python2.6/tarfile.pyRRscCs7|idjo#|ii}|ii|ndS(NR\(R`RRRRR(R|R((s/usr/lib64/python2.6/tarfile.pyRsi@( RlRmRnRR~RRPRRRRR(((s/usr/lib64/python2.6/tarfile.pyRzs     t _FileInFilecBsSeZdZddZdZdZddZdZdZ dZ 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(RtoffsetRtsparsetposition(R|RRRR((s/usr/lib64/python2.6/tarfile.pyR~s     cCs|iS(s*Return the current file position. (R(R|((s/usr/lib64/python2.6/tarfile.pyRscCs ||_dS(s(Seek to a position in the file. N(R(R|R((s/usr/lib64/python2.6/tarfile.pyRscCsi|djo|i|i}nt||i|i}|idjo|i|S|i|SdS(s!Read data from the file. N(RLRRtminRt readnormalt readsparse(R|R((s/usr/lib64/python2.6/tarfile.pyRPs  cCs9|ii|i|i|i|7_|ii|S(s*Read operation for regular files. (RRRRRP(R|R((s/usr/lib64/python2.6/tarfile.pyRscCs`g}xJ|djo<|i|}|pPn|t|8}|i|q Wdi|S(s)Read operation for sparse files. iR1(treadsparsesectionRR=R>(R|RRRH((s/usr/lib64/python2.6/tarfile.pyRs cCs|ii|i}|djodSt||i|i|i}t|toN|i |i|i}|i i |i||i|7_|i i |S|i|7_t |SdS(s0Read a single section of a sparse file. R1N(RR$RRLRRRt isinstancet_datatrealposRRRPR (R|RtsectionR((s/usr/lib64/python2.6/tarfile.pyRs  N( RlRmRnRLR~RRRPRRR(((s/usr/lib64/python2.6/tarfile.pyRs     t ExFileObjectcBsheZdZdZdZd dZddZdZdZ e i dZ d Z d ZRS( saFile-like object for reading an archive member. Is returned by TarFile.extractfile(). icCsmt|i|i|it|dd|_|i|_d|_t|_ |i|_d|_ d|_ dS(NRR[iR1( RRt offset_dataRRRLR}R`RRRtbuffer(R|ttarfilettarinfo((s/usr/lib64/python2.6/tarfile.pyR~s      cCs|iotdnd}|ioD|djo|i}d|_qn|i| }|i||_n|djo||ii7}n!||ii|t|7}|it|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 fileR1N(RR)RRLRRPRR(R|RRH((s/usr/lib64/python2.6/tarfile.pyRPs        icCs9|iotdnd|ijo|iidd}n|ig}xto|ii|i}|i|| p d|joMdi ||_|iidd}|djot |i}nPqSqSW|djot ||}n|i| }|i||_|i t |7_ |S(sRead 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 iR1ii( RR)RR$RRRPRR=R>RRR(R|RRtbuffersRH((s/usr/lib64/python2.6/tarfile.pytreadline5s*       cCs>g}x1to)|i}|pPn|i|q W|S(s0Return a list with all remaining lines. (RRR=(R|tresulttline((s/usr/lib64/python2.6/tarfile.pyt readlinesTs cCs!|iotdn|iS(s*Return the current file position. sI/O operation on closed file(RR)R(R|((s/usr/lib64/python2.6/tarfile.pyR^s cCs |iotdn|tijo"tt|d|i|_n|tijoJ|djot|i|d|_qt|i||i|_nF|ti jo)tt|i||id|_n tdd|_ |i i |idS(s(Seek to a position in the file. sI/O operation on closed fileisInvalid argumentR1N( RR)RgtSEEK_SETRtmaxRRtSEEK_CURtSEEK_ENDRRR(R|Rtwhence((s/usr/lib64/python2.6/tarfile.pyRfs "  )  cCs t|_dS(sClose the file object. N(RR(R|((s/usr/lib64/python2.6/tarfile.pyR{sccs0x)to!|i}|pPn|VqWdS(s/Get an iterator over the file's lines. N(RR(R|R((s/usr/lib64/python2.6/tarfile.pyt__iter__s  N(RlRmRnRR~RLRPRRRRgRRRR(((s/usr/lib64/python2.6/tarfile.pyR s    cBseZdZddZdZdZeeeZdZdZ eee Z dZ dZ e ed d Zd Zd Zd ZedZdZedZedZedZeedZedZedZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'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. R1cCs||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_h|_dS(sXConstruct a TarInfo object. name is the optional name of the member. iiR1trootN(R}R`RRRRtchksumtREGTYPEttypetlinknameRRtdevmajortdevminorRRt pax_headers(R|R}((s/usr/lib64/python2.6/tarfile.pyR~s                cCs|iS(N(R}(R|((s/usr/lib64/python2.6/tarfile.pyt_getpathscCs ||_dS(N(R}(R|R}((s/usr/lib64/python2.6/tarfile.pyt_setpathscCs|iS(N(R(R|((s/usr/lib64/python2.6/tarfile.pyt _getlinkpathscCs ||_dS(N(R(R|R((s/usr/lib64/python2.6/tarfile.pyt _setlinkpathscCs d|ii|it|fS(Ns<%s %r at %#x>(t __class__RlR}tid(R|((s/usr/lib64/python2.6/tarfile.pyt__repr__scCs-h t|id6|id@d6|id6|id6|id6|id6|id6|id 6|i ot|i nd d 6|i d 6|i d 6|i d6|i d6}|d tjo)|did o|dcd7n||i||}y|id Wn tj o|||nXt|||jo|||q>WxddddfD]\}} ||jod||RK(RR7tpartsRHR((s/usr/lib64/python2.6/tarfile.pyRJs&cCsBtt|t\}}|djo|t|t7}n|S(sdReturn the string payload filled with zero bytes up to the next 512 byte border. i(RORRR (tpayloadRVRW((s/usr/lib64/python2.6/tarfile.pyt_create_payloadfs cCs[|t7}h}d|d<||dRRRR ( RRRtrecordstkeywordtvalueR0R-R%R((s/usr/lib64/python2.6/tarfile.pyRs,       cCs8t|tjotdn|ittjotdnt|dd!}|t|jotdn|}||_t|dd!|_ t|dd!|_ t|dd !|_ t|d d !|_ t|d d !|_ t|d d!|_||_|dd !|_t|d d !|_t|dd!|_t|dd!|_t|dd!|_t|dd!|_t|dd!}|itjo |i ido t|_n|io|i id|_ n|o(|itjo|d|i |_ n|S(sBConstruct a TarInfo object from a 512 byte string buffer. struncated headers empty headeriis bad checksumiidiliti|iiii i)iIiQiYiRf(RRR*tcountR R/RKRHR&R}R`RRRRRRRRRRRtAREGTYPERRtisdirtrstript GNU_TYPES(RRHRtobjR((s/usr/lib64/python2.6/tarfile.pytfrombufs<   #  cCsP|iit}|pdS|i|}|iit|_|i|S(sOReturn the next TarInfo object from TarFile object tarfile. N(RRPRRRRt _proc_member(RRRHR((s/usr/lib64/python2.6/tarfile.pyt fromtarfiles cCsz|ittfjo|i|S|itjo|i|S|itttfjo|i |S|i |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.6/tarfile.pyRscCs{|ii|_|i}|ip|itjo||i|i7}n||_|i |i |i |i |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.6/tarfile.pyRs  cCs|ii|i|i}|i|}|djotdn|i|_|it jot ||_ n$|it jot ||_ n|S(sSProcess the blocks that hold a GNU longname or longlink member. smissing subsequent headerN(RRPR!RRRLR*RRRR&R}RR(R|RRHtnext((s/usr/lib64/python2.6/tarfile.pyRs  c Cs|i}t}d}d}d}xtdD]}y6t|||d!}t||d|d!} Wntj oPnX||jo|it|||n|it|| ||| 7}|| }|d7}q1Wt|d} t|dd!} x| d jo|i i t }d }xtd D]}y6t|||d!}t||d|d!} Wntj oPnX||jo|it|||n|it|| ||| 7}|| }|d7}qBWt|d } qW|| jo|it|| |n||_ |i i |_|i|i|i|_| |_|S( s8Process a GNU sparse header plus extra headers. ilii iiiiiiii(RHt _ringbufferR+R/R)R=t_holeRR,RRPRRRRR!RR( R|RRHtspRtlastposRR.Rtnumbytest isextendedtorigsize((s/usr/lib64/python2.6/tarfile.pyRsZ              c Cs|ii|i|i}|itjo |i}n|ii}ti dti }d}xt o|i ||}|pPn|i \}}t|}||idd|id|d!} |id}| id} | ||<||7}qhW|i|} |ittfjo| djotdn| i||i|i|i| _d|joM| i} | ip| itjo| | i| i7} n| |_qn| S( sVProcess an extended or global header as described in POSIX.1-2001. s(\d+) ([^=]+)=iiiR:smissing subsequent headerRN(RRPR!RRRRRtretcompiletURtmatchtgroupsR(tendtstartRRRRRLR*R"R?R@RRRR ( R|RRHRtregexRR.R"R RR#R((s/usr/lib64/python2.6/tarfile.pyROs<  +     cCsx|iD]\}}|tjoq n|djo|id}n|tjo4yt||}Wqtj o d}qXnt|||}t|||q W|i|_dS(soReplace fields with supplemental information from a previous pax extended or global header. RRfiN( R t PAX_FIELDSRtPAX_NUMBER_FIELDSR)RBtsetattrRR(R|RR?R@R R((s/usr/lib64/python2.6/tarfile.pyR"s    cCs2t|t\}}|o|d7}n|tS(s_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. i(ROR(R|RRVRW((s/usr/lib64/python2.6/tarfile.pyR!scCs |itjS(N(Rt REGULAR_TYPES(R|((s/usr/lib64/python2.6/tarfile.pyRscCs |iS(N(R(R|((s/usr/lib64/python2.6/tarfile.pytisfilescCs |itjS(N(RR(R|((s/usr/lib64/python2.6/tarfile.pyRscCs |itjS(N(RtSYMTYPE(R|((s/usr/lib64/python2.6/tarfile.pytissymscCs |itjS(N(RtLNKTYPE(R|((s/usr/lib64/python2.6/tarfile.pytislnkscCs |itjS(N(RtCHRTYPE(R|((s/usr/lib64/python2.6/tarfile.pytischrscCs |itjS(N(RtBLKTYPE(R|((s/usr/lib64/python2.6/tarfile.pytisblkscCs |itjS(N(RtFIFOTYPE(R|((s/usr/lib64/python2.6/tarfile.pytisfifoscCs |itjS(N(RR(R|((s/usr/lib64/python2.6/tarfile.pytissparsescCs|itttfjS(N(RR<R>R@(R|((s/usr/lib64/python2.6/tarfile.pytisdevs(/RlRmRnR~RRtpropertyRRRRRRtDEFAULT_FORMATtENCODINGRRRRt classmethodRRt staticmethodRR RRRRRRRRRRR"R!RR7RR9R;R=R?RARBRC(((s/usr/lib64/python2.6/tarfile.pyRsP         3  ,   8 :          c Bs'eZdZdZeZeZdZeZ e Z d.Z eZeZd.dd.d.d.d.d.d.d.d.d.d.d ZdZdZeeeZed.dd.edZedd.dZedd.dd Zedd.dd Zhd d 6d d6dd6ZdZdZdZ dZ!d.d.d.dZ"e#dZ$d.e#d.dZ%d.dZ&dd.dZ'ddZ(dZ)dZ*dZ+d Z,d!Z-d"Z.d#Z/d$Z0d%Z1d&Z2d'Z3d(Z4d.d)Z5d*Z6d.d+Z7d,Z8d-Z9RS(/s=The TarFile Class provides an interface to tar archives. iR[c Cst|djp |djotdn||_hdd6dd6dd 6||_|pY|idjo*tii| od |_d|_nt||i}t|_ nT|djot |d o |i }nt |d o|i|_nt |_ |otii|nd|_ ||_|dj o ||_n|dj o ||_n|dj o ||_n|dj o ||_n|dj o ||_n| dj o | |_n$|djo d |_n d |_| dj o|itjo | |_n h|_| dj o | |_n| dj o | |_nt|_g|_t|_|ii|_h|_y|idjod|_ |i!|_ n|idjo\d|_ xPt oD|i!djo-|idjo|ii"t# dnPqqWn|idjo[t |_|ioD|ii$|ii%} |ii&| |it| 7_qnWn.|i p|ii'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'trbR[sr+btatwbR\R}R`sutf-8R9itawN((RR)R`t_modeRgRtexistst bltn_openRRRLRyR}RtabspathRR7Rt dereferencet ignore_zerosR?R@RRtdebugt errorlevelRtmemberst_loadedRRtinodest firstmemberR#RRRRRRR(R|R}R`RR7RRQRRR?R@RRSRTRH((s/usr/lib64/python2.6/tarfile.pyR~s  "$     #                              !  cCs |itjS(N(R7R(R|((s/usr/lib64/python2.6/tarfile.pyt _getposix;scCs@ddk}|idtd|o t|_n t|_dS(Nis use the format attribute insteadi(twarningstwarntDeprecationWarningRR7R2(R|RRZ((s/usr/lib64/python2.6/tarfile.pyt _setposix=s    c Ks,| o| otdn|djox|iD]}t||i|}|dj o|i}ny||d||SWq7ttfj o*} |dj o|i|q7q7q7Xq7WtdnCd|jo|idd\} }| pd} |pd}||ijot||i|}ntd|||| ||Sd |jo|id d\} }| pd} |pd}| d jotd n||| t || ||||} t | _ | S|d jo|i ||||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 openR[sr:*s%file could not be opened successfullyt:iRsunknown compression type %rt|trwsmode must be 'r' or 'w'RLsundiscernible modeN(R[sr:*( R)t OPEN_METHRRLRRpRqRtsplitRRRttaropen( RR}R`RRtkwargsRtfunct saved_posteReR]((s/usr/lib64/python2.6/tarfile.pyRzRsJ                cKsCt|djp |djotdn|||||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.6/tarfile.pyRcs i cKst|djp |djotdnyddk}|iWn%ttfj otdnX|djot||d}ny.|i |||i|||||}Wnt j ot 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 availableRXsnot a gzip file(RR)tgziptGzipFileRtAttributeErrorRqRLRORcRQRpRR(RR}R`Rt compresslevelRdRhR]((s/usr/lib64/python2.6/tarfile.pytgzopens"       c Kst|djp |djotdnyddk}Wntj otdnX|dj ot||}n|i||d|}y|i||||}Wnt j ot 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 availableRksnot a bzip2 file( RR)RRRqRLRtBZ2FileRcRQRpRR(RR}R`RRkRdRR]((s/usr/lib64/python2.6/tarfile.pytbz2opens   RcRRlRRnRcCs|iodS|idjop|iittd|itd7_t|it\}}|djo|iitt|qn|i p|ii nt |_dS(slClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NRLii( RR`RRRR RRROt RECORDSIZERRR(R|RVRW((s/usr/lib64/python2.6/tarfile.pyRs    cCs4|i|}|djotd|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 _getmemberRLtKeyError(R|R}R((s/usr/lib64/python2.6/tarfile.pyt getmembers cCs)|i|ip|in|iS(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_checkRVt_loadRU(R|((s/usr/lib64/python2.6/tarfile.pyt getmemberss  cCs(g}|iD]}||iq~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|t_[1]R((s/usr/lib64/python2.6/tarfile.pytgetnames sc Cs|id|d j o |i}n|d jo |}nt|}tii|\}}x#|dd!djo|d}qeW|i}||_|d joAt tdo|i oti |}qti |}nti |i}d}|i}t i|o|i|if} |i oK|idjo;| |ijo+||i| jot} |i| }qBt} | do||i| t td o.ti4|i5|_6ti7|i5|_8qn|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. RLiiRftlstatR1ltmajortminorN(9RsRLR}RhRgRt splitdriveRRRyRQRxtstattfstattfilenotst_modetS_ISREGtst_inotst_devtst_nlinkRWR:RtS_ISDIRRtS_ISFIFOR@tS_ISLNKR8treadlinktS_ISCHRR<tS_ISBLKR>R`tst_uidRtst_gidRtst_sizeRtst_mtimeRRRtpwdtgetpwuidRRqtgrptgetgrgidRRytst_rdevRRzR( R|R}tarcnameRtdrvRtstatresRtstmdtinodeR((s/usr/lib64/python2.6/tarfile.pyt gettarinfos          $                 cCs|ix |D]}|ot|iGd|ip|i|ip|ifG|ip |iodd|i |i fGn d|i Gdt i |id Gn|i|iodndG|o<|iod G|iGn|iod G|iGqnHqWd S( sPrint 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:%02diRfR1s->slink toN(RsReR`RRRRR=R?RRRRt localtimeRR}RR9RR;(R|tverboseR((s/usr/lib64/python2.6/tarfile.pytlistrs(     cCs|id|djo |}n|dj o&||o|idd|dS|idj o5tii||ijo|idd|dS|djof|oZ|djo d}nx@ti|D]+}|i|tii ||||qWndS|id||i ||}|djo|idd |dS|i o-t |d }|i |||in|ioj|i ||oRxOti|D]:}|itii ||tii ||||qWqn|i |dS( sAdd 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. RListarfile: Excluded %rNstarfile: Skipped %rt.R1istarfile: Unsupported type %rRI(RsRLt_dbgR}RgRRPtlistdirtaddR>RRROtaddfileRR(R|R}Rt recursivetexcludetfR((s/usr/lib64/python2.6/tarfile.pyRsB   ,   -    @cCs|idti|}|i|i|i|i}|ii||it |7_|dj oxt ||i|i t |i t\}}|djo&|iitt||d7}n|i|t7_n|ii|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. RLiiN(RsRRR7R?R@RRRRRRLRNRRORR RUR=(R|RRRHRVRW((s/usr/lib64/python2.6/tarfile.pyRs   Rc Cs;g}|djo |}nxT|D]L}|io)|i|ti|}d|_n|i||q$W|idtid|i x|D]}t i i ||i }y4|i|||i|||i||Wqtj o4}|idjoq3|idd|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(RLRR=RR`textracttsorttoperatort attrgettertreverseRgRR>R}tchowntutimetchmodRoRTR(R|RRUt directoriesRtdirpathRg((s/usr/lib64/python2.6/tarfile.pyt extractalls.      R1cCsE|idt|to|i|}n|}|iotii||i|_ ny&|i |tii||i Wnt j ok}|i djoqA|idjo|idd|iqA|idd|i|ifnAtj o4}|i djoqA|idd|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'. R[iis tarfile: %sstarfile: %s %rN(RsRt basestringRrR;RgRR>Rt _link_targett_extract_memberR}tEnvironmentErrorRTtfilenameRLRtstrerrorRo(R|tmemberRRRg((s/usr/lib64/python2.6/tarfile.pyRs$  &$cCs|idt|to|i|}n|}|io|i||S|itjo|i||S|ip |i oCt|i t ot dq|i |i|i|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() R[s'cannot extract (sym)link as file objectN(RsRRRrRt fileobjectRR R;R9RRRrt extractfileRpRRL(R|RR((s/usr/lib64/python2.6/tarfile.pyR(s  cCs|ddjo|d }ntii|}tii|}|o%tii| oti|n|ip |io$|idd|i |i fn|id|i |i o|i ||n|i o|i||n|io|i||n|ip |io|i||nc|ip |io|i||n5|itjo|i||n|i |||i|||ip$|i|||i||ndS(s\Extract the TarInfo object tarinfo to a physical file called targetpath. iRfis%s -> %sN(RgRRhtdirnameRNtmakedirsR;R9RR}RRtmakefileRtmakedirRAtmakefifoR=R?tmakedevtmakelinkRR t makeunknownRRR(R|Rt targetpatht upperdirs((s/usr/lib64/python2.6/tarfile.pyROs4$    cCsJyti|dWn/tj o#}|itijoqFnXdS(s,Make a directory called targetpath. iN(RgtmkdirRterrnotEEXIST(R|RRRg((s/usr/lib64/python2.6/tarfile.pyRs cCsC|i|}t|d}t|||i|idS(s'Make a file called targetpath. RKN(RRORNR(R|RRtsourcettarget((s/usr/lib64/python2.6/tarfile.pyRs   cCs+|i|||idd|idS(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.6/tarfile.pyRs cCs1ttdoti|n tddS(s'Make a fifo called targetpath. tmkfifosfifo not supported by systemN(RyRgRRo(R|RR((s/usr/lib64/python2.6/tarfile.pyRscCsttd pttd otdn|i}|io|tiO}n|tiO}ti||ti |i |i dS(s<Make a character or block device called targetpath. tmknodRs'special devices not supported by systemN( RyRgRoR`R?R|tS_IFBLKtS_IFCHRRRRR(R|RRR`((s/usr/lib64/python2.6/tarfile.pyRs"    cCs!|i}y8|ioti||nti|i|Wntj o|io4tiitii |i |}t |}ny|i |i ||Wqttfj oS}tii |}yti||Wqtj o}tdqXqXnXdS(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. slink could not be createdN(RR9RgtsymlinktlinkRRjRR>RR}RhRRrRRqRMtcopy2RQ(R|RRRRg((s/usr/lib64/python2.6/tarfile.pyRs$    c Cstottdortidjo_yti|id}WnOtj oCyti|i d}Wqtj oti }qXnXyti |i d}WnOtj oCyti |id}Wqtj oti}qXnXy_|io'ttdoti|||n(tidjoti|||nWqtj o}tdqXndS(s6Set owner of targetpath according to tarinfo. tgeteuidiitlchowntos2emxscould not change ownerN(RRyRgRRtgetgrnamRRqRRtgetgidtgetpwnamRRRtgetuidR9RtsystplatformRRRo(R|RRRtuRg((s/usr/lib64/python2.6/tarfile.pyRs,*cCsSttdo?yti||iWqOtj o}tdqOXndS(sASet file permissions of targetpath according to tarinfo. Rscould not change modeN(RyRgRR`RRo(R|RRRg((s/usr/lib64/python2.6/tarfile.pyRs cCs]ttdpdSy ti||i|ifWn!tj o}tdnXdS(sBSet modification time of targetpath according to tarinfo. RNs"could not change modification time(RyRgRRRRo(R|RRRg((s/usr/lib64/python2.6/tarfile.pyRs  cCs|id|idj o|i}d|_|S|ii|ixtoy8|ii|}|djodS|i i |Wn|t j op}|i o3|i dd|i|f|it7_qJq|idjott|ndSnXPqJW|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. traNis0x%X: %si(RsRXRLRRRRRRRUR=R*RRRRRpR (R|tmRRg((s/usr/lib64/python2.6/tarfile.pyR#s.      cCsz|i}|djot|}n|i|}x;t|dddD]#}|||ijo ||SqOWdS(s}Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. iiN(RuRLRtindexR+R}(R|R}RRUR0R.((s/usr/lib64/python2.6/tarfile.pyRp! s  cCs:x*to"|i}|djoPqqWt|_dS(sWRead through the entire archive file and look for readable members. N(RR#RLRV(R|R((s/usr/lib64/python2.6/tarfile.pyRt1 s    cCs\|iotd|iin|dj o'|i|jotd|indS(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(RRQRRlRLR`(R|R`((s/usr/lib64/python2.6/tarfile.pyRs; s cCs&|iot|iSt|SdS(s$Provide an iterator object. N(RVtiterRUtTarIter(R|((s/usr/lib64/python2.6/tarfile.pyRD s cCs%||ijoti|IJndS(s.Write debugging output to sys.stderr. N(RSRtstderr(R|tleveltmsg((s/usr/lib64/python2.6/tarfile.pyRL sN(:RlRmRnRSRRQRRRTRER7RFR?RLR@RRRRR~RYR]RDtposixRGRoRzRcRlRnRaRRrRuRwRRRRRRRRRRRRRRRRRRR#RpRtRsRR(((s/usr/lib64/python2.6/tarfile.pyRsn  `   H   c 9 % ! ' 0      $  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.6/tarfile.pyR~Z s cCs|S(s Return iterator object. ((R|((s/usr/lib64/python2.6/tarfile.pyR_ scCs|iip0|ii}|pt|i_tqpn4y|ii|i}Wntj o tnX|id7_|S(sReturn the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. i(RRVR#Rt StopIterationRURt IndexError(R|R((s/usr/lib64/python2.6/tarfile.pyR#c s   (RlRmRnR~RR#(((s/usr/lib64/python2.6/tarfile.pyRS s  t_sectioncBs eZdZdZdZRS(s$Base class for _data and _hole. cCs||_||_dS(N(RR(R|RR((s/usr/lib64/python2.6/tarfile.pyR~{ s cCs&|i|jo|i|ijSS(N(RR(R|R((s/usr/lib64/python2.6/tarfile.pyt __contains__~ s(RlRmRnR~R(((s/usr/lib64/python2.6/tarfile.pyRx s RcBseZdZdZRS(s/Represent a data section in a sparse file. cCs ti|||||_dS(N(RR~R(R|RRR((s/usr/lib64/python2.6/tarfile.pyR~ s(RlRmRnR~(((s/usr/lib64/python2.6/tarfile.pyR sR%cBseZdZRS(s/Represent a hole section in a sparse file. (RlRmRn(((s/usr/lib64/python2.6/tarfile.pyR% sR$cBs eZdZdZdZRS(sMRingbuffer class which increases performance over a regular list. cCs d|_dS(Ni(tidx(R|((s/usr/lib64/python2.6/tarfile.pyR~ scCs}|i}xdto\||}||joPn|d7}|t|jo d}n||ijodSq W||_|S(Nii(RRRRL(R|RRtitem((s/usr/lib64/python2.6/tarfile.pyR$ s       (RlRmRnR~R$(((s/usr/lib64/python2.6/tarfile.pyR$ s t TarFileCompatcBsteZdZdedZdZdZdZdZdZ dZ d d d Z d Z d ZRS( sRTarFile class compatible with standard module zipfile's ZipFile class. R[cCsddkl}|ddd|tjoti|||_n3|tjoti|||_n td|dd!d joU|ii }xC|D]7}|i |_ |i |_ ti|id |_qWndS( Ni(twarnpy3ks6the TarFileCompat class has been removed in Python 3.0t stacklevelisunknown compression constantiiR[i(RZRt TAR_PLAINRRcRt TAR_GZIPPEDRlR)RuR}RRt file_sizeRtgmtimeRt date_time(R|tfileR`t compressionRRUR((s/usr/lib64/python2.6/tarfile.pyR~ s      cCstd|iS(NcSs|iS((R}(R((s/usr/lib64/python2.6/tarfile.pyRk s(tmaptinfolist(R|((s/usr/lib64/python2.6/tarfile.pytnamelist scCstd|iiS(NcSs |itjS((RR6(R((s/usr/lib64/python2.6/tarfile.pyRk s(tfilterRRu(R|((s/usr/lib64/python2.6/tarfile.pyR s cCs|iidS(N(RR(R|((s/usr/lib64/python2.6/tarfile.pytprintdir scCsdS(N((R|((s/usr/lib64/python2.6/tarfile.pyttestzip scCs|ii|S(N(RRr(R|R}((s/usr/lib64/python2.6/tarfile.pytgetinfo scCs"|ii|ii|iS(N(RRRrRP(R|R}((s/usr/lib64/python2.6/tarfile.pyRP scCs|ii||dS(N(RR(R|RRt compress_type((s/usr/lib64/python2.6/tarfile.pyRR sc Csyddkl}Wn#tj oddkl}nXddk}t|i}t||_|i|i |_ |i i |||dS(Ni(tStringIO( t cStringIORRtcalendarRRRRttimegmRRRR(R|tzinfotbytesRRttinfo((s/usr/lib64/python2.6/tarfile.pytwritestr s cCs|iidS(N(RR(R|((s/usr/lib64/python2.6/tarfile.pyR sN(RlRmRnRR~RRRRRRPRLRRRR(((s/usr/lib64/python2.6/tarfile.pyR s       cCs9yt|}|itSWntj otSXdS(sfReturn True if name points to a tar archive that we are able to handle, else return False. N(RzRRRR(R}R]((s/usr/lib64/python2.6/tarfile.pyR s   (vRnt __version__tversiont __author__t__date__t __cvsid__t __credits__RRgRMR|RRR3RR+RRRRRRLt__all__R RRoRRRRRRRR:R8R<R>RR@tCONTTYPERRRRRRRR2RRER R6RR3RR(R4tS_IFLNKtS_IFREGRtS_IFDIRRtS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECtgetfilesystemencodingRFtgetdefaultencodingR#R&R/R8RBRKRNR_ReRjRhRt ExceptionRRoRpRqRrR*RsRtobjectRRRRRRRRRR%RR$RRRRRzRO(((s/usr/lib64/python2.6/tarfile.pyts.                                                 DL4% 4