\e[c @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_tarfiletTarErroriitiisustar tustar00idit0t1t2t3t4t5t6t7tLtKtStxtgtXiitpathtlinkpathtsizetmtimetuidtgidtunametgnametatimetctimeiii`i@i iiiiii@i iiitnttcesutf-8cCs,|j||}|| |t|tS(s8Convert a string to a null-terminated bytes object. (tencodetlentNUL(tstlengthtencodingterrors((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytstnscCs8|jd}|dkr(|| }n|j||S(s8Convert a null-terminated bytes object to a string. Ri(tfindtdecode(R$R&R'tp((sD/tmp/pip-install-0xiv62/pip/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((sD/tmp/pip-install-0xiv62/pip/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 fieldRtlii( R!R#t GNU_FORMATR1tstructtunpacktpackt bytearrayR3tinsert(R5tdigitstformatR$R6((sD/tmp/pip-install-0xiv62/pip/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(tsumR:R;(tbuftunsigned_chksumt signed_chksum((sD/tmp/pip-install-0xiv62/pip/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@(tNonetTruetreadtwritetdivmodR3R"tIOError(tsrctdstR%RGtBUFSIZEtblockst remaindertb((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt copyfileobjs,    R8t-RVtdtcR+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() RXt(tfilemode_tabletappendtjoin(tmodetpermttabletbittchar((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytfilemode8s  cBseZdZRS(sBase exception.(t__name__t __module__t__doc__(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRGst ExtractErrorcBseZdZRS(s%General exception for extract errors.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRlJst ReadErrorcBseZdZRS(s&Exception for unreadable tar archives.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRmMstCompressionErrorcBseZdZRS(s.Exception for unavailable compression methods.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRnPst StreamErrorcBseZdZRS(s=Exception for unsupported operations on stream-like TarFiles.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRoSst HeaderErrorcBseZdZRS(s!Base exception for header errors.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRpVstEmptyHeaderErrorcBseZdZRS(sException for empty headers.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRqYstTruncatedHeaderErrorcBseZdZRS(s Exception for truncated headers.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRr\stEOFHeaderErrorcBseZdZRS(s"Exception for end of file headers.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRs_sR2cBseZdZRS(sException for invalid headers.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR2bstSubsequentHeaderErrorcBseZdZRS(s3Exception for missing and invalid extended headers.(RiRjRk(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRtest _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(NR[R\tO_BINARYi( tostO_RDONLYtO_WRONLYtO_CREATtO_TRUNCthasattrRvtopentfd(tselftnameRc((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt__init__rs cCstj|jdS(N(RwtcloseR~(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR{scCstj|j|S(N(RwRMR~(RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRM~scCstj|j|dS(N(RwRNR~(RR$((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRNs(RiRjRkRRRMRN(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRuls   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 availableR[tbz2sbz2 module is not available(RLt _extfileobjRKRutFalset _StreamProxyt getcomptypeRRctcomptypetfileobjtbufsizeRGtpostclosedtzlibt ImportErrorRntcrc32tcrct _init_read_gzt_init_write_gzRtdbuftBZ2Decompressortcmpt BZ2CompressorR(RRRcRRRRR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRsP                        cCs*t|dr&|j r&|jndS(NR(R|RR(R((sD/tmp/pip-install-0xiv62/pip/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. RRcRRRRtchksumttypetlinknameRRtdevmajortdevminorRRt 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(RRcRRRRRtREGTYPERRRRRRRRRKRR(RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRs"                cCs|jS(N(R(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt_getpathscCs ||_dS(N(R(RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt_setpathscCs|jS(N(R(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt _getlinkpathscCs ||_dS(N(R(RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt _setlinkpathscCs d|jj|jt|fS(Ns<%s %r at %#x>(t __class__RiRtid(R((sD/tmp/pip-install-0xiv62/pip/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|dcd7ny||jd d Wn"tk r||||nXt|||kr>||||q>WxddddfD]\}}||krd|||j|S|jtttfkrc|j |S|j |SdS(sYChoose the right processing method depending on the type and call it. N( RRRt _proc_gnulongRt _proc_sparseRR tSOLARIS_XHDTYPEt _proc_paxt _proc_builtin(RR((sD/tmp/pip-install-0xiv62/pip/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'(RRR((sD/tmp/pip-install-0xiv62/pip/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(RRMR0RR(RpRtRRRR,R&R'RRR(RRRGtnext((sD/tmp/pip-install-0xiv62/pip/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(RRRMRR3R7R1RaRRRRR0RR( RRR"R$R%RGRR6RR#((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR*Ks(     cCs|jj|j|j}|jtkr9|j}n|jj}tj d|}|dk r|j dj d|ds,cCsd}g}|jjt}|jdd\}}t|}xjt||dkrd|kr||jjt7}n|jdd\}}|jt|qEW|jj|_ t t |ddd|ddd|_ dS(s?Process a GNU tar extended sparse header, version 1.0. s iiN( RKRRMRRGR0R"RaRRRCRDR(RR2RRtfieldsRRGtnumber((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR@s  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( RtsetattrR0t PAX_FIELDStPAX_NUMBER_FIELDSR1RRR(RRR&R'RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR1s"        cCs9y|j|dSWntk r4|j||SXdS(s1Decode a single field from a pax record. R.N(R*tUnicodeDecodeError(RRR&tfallback_encodingtfallback_errors((sD/tmp/pip-install-0xiv62/pip/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(ROR(RRRTRU((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR0 s cCs |jtkS(N(Rt REGULAR_TYPES(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR.scCs |jS(N(R.(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytisfilescCs |jtkS(N(RR(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRscCs |jtkS(N(RtSYMTYPE(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytissymscCs |jtkS(N(RtLNKTYPE(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytislnkscCs |jtkS(N(RtCHRTYPE(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytischr scCs |jtkS(N(RtBLKTYPE(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytisblk"scCs |jtkS(N(RtFIFOTYPE(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytisfifo$scCs |jdk S(N(RRK(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytissparse&scCs|jtttfkS(N(RRVRXRZ(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytisdev(s(snamesmodesuidsgidssizesmtimeschksumstypeslinknamesunamesgnamesdevmajorsdevminorsoffsets offset_datas pax_headersssparsestarfiles_sparse_structss _link_target(3RiRjRkt __slots__RRRtpropertyRRRRRRtDEFAULT_FORMATtENCODINGRRRRt classmethodR Rt staticmethodRRRRR&R(R'R-R)R*R,R?R>R@R1R<R0R.RQRRSRURWRYR[R\R](((sD/tmp/pip-install-0xiv62/pip/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. iiR[Rc 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'trbR[sr+btatwbR\RRctawN(-R"R1Rct_modeRwRtexistst bltn_openRRRKR|RRLtabspathRR@Rt dereferencet ignore_zerosR&R'RRtdebugt errorlevelRtmemberst_loadedRRtinodest firstmemberR2RR(RaRsRpRmRR RRNR(RRRcRR@RRlRmR&R'RRnRoteRG((sD/tmp/pip-install-0xiv62/pip/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 openR[sr:*s%file could not be opened successfullyt:iRsunknown compression type %rt|trwsmode must be 'r' or 'w'Rgsundiscernible modeN(R[sr:*(R1t OPEN_METHRRKRRmRnRRGRRRRttaropen( R RRcRRtkwargsRtfunct saved_posRtRhtstreamR]((sD/tmp/pip-install-0xiv62/pip/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"R1(R RRcRRz((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRysi 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. iRwsmode must be 'r' or 'w'iNsgzip module is not availableRVsnot a gzip file( R"R1tgziptGzipFileRtAttributeErrorRnRKRyRPRRmR( R RRcRt compresslevelRzR~t extfileobjR]((sD/tmp/pip-install-0xiv62/pip/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. iRwsmode must be 'r' or 'w'.iNsbz2 module is not availableRsnot a bzip2 file(R"R1RRRnRKRtBZ2FileRyRPtEOFErrorRRmRR(R RRcRRRzRR]((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytbz2open$s     RyRRRRRcCs|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. NRgii( RRcRRNR#RRROt RECORDSIZERRRL(RRTRU((sD/tmp/pip-install-0xiv62/pip/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 _getmemberRKtKeyError(RRR((sD/tmp/pip-install-0xiv62/pip/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_checkRqt_loadRp(R((sD/tmp/pip-install-0xiv62/pip/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(RR((sD/tmp/pip-install-0xiv62/pip/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(RtprintRhRcRRRRRWRYRRRRt localtimeRRRRSRRU(RtverboseR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRCs&   !)  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. RgiNsuse the filter argument insteadistarfile: Excluded %rstarfile: Skipped %ristarfile: Unsupported type %rRdtfilter(RRKtwarningstwarntDeprecationWarningt_dbgRRwRRkRR.RjtaddfileRRtlistdirtaddRb( RRRt recursivetexcludeRRRtf((sD/tmp/pip-install-0xiv62/pip/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. RgiiN(RRRR@R&R'RRNRR"RKRWRRORR#RpRa(RRRRGRTRU((sD/tmp/pip-install-0xiv62/pip/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(Re((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pytdsis tarfile: %sN(RKRRaRRctextracttsorttreverseRwRRbRtchowntutimetchmodRlRoR(RRRpt directoriesRtdirpathRt((sD/tmp/pip-install-0xiv62/pip/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. R[Riis tarfile: %sstarfile: %s %rN(RRRRRURwRRbRRt_extract_memberRtEnvironmentErrorRotfilenameRKRtstrerrorRl(RtmemberRRRRt((sD/tmp/pip-install-0xiv62/pip/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() R[s'cannot extract (sym)link as file objectN(RRRRR.t fileobjectRR/RURSRRRot extractfilet_find_link_targetRK(RRR((sD/tmp/pip-install-0xiv62/pip/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(RRRwRRtdirnameRitmakedirsRURSRRRR.tmakefileRtmakedirR[tmakefifoRWRYtmakedevtmakelinkRR/t makeunknownRRR(RRt targetpathRt upperdirs((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRs4#    cCsFytj|dWn+tk rA}|jtjkrBqBnXdS(s,Make a directory called targetpath. iN(RwtmkdirRterrnotEEXIST(RRRRt((sD/tmp/pip-install-0xiv62/pip/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. RfN( RRRRjRRKRWRttruncateR(RRRtsourcettargetRR((sD/tmp/pip-install-0xiv62/pip/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(RRR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR s cCs/ttdrtj|n tddS(s'Make a fifo called targetpath. tmkfifosfifo not supported by systemN(R|RwRRl(RRR((sD/tmp/pip-install-0xiv62/pip/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( R|RwRlRcRYRtS_IFBLKtS_IFCHRRRRR(RRRRc((sD/tmp/pip-install-0xiv62/pip/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(RSRwtsymlinkRRRiRtlinkRRtsymlink_exceptionRbRRRRl(RRRR((sD/tmp/pip-install-0xiv62/pip/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(RR|RwRRtgetgrnamRRRtgetpwnamRRRSRtsystplatformRRRl(RRRRtuRt((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyRD s '    cCsOttdrKytj||jWqKtk rG}tdqKXndS(sASet file permissions of targetpath according to tarinfo. Rscould not change modeN(R|RwRRcRRl(RRRRt((sD/tmp/pip-install-0xiv62/pip/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(R|RwRRRRl(RRRRt((sD/tmp/pip-install-0xiv62/pip/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(RRsRKRRRRLRR(RsRmRRR2RmRRqRrRtRpRaRq(RtmRRt((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR2n 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(RRKtindexRwRtnormpathtreversedR(RRRt normalizeRpRt member_name((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR s    cCs6x&tr(|j}|dkrPqqWt|_dS(sWRead through the entire archive file and look for readable members. N(RLR2RKRq(RR((sD/tmp/pip-install-0xiv62/pip/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(RRPRRiRKRc(RRc((sD/tmp/pip-install-0xiv62/pip/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( RSRwRRRRRKRRLR(RRRtlimitR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR s     cCs$|jrt|jSt|SdS(s$Provide an iterator object. N(RqtiterRptTarIter(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR s  cCs)||jkr%t|dtjndS(s.Write debugging output to sys.stderr. tfileN(RnRRtstderr(Rtleveltmsg((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR scCs|j|S(N(R(R((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt __enter__ s cCs?|dkr|jn"|js2|jjnt|_dS(N(RKRRRRLR(RRRt traceback((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt__exit__ s    N(9RiRjRkRnRRlRmRoR`R@RaR&RKR'RRRRRRbRR}RyRRRxRRRRRRLRCRRRRRRRRRRRRRRRR2RRRRRRRR(((sD/tmp/pip-install-0xiv62/pip/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(RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR s cCs|S(s Return iterator object. ((R((sD/tmp/pip-install-0xiv62/pip/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(RRqR2RLt StopIterationRpRt IndexError(RR((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyt__next__ s     (RiRjRkRRRR2(((sD/tmp/pip-install-0xiv62/pip/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}RRLRR(RR]((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyR# s    (xt __future__Rt __version__tversiont __author__t__date__t __cvsid__t __credits__RRwRRRR:RR5RRRRKRtNotImplementedErrorRt WindowsErrort NameErrort__all__t version_infot __builtin__tbuiltinsR}t_openR#RRRRRRR RRRTRRRVRXRRZtCONTTYPERRRRR R+RR9RR`R/RPR RKtsetR=RR0RLtS_IFLNKtS_IFREGRtS_IFDIRRtS_IFIFOtTSUIDtTSGIDtTSVTXtTUREADtTUWRITEtTUEXECtTGREADtTGWRITEtTGEXECtTOREADtTOWRITEtTOEXECRRatgetfilesystemencodingR(R,R7RARJRWR`Rht ExceptionRRlRmRnRoRpRqRrRsR2RttobjectRuRRRRRRRRRRj(((sD/tmp/pip-install-0xiv62/pip/pip/_vendor/distlib/_backport/tarfile.pyts.                                                 ?K*