m %UIc @sdZdZdZdZdZdZdZdkZdkZdk Z dk Z dk Z dk Z dk Z eidjo ed nydkZdkZWnej oeZZnXd d d d gZdZdZedZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'd Z(eeee e#e$e%e!e"e&e'e(f Z)eee%e(fZ*d!Z+d"Z,d#Z-d$Z.d%Z/d&Z0d'Z1d(Z2dZ3d)Z4d*Z5d+Z6d,Z7d-Z8d.Z9d/Z:d0Z;d1Z<d2Z=d3Z>ed4Z?e+d5fe,d6fe-d7fe.d8fe/d9fe0d:ffe4d;ffe5d<ffe6e1Bd=fe1d fe6d>ffe7d;ffe8d<ffe9e2Bd=fe2d fe9d>ffe:d;ffe;d<ffe<e3Bd?fe3d@fe<d>fff Z@dAZAeiBdBjo dCZCn eiDiCZCd eEfdDYZFdEeFfdFYZGdGeFfdHYZHdIeFfdJYZIdKeFfdLYZJdMfdNYZKdOfdPYZLdQeMfdRYZNd eMfdSYZOd eMfdTYZPdUfdVYZQdWfdXYZRdYeRfdZYZSd[eRfd\YZTd]eUfd^YZVd_ZWd.ZXd`fdaYZYdbZZePi[Z[dS(cs,Read from and write to tar format archives. s$Revision: 41341 $s0.6.4s!Lars Gustbel (lars@gustaebel.de)s5$Date: 2005-10-28 16:00:51 +1000 (Fri, 28 Oct 2005) $s9$Id: tarfile.py 41341 2005-10-28 06:00:51Z neal.norwitz $s3Gustavo Niemeyer, Niels Gustbel, Richard Townsend.Ntmacs'tarfile does not work for platform==mactTarFiletTarInfot is_tarfiletTarErrortiitustart00idilt0t1t2t3t4t5t6t7tLtKtSiii`i@i iiiiii@i iiiiicCs |itS(s@Convert a null-terminated string buffer to a python string. N(tstrstriptNUL(R((t$/data/zmath/lib/python2.4/tarfile.pytntsscCsTd}x"|d D]}|t|7}qWx"|dD]}|t|7}q6W|S(sCalculate the checksum for a member's header. It's a simple addition of all bytes, treating the chksum field as if filled with spaces. buf is a 512 byte long string buffer which holds the header. iiiN(tchktbuftctord(RRR((Rt calc_chksums  cCs|djodSn|djoti||dSndd}t||\}}xPt |D]B}|i |}t||jo tdn|i|qfW|djo@|i |}t||jo tdn|i|ndS(sjCopy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. iNiisend of file reached(tlengthtNonetshutilt copyfileobjtsrctdsttBUFSIZEtdivmodtblockst remaindertxrangetbtreadRtlentIOErrortwrite(R!R"RR#R%RR(R&((RR s(       tlt-R(tdRtptrtwRtxtttTcCskg}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() R.tN(tpermtfilemode_tablettabletbittchartmodetappendtjoin(R<R7R;R9R:((Rtfilemodes   t/cCstii|itidS(NR@(tostpathtnormpathtreplacetsep(RB((RtscBstZdZRS(sBase exception.(t__name__t __module__t__doc__(((RRs t ExtractErrorcBstZdZRS(s%General exception for extract errors.(RGRHRI(((RRJs t ReadErrorcBstZdZRS(s%Exception for unreadble tar archives.(RGRHRI(((RRKs tCompressionErrorcBstZdZRS(s.Exception for unavailable compression methods.(RGRHRI(((RRLs t StreamErrorcBstZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(RGRHRI(((RRMs t _LowLevelFilecBs2tZdZdZdZdZdZRS(sLow-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. cCsjhdti<dtitiBtiB<|}ttdo|tiO}nti|||_ dS(NR1R2tO_BINARY( RAtO_RDONLYtO_WRONLYtO_CREATtO_TRUNCR<thasattrROtopentnametselftfd(RWRVR<((Rt__init__s0cCsti|idS(N(RAtcloseRWRX(RW((RRZscCsti|i|S(N(RAR)RWRXtsize(RWR[((RR)scCsti|i|dS(N(RAR,RWRXR(RWR((RR,s(RGRHRIRYRZR)R,(((RRNs   t_StreamcBstZdZdZdZdZdZdZdZdZ dZ d d Z e d 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. cCswt|_|djot||}t|_n|pd|_||_||_ ||_||_ d|_ d|_ t|_ |djopy dk}Wntj otdnX||_|id|_|djo|iq|in|djohy dk}Wntj otdnX|djod|_|i|_qs|i|_ndS( s$Construct a _Stream object. R6ltgzNszlib module is not availableR1tbz2sbz2 module is not available(tTrueRWt _extfileobjtfileobjRRNRVR<tFalsettypetbufsizeRtpostclosedtzlibt ImportErrorRLtcrc32tcrct _init_read_gzt_init_write_gzR^tdbuftBZ2Decompressortcmpt BZ2Compressor(RWRVR<RcRaRdRgR^((RRYs@                  cCs|ip|indS(N(RWRfRZ(RW((Rt__del__=s cCs|iid|ii|ii |iid|_tidt t i }|i d||i ido|i d |_ n|i |i tdS(s6Initialize for writing with gzip compression. i isReR*(RWR[R4R((RR)s cCs|idjo|i|Snt|i}|ig}x_||joQ|i|i}|pPn|i i |}|i ||t|7}q?Wdi |}|||_|| S(s+Return size bytes from the stream. R}R6N(RWRcRR[R*RmRR4RdRRot decompressR=R>(RWR[RR4R((RRs     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. R6N( R*RWRRR4R[RaR)RdR=R>(RWR[RR4R((Rt__reads    (RGRHRIRYRqRlR,R{RZRkRRRR)RR(((RR\ s  (      t ExFileObjectcBsttZdZdZdZddZdZedZedZ dZ d Z d d Z d Z RS( sFile-like object for reading an archive member. Is returned by TarFile.extractfile(). Support for sparse files included. cCs|i|_|i|_d|_t|_|i|_ |i |_ d|_ d|_ |i o|i|_|i|_n |i|_dS(NR1lR6(ttarfileRaRWttarinfoRVR<RbRft offset_datatoffsetR[Ret linebuffertissparsetsparset _readsparseR)t _readnormal(RWRR((RRYs          cCs|ii|S(s"Overloadable read method. N(RWRaR)R[(RWR[((RRsicCsI|djo ti}n|iid}|djot||}n|t|i8}xt|djof|djoY|i t|d}|pPn|i|7_|t|8}|iid}qbW|djo|i}d|_|Sn|i| }|i|d|_x |ddjo|d }q!W|dS( sRead a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). is idiR6is N( R[tsystmaxintRWRtfindtnltminR*R)RR(RWR[RRR((Rtreadlines2       cCs>g}x1to)|i}|pPn|i|q W|S(s2Return a list with all (following) lines. N(tresultR_RWRtlineR=(RWRR((Rt readliness cCs|io tdn|ii|i|i|i|i}|djo |}nt ||}|i|7_|i |S(s*Read operation for regular files. sfile is closedN( RWRft ValueErrorRaRRReR[t bytesleftRt bytestoreadRt_ExFileObject__read(RWR[RR((RR"s    cCs|io tdn|djo|i|i}ng}xJ|djo<|i|}|pPn|t |8}|i |qAWdi |S(s)Read operation for sparse files. sfile is closediR6N( RWRfRR[RRetdatat_readsparsesectionRR*R=R>(RWR[RR((RR0s    cCs|ii|i}|djodSnt||i|i|i}t |t oN|i |i|i}|i|7_|i i|i||i|Sn|i|7_t|SdS(s0Read a single section of a sparse file. R6N(RWRRRetsectionRRR[Rttoreadt isinstancet_datatrealposRaRRR(RWR[RRR((RRBs  cCs|iS(s*Return the current file position. N(RWRe(RW((RRTsicCsd|_|djo"tt|d|i|_n|djoJ|djot|i|d|_qt|i||i|_n|djo)tt|i||id|_ndS(s(Seek to a position in the file. R6iiiN(RWRtwhenceRtmaxReR[(RWReR((RRYs  "    cCs t|_dS(sClose the file object. N(R_RWRf(RW((RRZgs(RGRHRIRYRRRRRRRRRRZ(((RRs         cBstZdZddZdZdZeeZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZRS(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. R6cCs||_d|_d|_d|_d|_d|_d|_t|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_dS(sXConstruct a TarInfo object. name is the optional name of the member. iiR6tusertgroupN(RVRWR<tuidtgidR[tmtimetchksumtREGTYPERctlinknametunametgnametdevmajortdevminortprefixRR(RWRV((RRYxs"               cCs d|ii|it|fS(Ns<%s %r at %#x>(RWt __class__RGRVtid(RW((Rt__repr__scCsi|}t|dd!|_t|dd!d|_t|dd!d|_t|dd!d|_|dt djot |dd!d|_ nMd |_ x@t d D]2}|i dK_ |i t|d |7_ qWt |dd !d|_t|d d !d|_|d d!|_t|dd!|_t|dd!|_t|dd!|_y6t|dd!d|_t|dd!d|_Wn#tj od|_|_nX|dd!|_|io |iido t|_n|itjo.ttii t|i|i|_n|i!o|id7_n|S(sBConstruct a TarInfo object from a 512 byte string buffer. iidiliiti|iili i}iiiii i)iIiQiYiR@N("tclsRRRRVtintR<RRtchrRxR[trangeRRRRRcRRRRRRRtisregR|tDIRTYPEtGNUTYPE_SPARSERCRARBR>tisdir(RRRR((Rtfrombufs@   !  . c Cs|itjod|i} nU|i}d} x2tdD]$}t|d@| } |dL}q=Wtd| } g}x|idfd|i d @dfd|i dfd|i df| d fd|i d fd|i d f|idftd ftdf|idf|idfd|idfd|idf|idffD]5\}}t|}|i|| ||tqLWdi|}t|}|d d||d}|t t|t7}||_|S(s8Return a tar header block as a 512 byte string. s%011oR6i iiiids%07oii s iiii iis%06oN(s i(!RWR[tMAXSIZE_MEMBERRRRRtpartsRVR<RRRRcRtMAGICtVERSIONRRRRRtvaluet fieldsizeR*R-R=RR>RRRt BLOCKSIZE( RWRRRR-RRRRR[((Rttobufs*    !  cCs |itjS(N(RWRct REGULAR_TYPES(RW((RRscCs |iS(N(RWR(RW((RtisfilescCs |itjS(N(RWRcR(RW((RRscCs |itjS(N(RWRctSYMTYPE(RW((RtissymscCs |itjS(N(RWRctLNKTYPE(RW((RtislnkscCs |itjS(N(RWRctCHRTYPE(RW((RtischrscCs |itjS(N(RWRctBLKTYPE(RW((RtisblkscCs |itjS(N(RWRctFIFOTYPE(RW((RtisfifoscCs |itjS(N(RWRcR(RW((RRscCs|itttfjS(N(RWRcRRR(RW((Rtisdevs(RGRHRIRYRRt classmethodRRRRRRRRRRR(((RRps    0  /         cBs.tZdZdZeZeZdZeZe Z e de dZ e de dddZ ee Z de dZeeZde dd ZeeZde dd ZeeZhd d <d d<ddt td o.ti;|i<| _=ti>|i<| _?qn| 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. RiiR@tlstatR6iltmajortminorN(@RWRRaRRVtarcnameRCRARBt splitdrivetdrvRRRTt dereferenceRtstatreststattfstattfilenoRtst_modetstmdtS_ISREGtst_inotst_devtinodetst_nlinkRRRcRtS_ISDIRRtS_ISFIFORtS_ISLNKRtreadlinktS_ISCHRRtS_ISBLKRR<tst_uidRtst_gidRtst_sizeR[tst_mtimeRtpwdtgetpwuidRRtgrptgetgrgidRRtst_rdevRRR( RWRVRRaR RRR RcRR((Rt gettarinfo-s         +               cCs|ix|D]}|ot|iGd|ip|i|ip|i fG|i p |i odd|i |i fGn d|iGdti|id Gn|iG|o<|iodG|iGn|iodG|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:%02dis->slink toN(RWRRtverboseR?R<RRRRRRRRR[Ryt localtimeRRVRRR(RWR&R((Rtlists$  (   cCs|id|djo |}n|idj oDtii|tii|ijo|idd|dSn|djoc|oT|djo d}nx:ti dD]%}|i |tii ||qWndSn|id||i||}|djo|idd|dSn|io-t|d }|i|||in|iod|i||oLxIti |D]4}|i tii ||tii ||qWqn|i|dS( sQAdd 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. Ristarfile: Skipped %rNt.R6istarfile: Unsupported type %rR(RWRRRRVRARBtabspatht_dbgt recursivetlistdirtftaddR>R%RRRtaddfileRZR(RWRVRR,R.R((RR/s>   8   '    :cCs|idt|i|_|io|id7_n|iot|i|_n|itjo+|i o t dq|i ddnt |it joV|i ot dt q|i|it|it d |_|i ddnt |itjo|i o|itd }x'|o|d djo|d }q:W|it |}|d }| pt |tjot d tn||_||_q|i|it|itd |_|i dd n|ii|i|it7_|d j oxt||i|it|it\}}|d jo&|iitt||d7}n|i|t7_n|ii |d S(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. RR@sfile is too large (>= 8 GB)is)tarfile: Created GNU tar largefile headerslinkname is too long (>%d)is+tarfile: Created GNU tar extension LONGLINKisname is too long (>%d)s+tarfile: Created GNU tar extension LONGNAMEiN(!RWRRCRRVRRR[RtposixRR+R*t LENGTH_LINKt_create_gnulongtGNUTYPE_LONGLINKt LENGTH_NAMEt LENGTH_PREFIXRtGNUTYPE_LONGNAMERaR,RRRRR R$R%R&RRR=(RWRRaRVRR%R&((RR0sT            R6cCsE|idt|to |}n|i|}|ioti i ||i |_ ny&|i |ti i ||iWntj ok}|idjoqA|idjo|idd|iqA|idd|i|ifnAtj o4}|idjoqA|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'. R1iis tarfile: %sstarfile: %s %rN(RWRRtmemberRRRRRARBR>Rt _link_targett_extract_memberRVtEnvironmentErrortet errorleveltfilenameRR+tstrerrorRJ(RWR8RBR<R((Rtextract%s&   &$cCs|idt|to |}n|i|}|io|i||Sn|i t jo|i||Sn_|i p |i o@t|i to tdq|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() R1s'cannot extract (sym)link as file objectN(RWRRR8RRRRt fileobjectRctSUPPORTED_TYPESRRRaR\RMt extractfileRRR(RWR8R((RRCFs    cCsl|ddjo|d }ntii|}tii|}|otii| ot}||_ t |_ d|_ |i|_|i|_|i|_|i|_|i|_y|i||i WqqXn|ip |io$|idd|i |ifn|id|i |io|i||n|io|i||n|io|i||n|ip |i o|i!||nc|ip |io|i"||n5|i t#jo|i$||n|i|||i%|||ip$|i&|||i'||ndS(s\Extract the TarInfo object tarinfo to a physical file called targetpath. iR@iis%s -> %sN((t targetpathRARBRCtdirnamet upperdirstexistsRttiRVRRcR<RRRRRRRWR:RRR+RRtmakefileRtmakedirRtmakefifoRRtmakedevtmakelinkRBt makeunknowntchowntchmodtutime(RWRRDRHRF((RR:msN         $    cCsGyti|Wn/tj o#}|itijoqCnXdS(s,Make a directory called targetpath. N(RAtmkdirRDR;R<terrnotEEXIST(RWRRDR<((RRJs cCsC|i|}t|d}t|||i|idS(s'Make a file called targetpath. RN( RWRCRtsourceRRDttargetR RZ(RWRRDRVRU((RRIs   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(RWRIRRDR+Rc(RWRRD((RRNscCs.ttdoti|n tddS(s'Make a fifo called targetpath. tmkfifosfifo not supported by systemN(RTRARWRDRJ(RWRRD((RRKscCsttd pttd o tdn|i}|io|tiO}n|tiO}ti ||ti |i |i dS(s<Make a character or block device called targetpath. tmknodRLs'special devices not supported by systemN(RTRARJRR<RR tS_IFBLKtS_IFCHRRXRDRLRR(RWRRDR<((RRLs"     cCs|i}y8|ioti||nti|i|Wnt j o|io4ti i ti i |i |}t|}ny|i|i||Wqttfj oP}ti i|}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(RRtlinkpathRRAtsymlinkRDtlinkR9RRBR>RERVRCRWR:RR;RR<Rtcopy2R+(RWRRDR<R[((RRMs&    cCstottdootidjo\yti|id}WnOt j oCyti |i d}Wqt j oti }qXnXyti |id}WnOt j oCyti|id}Wqt j oti}qXnXy_|io'ttdoti|||n(tidjoti|||nWqtj o}tdqXndS(s6Set owner of targetpath according to tarinfo. tgeteuidiitlchowntos2emxscould not change ownerN(R RTRAR_R"tgetgrnamRRtgRR#RtgetgidtgetpwnamRtuR!RtgetuidRR`RDRtplatformROR;R<RJ(RWRRDR<RcRf((RROs.*cCsPttdo<yti||iWqLtj o}tdqLXndS(sASet file permissions of targetpath according to tarinfo. RPscould not change modeN( RTRARPRDRR<R;R<RJ(RWRRDR<((RRPs cCsttdpdSntidjo|iodSny ti||i|ifWnt j o}t dnXdS(sBSet modification time of targetpath according to tarinfo. RQNtwin32s"could not change modification time( RTRARRhRRRQRDRR;R<RJ(RWRRDR<((RRQs cCs|id|id j o|i}d |_|Sn|ii|ixto|ii t }|pd Snyt i |}Wntj o|ioY|itt jo d}nd}|idd|i|f|it 7_qMq"|idjo tdnd SnXPqMW|it|jo|idd |in|i|_|it 7_|i|ijo|i|i||Sn|i|_|ip|itjo|i|i|i7_n|i i!||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. tratemptytinvalidis0x%X: %s blockis$empty, unreadable or compressed fileistarfile: Bad Checksum %rN("RWRRRtmRaRRR_R)RRRRRRt ignore_zerostcountRtadjR+RKRRRVRct TYPE_METHRRRBt_blockR[RR=(RWRmRRRp((RR(sJ         cCsd}|i}xG|djo9|iit}||7}|i t7_ |t8}qW|i }|i |_ |i t jot ||_n$|i tjot ||_n|S(sTEvaluate the blocks that hold a GNU longname or longlink member. R6iN(RRR[RoRWRaR)RtblockRRRcR7RRVR4R(RWRRoRRRs((Rt proc_gnulongws      c Cs|i} t}d}d}d}xtdD]} y<t | ||d!d}t | |d|d!d}Wnt j oPnX||jo|it|||n|it|||||7}||}|d7}q4Wt| d} t | dd !d}x| d jo|iit} |i t7_ d }xtd D]} y<t | ||d!d}t | |d|d!d}Wnt j oPnX||jo|it|||n|it|||||7}||}|d7}q]Wt| d } qW||jo|it|||n||_|i |_|i |i|i7_ ||_|ii||S(s8Analyze a GNU sparse header plus extra headers. ilii iiiiiiiiiN(RRRt _ringbuffertspRetlastposRR'RRRtnumbytesRR=t_holeRRt isextendedtorigsizeRWRaR)RRRRrR[R( RWRR{RRxRwRvReRRRzR((Rt proc_sparses`   "     "       cCs2t|t\}}|o|d7}n|tS(s_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. iN(R$RoRR%R&(RWRoR%R&((RRrs cCs}|i}|djot|}n|i|}x>t|dddD]&}|||i jo ||SqOqOWdS(s}Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. iiN( RWRRRRR*tendtindexR'RRV(RWRVRR}RR((RRs  cCs:x*to"|i}|djoPqqWt|_dS(sWRead through the entire archive file and look for readable members. N(R_RWRRRR(RWR((RRs   cCsV|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(RWRfR+RRGR<RR(RWR<((RRs  cCs)|iot|iSn t|SdS(s$Provide an iterator object. N(RWRtiterRtTarIter(RW((Rt__iter__s cCs|t7}t}d|_||_d|_t||_|i i |i |i t 7_ |i i |t|it \}}|djo&|i i tt ||d7}n|i |t 7_ dS(sWrite a GNU longname/longlink member to the TarFile. It consists of an extended tar header, with the length of the longname as size, followed by data blocks, which contain the longname as a null terminated string. s ././@LongLinkiiN(RVRRRRcR<R*R[RWRaR,RRRR$R%R&(RWRVRcR%RR&((RR3s      cCs%||ijoti|IJndS(s.Write debugging output to sys.stderr. N(tlevelRWtdebugRtstderrtmsg(RWRR((RR+!s(6RGRHRIRRbR RnR=R1RRARRYRURRRRRRZRRRR%R_R(R/R0R@RCR:RJRIRNRKRLRMRORPRQRRtR|R7R4RRqRrRRRRR3R+(((RR s` CA  $  !  d 4 C ! ' :       O  =!   RcBs)tZdZdZdZdZRS(sMIterator Class. for tarinfo in TarFile(...): suite... cCs||_d|_dS(s$Construct a TarIter object. iN(RRWR~(RWR((RRY/s cCs|S(s Return iterator object. N(RW(RW((RR4scCs|iip0|ii}|pt|i_tqpn4y|ii|i}Wnt j o tnX|id7_|S(sReturn the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. iN( RWRRRRR_t StopIterationRR~t IndexError(RWR((RR8s   (RGRHRIRYRR(((RR(s   t_sectioncBs tZdZdZdZRS(s$Base class for _data and _hole. cCs||_||_dS(N(RRWR[(RWRR[((RRYPs cCs(|i|jo|i|ijnS(N(RWRR[(RWR((Rt __contains__Ss(RGRHRIRYR(((RRMs  RcBstZdZdZRS(s/Represent a data section in a sparse file. cCs ti|||||_dS(N(RRYRWRR[R(RWRR[R((RRYYs(RGRHRIRY(((RRVs RycBstZdZRS(s/Represent a hole section in a sparse file. (RGRHRI(((RRy]s RucBs tZdZdZdZRS(sMRingbuffer class which increases performance over a regular list. cCs d|_dS(Ni(RWtidx(RW((RRYfscCs|i}xgto_||}||joPn|d7}|t|jo d}n||ijodSq q W||_|S(Nii(RWRR_titemRR*R(RWRRR((RRhs       (RGRHRIRYR(((RRubs  it TarFileCompatcBsttZdZdedZdZdZdZdZdZ dZ e e d Z d Z d ZRS( sRTarFile class compatible with standard module zipfile's ZipFile class. R1cCs|tjoti|||_n0|tjoti |||_n t d|dd!djok|ii }xYt t|D]A}||}|i|_|i|_ti|id |_qWndS(Nsunknown compression constantiiR1i(t compressiont TAR_PLAINRRRR<RWRt TAR_GZIPPEDRRRRR'R*RRmRVR>R[t file_sizeRytgmtimeRt date_time(RWRR<RRRmR((RRYs      cCstd|iS(NcCs|iS(N(RmRV(Rm((RRFs(tmapRWtinfolist(RW((RtnamelistscCstd|iiS(NcCs |itjS(N(RmRcR(Rm((RRFs(tfilterRWRR(RW((RRs cCs|iidS(N(RWRR((RW((RtprintdirscCsdS(N((RW((RttestzipscCs|ii|S(N(RWRRRV(RWRV((RtgetinfoscCs"|ii|ii|iS(N(RWRRCRRVR)(RWRV((RR)scCs|ii||dS(N(RWRR/R>R(RWR>Rt compress_type((RR,scCs_dk}dk}|i|_|i|_|i|i|_ |i i ||i|dS(N(tStringIOtcalendartzinfoR>RVRR[ttimegmRRRWRR0tbytes(RWRRRR((Rtwritestrs     cCs|iidS(N(RWRRZ(RW((RRZs(RGRHRIRRYRRRRRR)RR,RRZ(((RR|s        cCs<yt|}|itSWntj o tSnXdS(sfReturn True if name points to a tar archive that we are able to handle, else return False. N(RURVR4RZR_RRb(RVR4((RRs  (\RIt __version__tversiont __author__t__date__t __cvsid__t __credits__RRARR RSRyRvRhRhR"R Rt__all__RRRRRR5R2R6RRtAREGTYPERRRRRRtCONTTYPER7R4RRBRtS_IFLNKtS_IFREGRYtS_IFDIRRZtS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECRRR R8R?RERCRBt ExceptionRRJRKRLRMRNR\tobjectRRRRRRRyR(RuRRRRRU(SRLRvRRRNRR\RRRRRZRRRRMRRRRRRR RRRYRRRR4RRRRRKR8RuRRARRRRRyRUR7RRRRSRRRRRR R2RRR?RRRRRJR6RRR RRRRRBR5RR"RRRCRRyR((Rt?s         *     "% /