abc @s>ddlmZdZdZdZdZdZdZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZyddlZddlZWnek reZZnXeefZyeef7ZWnek rnXd d d d gZejd dkr3ddlZn ddlZejZdZdZ e dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2d!Z3d"Z4d#Z5d Z6d$Z7d%Z8e7Z9e'e(e)e*e-e.e/e+e,e0e1e2f Z:e'e(e/e2fZ;e0e1e2fZ<d&d'd(d)d*d+d,d-fZ=e>d&d'd,d-fZ?ie@d.6e@d/6e@d)6eAd*6eAd+6eAd(6ZBd0ZCd1ZDd2ZEd3ZFd4ZGd5ZHd6ZId7ZJdZKd8ZLd9ZMd:ZNd;ZOd<ZPd=ZQd>ZRd%ZSd$ZTe jUd?d@fkr)dAZVn ejWZVdBZXdCZYdDZZd=e9dEZ[dFZ\edGZ]eCdHfeDdIfeEdJfeFdKfeGdLfeHdMffeLdNffeMdOffeNeIBdPfeId feNd!ffeOdNffePdOffeQeJBdPfeJd feQd!ffeRdNffeSdOffeTeKBdQfeKdRfeTd!fff Z^dSZ_d e`fdTYZadUeafdVYZbdWeafdXYZcdYeafdZYZdd[eafd\YZed]eafd^YZfd_effd`YZgdaeffdbYZhdceffddYZideeffdfYZjdgeffdhYZkdielfdjYZmdkelfdlYZndmelfdnYZodoelfdpYZpdqelfdrYZqdselfdtYZrd elfduYZsd elfdvYZtdwelfdxYZudyZveZwetjZdS(zi(tprint_functions $Revision$s0.9.0s&Lars Gust\u00e4bel (lars@gustaebel.de)s5$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $s?$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $s8Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend.NtTarFiletTarInfot is_tarfiletTarErroriisiisustar sustar00idit0t1t2t3t4t5t6t7tLtKtStxtgtXiitpathtlinkpathtsizetmtimetuidtgidtunametgnametatimetctimeiii`i@i iiiiii@i iiitnttcesutf-8cCs,|j||}|| |t|tS(s8Convert a string to a null-terminated bytes object. (tencodetlentNUL(tstlengthtencodingterrors((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytstnscCs8|jd}|dkr(|| }n|j||S(s8Convert a null-terminated bytes object to a string. si(tfindtdecode(R"R$R%tp((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytntss  cCs|dtdkr^y%tt|ddp1dd}Wqtk rZtdqXnId}x@tt|dD](}|dK}|t||d7}q{W|S( s/Convert a number field to a python number. iitasciitstrictRisinvalid headeri(tchrtintR*t ValueErrortInvalidHeaderErrortrangeR tord(R"tnti((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytntis%  cCsd|kod|dknrHd|d|fjdt}n|tksh|d|dkrwtdn|dkrtjdtjd |d}nt}x6t|dD]$}|j d|d @|dL}qW|j dd |S( s/Convert a python number to a number field. iiis%0*oR+isoverflow in number fieldR tlii( RR!t GNU_FORMATR/tstructtunpacktpackt bytearrayR1tinsert(R3tdigitstformatR"R4((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytitns $$  % 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(tsumR8R9(tbuftunsigned_chksumt signed_chksum((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt calc_chksumss 77cCs|dkrdS|dkrSx0trN|jd}|s>Pn|j|qWdSd}t||\}}xQt|D]C}|j|}t||krtdn|j|q{W|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@i@(tNonetTruetreadtwritetdivmodR1R tIOError(tsrctdstR#REtBUFSIZEtblockst remaindertb((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt copyfileobjs,    R6t-RTtdtcR)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() RVt(tfilemode_tabletappendtjoin(tmodetpermttabletbittchar((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytfilemode8s  cBseZdZRS(sBase exception.(t__name__t __module__t__doc__(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRGst ExtractErrorcBseZdZRS(s%General exception for extract errors.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRjJst ReadErrorcBseZdZRS(s&Exception for unreadable tar archives.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRkMstCompressionErrorcBseZdZRS(s.Exception for unavailable compression methods.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRlPst StreamErrorcBseZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRmSst HeaderErrorcBseZdZRS(s!Base exception for header errors.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRnVstEmptyHeaderErrorcBseZdZRS(sException for empty headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRoYstTruncatedHeaderErrorcBseZdZRS(s Exception for truncated headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRp\stEOFHeaderErrorcBseZdZRS(s"Exception for end of file headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRq_sR0cBseZdZRS(sException for invalid headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR0bstSubsequentHeaderErrorcBseZdZRS(s3Exception for missing and invalid extended headers.(RgRhRi(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRrest _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(NRYRZtO_BINARYi( tostO_RDONLYtO_WRONLYtO_CREATtO_TRUNCthasattrRttopentfd(tselftnameRa((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__init__rs cCstj|jdS(N(RutcloseR|(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR{scCstj|j|S(N(RuRKR|(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRK~scCstj|j|dS(N(RuRLR|(R}R"((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRLs(RgRhRiRRRKRL(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRsls   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|_y|dkr%yddl}Wntk rtdnX||_|jd|_|dkr|jq%|jn|d kryddl}Wntk r`td nX|dkrd|_|j|_q|j|_nWn,|js|j jnt|_nXdS( s$Construct a _Stream object. t*R]itgziNszlib module is not availableRYtbz2sbz2 module is not available(RJt _extfileobjRIRstFalset _StreamProxyt getcomptypeR~RatcomptypetfileobjtbufsizeREtpostclosedtzlibt ImportErrorRltcrc32tcrct _init_read_gzt_init_write_gzRtdbuftBZ2Decompressortcmpt BZ2CompressorR(R}R~RaRRRRR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRsP                        cCs*t|dr&|j r&|jndS(NR(RzRR(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__del__scCs|jjd|jj|jj |jjd|_tjdtt j }|j d|d|j j dr|j d |_ n|j |j j dd td S( s6Initialize for writing with gzip compression. i isZ2RS(@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. R~RaRRRRtchksumttypetlinknameRRtdevmajortdevminorRRt pax_headersRRt_sparse_structst _link_targetR]cCs||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_i|_dS(sXConstruct a TarInfo object. name is the optional name of the member. iiR]N(R~RaRRRRRtREGTYPERRRRRRRRRIRR(R}R~((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRs"                cCs|jS(N(R~(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_getpathscCs ||_dS(N(R~(R}R~((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_setpathscCs|jS(N(R(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt _getlinkpathscCs ||_dS(N(R(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt _setlinkpathscCs d|jj|jt|fS(Ns<%s %r at %#x>(t __class__RgR~tid(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__repr__scCsi |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$R%R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyttobufs    cCst|dny||jd d Wn"tk r||||nXt|||kr>||||q>WxddddfD]\}}||krd||R$R%tpartsRER((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRYs&$#cCs@tt|t\}}|dkr<|t|t7}n|S(sdReturn the string payload filled with zero bytes up to the next 512 byte border. i(RMR RR!(tpayloadRRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt_create_payloadus cCsm|j||t}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_gnulongRt _proc_sparseRRtSOLARIS_XHDTYPEt _proc_paxt _proc_builtin(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR%s   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((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR+$s  cCs|jj|j|j}y|j|}Wntk rPtdnX|j|_|jt krt ||j |j |_ n-|jtkrt ||j |j |_n|S(sSProcess the blocks that hold a GNU longname or longlink member. s missing or bad subsequent header(RRKR.RR&RnRrRRRR*R$R%R~RR(R}RREtnext((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR'5s  c Cs|j\}}}|`x|r|jjt}d}xtdD]}}y6t|||d!}t||d|d!} Wntk rPnX|r| r|j|| fn|d7}qFWt|d}qW||_ |jj |_ |j |j |j |_||_ |S(s8Process a GNU sparse header plus extra headers. iii ii(RRRKRR1R5R/R_RRRRR.RR( R}RR R"R#RERR4RR!((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR(Ks(     cCs|jj|j|j}|jtkr9|j}n|jj}tj d|}|dk r|j dj d|ds  cCsx|jD]\}}|dkr8t|d|q |dkr]t|dt|q |dkrt|dt|q |tkr |tkryt||}Wqtk rd}qXn|dkr|jd}nt|||q q W|j|_dS( soReplace fields with supplemental information from a previous pax extended or global header. sGNU.sparse.nameRsGNU.sparse.sizeRsGNU.sparse.realsizeiRN( RtsetattrR.t PAX_FIELDStPAX_NUMBER_FIELDSR/RRR(R}RR$R%RR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR/s"        cCs9y|j|dSWntk r4|j||SXdS(s1Decode a single field from a pax record. R,N(R(tUnicodeDecodeError(R}RR$tfallback_encodingtfallback_errors((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/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(RMR(R}RRRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR. s cCs |jtkS(N(Rt REGULAR_TYPES(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR,scCs |jS(N(R,(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisfilescCs |jtkS(N(RR(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRscCs |jtkS(N(RtSYMTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytissymscCs |jtkS(N(RtLNKTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytislnkscCs |jtkS(N(RtCHRTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytischr scCs |jtkS(N(RtBLKTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisblk"scCs |jtkS(N(RtFIFOTYPE(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisfifo$scCs |jdk S(N(RRI(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytissparse&scCs|jtttfkS(N(RRTRVRX(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytisdev(s(R~RaRRRRRRRRRRRRRRRRRR(3RgRhRit __slots__RRRtpropertyRRRRRRtDEFAULT_FORMATtENCODINGRRRRt classmethodR Rt staticmethodRRRRR$R&R%R+R'R(R*R=R<R>R/R:R.R,RORRQRSRURWRYRZR[(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRs`         1  3?    f             c Bs-eZdZdZeZeZdZeZ e Z d1Z eZeZd1dd1d1d1d1d1d1dd1d1d1d Zed1dd1edZedd1dZedd1dd Zedd1dd Zid d 6d d6dd6ZdZdZdZdZd1d1d1dZedZ d1ed1d1dZ!d1dZ"dd1dZ#dedZ$dZ%edZ&dZ'd Z(d!Z)d"Z*d#Z+d$Z,d%Z-d&Z.d'Z/d(Z0d1ed)Z1d*Z2d1d+Z3d,Z4d-Z5d.Z6d/Z7d0Z8RS(2s=The TarFile Class provides an interface to tar archives. iiRYRc Cst|dks|dkr-tdn||_idd6dd6dd 6||_|s|jdkrtjj| rd |_d|_nt||j}t|_ nN|d krt |d r|j }nt |d r|j|_nt |_ |rtjj|nd |_ ||_|d k rC||_n|d k r[||_n|d k rs||_n|d k r||_n|d k r||_n| |_| d k r|jtkr| |_n i|_| d k r| |_n| d k r | |_nt|_g|_t|_|jj|_i|_y9|jdkrod |_ |j!|_ n|jdkrxt r|jj"|jy&|jj#|}|jj$|Wqt%k r|jj"|jPqt&k r } t't(| qXqWn|jd krzt |_|jrz|jj)|jj*}|jj+||jt|7_qznWn,|j s|jj,nt |_nXd S(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'trbRYsr+btatwbRZR~RatawN(-R R/Rat_modeRuRtexistst bltn_openRRRIRzR~RJtabspathRR>Rt dereferencet ignore_zerosR$R%RRtdebugt errorlevelRtmemberst_loadedRRtinodest firstmemberR0RR&R_RqRnRkRR RRLR(R}R~RaRR>RRjRkR$R%RRlRmteRE((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRFs  ""     !                             c Ks4| r| rtdn|dkrx|jD]}t||j|}|dk rj|j}ny||d||SWq3ttfk r} |dk r3|j|q3q3q3Xq3WtdnUd|krV|jdd\} }| pd} |pd}||jkr3t||j|}ntd|||| ||Sd |kr|jd d\} }| pd} |pd}| d krtd nt || |||} y||| | |} Wn| j nXt | _ | 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 openRYsr:*s%file could not be opened successfullyt:iRsunknown compression type %rt|trwsmode must be 'r' or 'w'Resundiscernible modeN(RYsr:*(R/t OPEN_METHRRIRRkRlRRERRRRttaropen( R R~RaRRtkwargsRtfunct saved_posRrRftstreamR[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR{sN              cKs@t|dks|dkr-tdn|||||S(sCOpen uncompressed tar archive name for reading or writing. iRsmode must be 'r', 'a' or 'w'(R R/(R R~RaRRx((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRwsi c Ks6t|dks|dkr-tdnyddl}|jWn#ttfk ritdnX|dk }y8|j||d||}|j||||}Wnxt k r| r|dk r|j n|dkrnt dn*| r"|dk r"|j nnX||_ |S( skOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. iRusmode must be 'r' or 'w'iNsgzip module is not availableRTsnot a gzip file( R R/tgziptGzipFileRtAttributeErrorRlRIRwRNRRkR( R R~RaRt compresslevelRxR|t extfileobjR[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytgzopens.        cKst|dks|dkr-tdnyddl}Wntk r\tdnX|dk r{t||}n|j||d|}y|j||||}Wn-t t fk r|j t dnXt |_|S( slOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. iRusmode must be 'r' or 'w'.iNsbz2 module is not availableRsnot a bzip2 file(R R/RRRlRIRtBZ2FileRwRNtEOFErrorRRkRR(R R~RaRRRxRR[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytbz2open$s     RwRRRRRcCs|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. NReii( RRaRRLR!RRRMt RECORDSIZERRRJ(R}RRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRHs   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 _getmemberRItKeyError(R}R~R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt getmember\s 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_checkRot_loadRn(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt getmembersgs   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(). (RR~(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytgetnamesqsc 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(RtprintRfRaRRRRRURWRRRRt localtimeRR~RRQRRS(R}tverboseR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRAs&   !)  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 rst |d }|j |||jn|jr|j ||rxTtj|D]@}|jtjj||tjj||||d |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. ReiNsuse the filter argument insteadistarfile: Excluded %rstarfile: Skipped %ristarfile: Unsupported type %rRbtfilter(RRItwarningstwarntDeprecationWarningt_dbgR~RuRRiRR,RhtaddfileRRtlistdirtaddR`( R}R~Rt recursivetexcludeRRRtf((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRsD        *        *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. ReiiN(RRRR>R$R%RRLRR RIRURRMRR!RnR_(R}RRRERRRS((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR4s    t.cCs:g}|dkr|}nx_|D]W}|jr\|j|tj|}d|_n|j||d|j q"W|jdd|jx|D]}tj j ||j }y4|j |||j |||j||Wqtk r1}|jdkrq2|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(). it set_attrstkeycSs|jS(N(R~(Rc((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pytdR]is tarfile: %sN(RIRR_RRatextracttsorttreverseRuRR`R~tchowntutimetchmodRjRmR(R}RRnt directoriesRtdirpathRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt extractallNs*      !  R]cCs=|jdt|tr.|j|}n|}|jr^tjj||j|_ ny,|j |tjj||j d|Wnt k r}|j dkrq9|jdkr|jdd|jq9|jdd|j|jfn<tk r8}|j dkr!q9|jdd|nXdS(sxExtract 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. RYRiis tarfile: %sstarfile: %s %rN(RRRRRSRuRR`RRt_extract_memberR~tEnvironmentErrorRmtfilenameRIRtstrerrorRj(R}tmemberRRRRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRts&  ! #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() RYs'cannot extract (sym)link as file objectN(RRRRR,t fileobjectRR-RSRQRRRmt extractfilet_find_link_targetRI(R}RR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRs  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|||r|j|||j s|j|||j||qndS(s\Extract the TarInfo object tarinfo to a physical file called targetpath. Ris%s -> %sN(RRRuRRtdirnameRgtmakedirsRSRQRR~RR,tmakefileRtmakedirRYtmakefifoRURWtmakedevtmakelinkRR-t makeunknownRRR(R}Rt targetpathRt upperdirs((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRs4#    cCsFytj|dWn+tk rA}|jtjkrBqBnXdS(s,Make a directory called targetpath. iN(RutmkdirRterrnotEEXIST(R}RRRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRs cCs|j}|j|jt|d}|jdk rqxJ|jD])\}}|j|t|||qAWnt|||j|j|j|j|j dS(s'Make a file called targetpath. RdN( RRRRhRRIRURttruncateR(R}RRtsourcettargetRR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/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((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s cCs/ttdrtj|n tddS(s'Make a fifo called targetpath. tmkfifosfifo not supported by systemN(RzRuRRj(R}RR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR scCsttd 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( RzRuRjRaRWRtS_IFBLKtS_IFCHRRRRR(R}RRRa((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s     cCsyj|jr%tj|j|nDtjj|jrPtj|j|n|j|j ||WnPt k r|jrtjj tjj |j |j}q|j}n>Xy|j|j ||Wntk 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. s%unable to resolve link inside archiveN(RQRutsymlinkRRRgRtlinkRRtsymlink_exceptionR`RR~RRj(R}RRR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR' s"       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(RRzRuRRtgetgrnamRRRtgetpwnamRRRQRtsystplatformRRRj(R}RRRtuRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRD s '    cCsOttdrKytj||jWqKtk rG}tdqKXndS(sASet file permissions of targetpath according to tarinfo. Rscould not change modeN(RzRuRRaRRj(R}RRRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRZ s cCsYttdsdSy tj||j|jfWntk rT}tdnXdS(sBSet modification time of targetpath according to tarinfo. RNs"could not change modification time(RzRuRRRRj(R}RRRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyRc s  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(RRqRIRRRRJRR&RqRkRRR0RkRRoRpRrRnR_Ro(R}tmRRr((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR0n 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(RRItindexRuRtnormpathtreversedR~(R}R~Rt normalizeRnRt member_name((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s    cCs6x&tr(|j}|dkrPqqWt|_dS(sWRead through the entire archive file and look for readable members. N(RJR0RIRo(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR 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(RRNRRgRIRa(R}Ra((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s cCs|jr5tjj|jd|j}d}n|j}|}|j|d|dt}|dkr~t d|n|S(sZFind the target member of a symlink or hardlink member in the archive. RRRslinkname %r not foundN( RQRuRRR~RRIRRJR(R}RRtlimitR((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s     cCs$|jrt|jSt|SdS(s$Provide an iterator object. N(RotiterRntTarIter(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s  cCs)||jkr%t|dtjndS(s.Write debugging output to sys.stderr. tfileN(RlRRtstderr(R}tleveltmsg((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR scCs|j|S(N(R(R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt __enter__ s cCs?|dkr|jn"|js2|jjnt|_dS(N(RIRRRRJR(R}RRt traceback((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__exit__ s    N(9RgRhRiRlRRjRkRmR^R>R_R$RIR%RRRRRR`RR{RwRRRvRRRRRRJRARRRRRRRRRRRRRRRR0RRRRRRRR(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR,sn  iK   b > &# & 0       1    RcBs/eZdZdZdZdZeZRS(sMIterator Class. for tarinfo in TarFile(...): suite... cCs||_d|_dS(s$Construct a TarIter object. iN(RR(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR s cCs|S(s Return iterator object. ((R}((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR scCs}|jjs9|jj}|sjt|j_tqjn1y|jj|j}Wntk ritnX|jd7_|S(sReturn the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. i(RRoR0RJt StopIterationRnRt IndexError(R}R((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyt__next__ s     (RgRhRiRRRR0(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/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(R{RRJRR(R~R[((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyR# s    (xt __future__Rt __version__tversiont __author__t__date__t __cvsid__t __credits__RRuRRRR8RR3RRRRIR~tNotImplementedErrorRt WindowsErrort NameErrort__all__t version_infot __builtin__tbuiltinsR{t_openR!RRRRRRR RRRRRPRTRVRRXtCONTTYPERRRRRR)RR7RR^R-RNRRItsetR;RR.RJtS_IFLNKtS_IFREGRtS_IFDIRRtS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECR~R_tgetfilesystemencodingR&R*R5R?RHRUR^Rft ExceptionRRjRkRlRmRnRoRpRqR0RrtobjectRsRRRRRRRRRRh(((sI/usr/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.pyts.                                                 ?K*