U &Ì.eéŸã@s dZdZdZddlmZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZz ddlZWnek rŒdZYnXz ddlZWnek r²dZYnXeefZzeef7ZWnek rÞYnXdddd d d d d dddddddgZdZdZdZdZedZdZdZdZ dZ!dZ"dZ#dZ$dZ%d Z&d!Z'd"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d)Z/d*Z0d+Z1dZ2d,Z3d-Z4e4Z5e#e$e%e&e)e*e+e'e(e,e-e.f Z6e#e$e+e.fZ7e,e-e.fZ8d.Z9d/d0d1d2hZ:e;e;e;ed4kràd5Z?ne @¡Z?d6d7„ZAd8d9„ZBd:d;„ZCd„ZDd?d@„ZEdedfdAdB„ZFdCdD„ZGGdEd „d eHƒZIGdFd „d eIƒZJGdGd „d eIƒZKGdHd „d eIƒZLGdId „d eIƒZMGdJd„deIƒZNGdKdL„dLeNƒZOGdMdN„dNeNƒZPGdOdP„dPeNƒZQGdQdR„dReNƒZRGdSdT„dTeNƒZSGdUdV„dVƒZTGdWdX„dXƒZUGdYdZ„dZeVƒZWGd[d\„d\eVƒZXGd]d^„d^ejYƒZZGd_d`„d`eIƒZ[Gdadb„dbe[ƒZ\Gdcdd„dde[ƒZ]Gdedf„dfe[ƒZ^Gdgdh„dhe[ƒZ_Gdidj„dje[ƒZ`dzdkdl„Zadmdn„Zbdodp„Zcdqdr„ZdebeceddsœZeeVƒZfGdtd„deVƒZgGdud„deVƒZhdvd„ZiehjZdwdx„ZjekdykrejƒdS){z0.9.0u"Lars Gustäbel (lars@gustaebel.de)u4Gustavo Niemeyer, Niels Gustäbel, Richard Townsend.é)ÚopenNÚTarFileÚTarInfoÚ is_tarfileÚTarErrorÚ ReadErrorÚCompressionErrorÚ StreamErrorÚ ExtractErrorÚ HeaderErrorÚENCODINGÚ USTAR_FORMATÚ GNU_FORMATÚ PAX_FORMATÚDEFAULT_FORMATrTz/etc/python/tarfile.cfgóiésustar sustar00édé›ó0ó1ó2ó3ó4ó5ó6ó7óLóKóSóxógóXéé)ÚpathÚlinkpathÚsizeÚmtimeÚuidÚgidÚunameÚgnamer%r&r+r,)ZatimeÚctimer(r)r*r'Úntúutf-8cCs8|dkrtdƒ‚| ||¡}|d|…|t|ƒtS)Nzmetadata cannot contain None)Ú ValueErrorÚencodeÚlenÚNUL)ÚsÚlengthÚencodingÚerrors©r8ú/usr/lib64/python3.8/tarfile.pyÚstn§s r:cCs*| d¡}|dkr|d|…}| ||¡S)Nréÿÿÿÿ)ÚfindÚdecode)r4r6r7Úpr8r8r9Únts¯s  r?cCs¦|ddkrbd}tt|ƒdƒD]}|dK}|||d7}q |ddkr¢dt|ƒd| }n@z"t|ddƒ}t| ¡p|d dƒ}Wntk r td ƒ‚YnX|S) Nr)é€éÿr#érAéÚasciiÚstrictÚ0úinvalid header)Úranger2r?ÚintÚstripr0ÚInvalidHeaderError)r4ÚnÚir8r8r9Únti·s   rNrBcCsØt|ƒ}d|kr$d|dkrDnntd|d|fdƒt}n|tkrÌd|d |krrd|dkrÌnnV|dkrŠtdgƒ}ntdgƒ}d||}t|dƒD]}| d|d@¡|dL}q¬ntd ƒ‚|S) NrrBr#z%0*orDrCr@rAzoverflow in number field)rIÚbytesr3rÚ bytearrayrHÚinsertr0)rLÚdigitsÚformatr4rMr8r8r9ÚitnËs  2    rTcCs0dtt d|¡ƒ}dtt d|¡ƒ}||fS)NrCZ 148B8x356BZ 148b8x356b)ÚsumÚstructZ unpack_from)ÚbufZunsigned_chksumZ signed_chksumr8r8r9Ú calc_chksumsès rXc Cs¦|pd}|dkrdS|dkr.t |||¡dSt||ƒ\}}t|ƒD],}| |¡}t|ƒ|krf|dƒ‚| |¡qD|dkr¢| |¡}t|ƒ|kr˜|dƒ‚| |¡dS)Ni@rúunexpected end of data)ÚshutilÚ copyfileobjÚdivmodrHÚreadr2Úwrite) ÚsrcZdstr5Ú exceptionÚbufsizeÚblocksÚ remainderÚbrWr8r8r9r[õs$       r[cCs8ttjddƒ}|dk r(| |d¡ |¡}t|dddS)Nr6Úbackslashreplaceú )Úend)ÚgetattrÚsysÚstdoutr1r=Úprint)r4r6r8r8r9Ú _safe_printsrlc@s eZdZdS)rN©Ú__name__Ú __module__Ú __qualname__r8r8r8r9rsc@s eZdZdS)r Nrmr8r8r8r9r sc@s eZdZdS)rNrmr8r8r8r9rsc@s eZdZdS)rNrmr8r8r8r9rsc@s eZdZdS)r Nrmr8r8r8r9r !sc@s eZdZdS)r Nrmr8r8r8r9r $sc@s eZdZdS)ÚEmptyHeaderErrorNrmr8r8r8r9rq'srqc@s eZdZdS)ÚTruncatedHeaderErrorNrmr8r8r8r9rr*srrc@s eZdZdS)ÚEOFHeaderErrorNrmr8r8r8r9rs-srsc@s eZdZdS)rKNrmr8r8r8r9rK0srKc@s eZdZdS)ÚSubsequentHeaderErrorNrmr8r8r8r9rt3srtc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú _LowLevelFilecCsFtjtjtjBtjBdœ|}ttdƒr2|tjO}t ||d¡|_dS)N©ÚrÚwÚO_BINARYi¶) ÚosÚO_RDONLYÚO_WRONLYÚO_CREATÚO_TRUNCÚhasattrryrÚfd)ÚselfÚnameÚmoder8r8r9Ú__init__@sþý  z_LowLevelFile.__init__cCst |j¡dS©N)rzÚcloser€©rr8r8r9r†Isz_LowLevelFile.closecCst |j|¡Sr…)rzr]r€©rr'r8r8r9r]Lsz_LowLevelFile.readcCst |j|¡dSr…)rzr^r€©rr4r8r8r9r^Osz_LowLevelFile.writeN)rnrorpr„r†r]r^r8r8r8r9ru:s ruc@sneZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z ddd„Z dd„Z dd„Z dd„ZdS)Ú_Streamc Csäd|_|dkrt||ƒ}d|_|dkr6t|ƒ}| ¡}|pd|fg}d|_g|_d}|j}|D]L\}}||kr||j  d||df¡|j  d||||f¡||7}||}qX||jkrÆ|j  d||jdf¡dS)Nrr‚FT) r™Úoffsetr'Úpositionrhr‚r›Ú map_indexÚmaprÂ)rr™rÌr'Z blockinfoZlastposZrealposr8r8r9r„hs(    z_FileInFile.__init__cCsdSr…r8r‡r8r8r9rµsz_FileInFile.flushcCsdS©NTr8r‡r8r8r9Úreadable„sz_FileInFile.readablecCsdS)NFr8r‡r8r8r9Úwritable‡sz_FileInFile.writablecCs |j ¡Sr…)r™Úseekabler‡r8r8r9rÓŠsz_FileInFile.seekablecCs|jSr…)rÍr‡r8r8r9r¾sz_FileInFile.tellcCs|tjkr tt|dƒ|jƒ|_nj|tjkr\|dkrFt|j|dƒ|_qŠt|j||jƒ|_n.|tjkr‚tt|j||jƒdƒ|_ntdƒ‚|jS)NrzInvalid argument) ÚioÚSEEK_SETÚminÚmaxr'rÍÚSEEK_CURÚSEEK_ENDr0)rrÍÚwhencer8r8r9r¿’s   z_FileInFile.seekc Cs |dkr|j|j}nt||j|jƒ}d}|dkr|j|j\}}}}||jkr`|krhqŽnqŽq6|jd7_|jt|jƒkr6d|_q6t|||jƒ}|râ|j ||j|¡|j |¡}t|ƒ|krØt dƒ‚||7}n |t |7}||8}|j|7_q,|S)Nrrr#rY) r'rÍrÖrÏrÎr2r™r¿r]rr3) rr'rWÚdataÚstartÚstoprÌr5rdr8r8r9r]¢s,     z_FileInFile.readcCs&| t|ƒ¡}||dt|ƒ…<t|ƒSr…)r]r2)rrdrWr8r8r9ÚreadintoÁsz_FileInFile.readintocCs d|_dSrÐ)r›r‡r8r8r9r†Æsz_FileInFile.close)N)N)rnrorpr„rµrÑrÒrÓr¾rÔrÕr¿r]rÞr†r8r8r8r9rËbs  rËcseZdZ‡fdd„Z‡ZS)Ú ExFileObjectcs&t|j|j|j|jƒ}tƒ |¡dSr…)rËr™Ú offset_datar'ÚsparseÚsuperr„)rÚtarfileÚtarinfor™©Ú __class__r8r9r„Ìs  ÿzExFileObject.__init__©rnrorpr„Ú __classcell__r8r8rår9rßÊsrßc@s eZdZdS)Ú FilterErrorNrmr8r8r8r9ré×srécseZdZ‡fdd„Z‡ZS)ÚAbsolutePathErrorcs ||_tƒ d|j›d¡dS)Nzmember z has an absolute path©rärâr„r‚©rrärår8r9r„ÛszAbsolutePathError.__init__rçr8r8rår9rêÚsrêcseZdZ‡fdd„Z‡ZS)ÚOutsideDestinationErrorcs.||_||_tƒ |j›d|›dd¡dS)Nz would be extracted to ú, ú which is outside the destination©räÚ_pathrâr„r‚©rrär%rår8r9r„às ÿz OutsideDestinationError.__init__rçr8r8rår9ríßsrícseZdZ‡fdd„Z‡ZS)ÚSpecialFileErrorcs||_tƒ |j›d¡dS)Nz is a special filerërìrår8r9r„çszSpecialFileError.__init__rçr8r8rår9róæsrócseZdZ‡fdd„Z‡ZS)ÚAbsoluteLinkErrorcs||_tƒ |j›d¡dS)Nz! is a symlink to an absolute pathrërìrår8r9r„ìszAbsoluteLinkError.__init__rçr8r8rår9rôësrôcseZdZ‡fdd„Z‡ZS)ÚLinkOutsideDestinationErrorcs.||_||_tƒ |j›d|›dd¡dS)Nz would link to rîrïrðròrår8r9r„ñs ÿz$LinkOutsideDestinationError.__init__rçr8r8rår9rõðsrõcCsäi}|j}tj |¡}| dtjf¡r@|j dtj¡}|d<tj |¡rTt|ƒ‚tj tj  ||¡¡}tj  ||g¡|krˆt ||ƒ‚|j }|dk rü|d@}|rê|  ¡s²| ¡rÌ|d@sÂ|dM}|dO}n| ¡sÜ| ¡râd}nt|ƒ‚||j krü||d<|rà|jdk rd|d<|jdk r*d|d <|jdk r>d|d <|jdk rRd|d <| ¡sf| ¡ràtj |j¡r~t|ƒ‚| ¡r¤tj  |tj |¡|j¡}ntj  ||j¡}tj |¡}tj  ||g¡|kràt||ƒ‚|S) Nú/r‚iíé@i¶ÿÿÿé€rƒr)r*r+r,)r‚rzr%ÚrealpathrÊÚsepÚlstripÚisabsrêrÃÚ commonpathrírƒÚisregÚislnkÚisdirÚissymrór)r*r+r,ÚlinknamerôÚdirnamerõ)ÚmemberÚ dest_pathZfor_dataÚ new_attrsr‚Z target_pathrƒr8r8r9Ú_get_filtered_attrs÷s^           þÿ  rcCs|Sr…r8)rrr8r8r9Úfully_trusted_filter6srcCs(t||dƒ}|r$|jf|ddi—ŽS|S)NFÚdeep©rr­©rrrr8r8r9Ú tar_filter9s r cCs(t||dƒ}|r$|jf|ddi—ŽS|S)NTr Fr r r8r8r9Ú data_filter?s r )Z fully_trustedr“rÛc@sÖeZdZeddddddddd d d d d ddddddddZdhdd„Zedd„ƒZejdd„ƒZedd„ƒZ e jdd„ƒZ dd„Z e e e e e e e e de d œ d!d"„Z d#d$„Z eed%fd&d'„Zd(d)„Zd*d+„Zd,d-„Zed.d/„ƒZd0d1„Zed2d3„ƒZed4d5„ƒZed6d7„ƒZed8d9„ƒZed:d;„ƒZedd?„Zd@dA„ZdBdC„Z dDdE„Z!dFdG„Z"dHdI„Z#dJdK„Z$dLdM„Z%dNdO„Z&dPdQ„Z'dRdS„Z(dTdU„Z)dVdW„Z*dXdY„Z+dZd[„Z,d\d]„Z-d^d_„Z.d`da„Z/dbdc„Z0ddde„Z1dfdg„Z2dS)irzName of the archive member.zPermission bits.z6User ID of the user who originally stored this member.z7Group ID of the user who originally stored this member.zSize in bytes.zTime of last modification.zHeader checksum.z–File type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.zcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.z User name.z Group name.zDevice major number.zDevice minor number.zThe tar header starts here.zThe file's data starts here.zMA dictionary containing key-value pairs of an associated pax extended header.zSparse member information.N)r‚rƒr)r*r'r(ÚchksumÚtyperr+r,ÚdevmajorÚdevminorrÌràÚ pax_headersrárãÚ_sparse_structsÚ _link_targetrŒcCsj||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_i|_dS)Ni¤rrŒ)r‚rƒr)r*r'r(rÚREGTYPErrr+r,rrrÌràrár©rr‚r8r8r9r„us"zTarInfo.__init__cCs|jSr…©r‚r‡r8r8r9r%sz TarInfo.pathcCs ||_dSr…rrr8r8r9r%’scCs|jSr…©rr‡r8r8r9r&–szTarInfo.linkpathcCs ||_dSr…r)rrr8r8r9r&›scCsd|jj|jt|ƒfS)Nz<%s %r at %#x>)rærnr‚Úidr‡r8r8r9Ú__repr__ŸszTarInfo.__repr__T) r‚r(rƒrr)r*r+r,r Ú_KEEPc CsŽ| rt |¡} n t |¡} || k r(|| _|| k r6|| _|| k rD|| _|| k rR|| _|| k r`|| _|| k rn|| _|| k r||| _|| k rŠ|| _ | Sr…) ÚcopyZdeepcopyr‚r(rƒrr)r*r+r,) rr‚r(rƒrr)r*r+r,r rÚresultr8r8r9r­¢s(  zTarInfo.replacecCs€|jdkrd}n |jd@}|j||j|j|j|j|j|j|j|j |j |j |j dœ }|dt kr||d d¡s||dd7<|S)Néÿ) r‚rƒr)r*r'r(rrrr+r,rrrr‚rö)rƒr‚r)r*r'r(rrrr+r,rrÚDIRTYPEr²)rrƒÚinfor8r8r9Úget_info¾s(  ózTarInfo.get_infoÚsurrogateescapecCsz| ¡}| ¡D]\}}|dkrtd|ƒ‚q|tkrD| |||¡S|tkrZ| |||¡S|tkrn| ||¡Stdƒ‚dS)Nz%s may not be Nonezinvalid format) r!Úitemsr0r Úcreate_ustar_headerrÚcreate_gnu_headerrÚcreate_pax_header)rrSr6r7r r‚Úvaluer8r8r9ÚtobufÚs z TarInfo.tobufcCsnt|d<t|d ||¡ƒtkr(tdƒ‚t|d ||¡ƒtkr^| |d||¡\|d<|d<| |t||¡S)NÚmagicrzlinkname is too longr‚Úprefix) Ú POSIX_MAGICr2r1Ú LENGTH_LINKr0Ú LENGTH_NAMEÚ_posix_split_nameÚ_create_headerr )rr r6r7r8r8r9r$ës zTarInfo.create_ustar_headercCs€t|d<d}t|d ||¡ƒtkr<|| |dt||¡7}t|d ||¡ƒtkrl|| |dt||¡7}|| |t ||¡S)Nr)rrr‚) Ú GNU_MAGICr2r1r,Ú_create_gnu_long_headerÚGNUTYPE_LONGLINKr-ÚGNUTYPE_LONGNAMEr/r)rr r6r7rWr8r8r9r%øszTarInfo.create_gnu_headerc Cs*t|d<|j ¡}ddtfddtfddfD]j\}}}||kr>q*z|| dd ¡Wn$tk rv||||<Yq*YnXt||ƒ|kr*||||<q*d D]`\}}||kr´d ||<qš||}d |krØd |d krænn t|t ƒršt |ƒ||<d ||<qš|r|  |t |¡} nd} | |  |tdd¡S)Nr)r‚r%rr&)r+r+é )r,r,r4rDrE))r)rB)r*rB)r'é )r(r5rrBr#rr­)r+rrr-r,r1ÚUnicodeEncodeErrorr2Ú isinstanceÚfloatÚstrÚ_create_pax_generic_headerÚXHDTYPEr/r ) rr r6rr‚Zhnamer5rRÚvalrWr8r8r9r&s8 þ   *  zTarInfo.create_pax_headercCs| |td¡S)Nr/)r:ÚXGLTYPE)Úclsrr8r8r9Úcreate_pax_global_header7sz TarInfo.create_pax_global_headercCs~| d¡}tdt|ƒƒD]T}d |d|…¡}d ||d…¡}t| ||¡ƒtkrt| ||¡ƒtkrqvqtdƒ‚||fS)Nrör#zname is too long)ÚsplitrHr2rÃr1Ú LENGTH_PREFIXr-r0)rr‚r6r7Z componentsrMr*r8r8r9r.=s ÿzTarInfo._posix_split_namec CsÆ| d¡ttfk}|r@t| dd¡d|ƒ}t| dd¡d|ƒ}ntdd||ƒ}tdd||ƒ}| dt¡}|dkrxtdƒ‚t| dd¡d ||ƒt| d d¡d @d|ƒt| d d¡d|ƒt| d d¡d|ƒt| dd¡d|ƒt| dd¡d|ƒd|t| dd¡d ||ƒ| dt¡t| dd¡d||ƒt| dd¡d||ƒt| dd¡d|ƒt| dd¡d|ƒt| dd¡d||ƒg}t  dt d  |¡¡} t | t d…ƒd} | dd…t d| dƒ| dd…} | S)NrrrrBrrŒzTarInfo.type must not be Noner‚rrƒrr)r*r'r5r(s rr)r+r4r,r*rz%dsri”þÿÿz%06orDi›þÿÿ)ÚgetÚCHRTYPEÚBLKTYPErTr:rr0r+rVr¯rÇrÃrXrO) r rSr6r7Zhas_device_fieldsrrZfiletypeÚpartsrWrr8r8r9r/Ms:  ñ&zTarInfo._create_headercCs.tt|ƒtƒ\}}|dkr*|t|t7}|S)Nr)r\r2rÇr3)Zpayloadrbrcr8r8r9Ú_create_payloadwszTarInfo._create_payloadcCsR| ||¡t}i}d|d<||d<t|ƒ|d<t|d<| |t||¡| |¡S)Nz ././@LongLinkr‚rr'r))r1r3r2r0r/r rF)r>r‚rr6r7r r8r8r9r1s ÿzTarInfo._create_gnu_long_headerc Cs2d}| ¡D]8\}}z| dd¡Wq tk rBd}YqFYq Xq d}|rV|d7}| ¡D]\}}| d¡}|r‚| |d¡}n | d¡}t|ƒt|ƒd}d } } |tt| ƒƒ} | | krÂqÈ| } q¨|tt| ƒd ƒd |d |d 7}q^i} d| d<|| d<t|ƒ| d<t| d<| | td d¡|  |¡S)NFr/rETrs21 hdrcharset=BINARY r"rÈrrDó ó=ó z././@PaxHeaderr‚rr'r)r­) r#r1r6r2r9rOr+r/r rF) r>rrr6ZbinaryÚkeywordr'ZrecordsÚlrLr>r r8r8r9r:’s<  ( ÿz"TarInfo._create_pax_generic_headerc Csvt|ƒdkrtdƒ‚t|ƒtkr(tdƒ‚| t¡tkr>tdƒ‚t|dd…ƒ}|t|ƒkrbt dƒ‚|ƒ}t |dd…||ƒ|_ t|dd …ƒ|_ t|d d …ƒ|_ t|d d …ƒ|_t|d d …ƒ|_t|d d…ƒ|_||_|dd …|_t |d d…||ƒ|_t |dd…||ƒ|_t |dd…||ƒ|_t|dd…ƒ|_t|dd…ƒ|_t |dd…||ƒ}|jtkr†|j  d¡r†t|_|jtkr8d}g}tdƒD]l} z0t|||d…ƒ} t||d|d…ƒ} Wntk rôYqYnX| | | f¡|d7}q¢t|dƒ} t|dd…ƒ} || | f|_ | !¡rP|j  "d¡|_ |rr|jt#krr|d|j |_ |S)Nrz empty headerztruncated headerzend of file headeré”éœz bad checksumrélété|éˆéii i)iIiQiYiôröi‚r¹r5éiâiãiï)$r2rqrÇrrÚcountr3rsrNrXrKr?r‚rƒr)r*r'r(rrrr+r,rrÚAREGTYPEr²rÚGNUTYPE_SPARSErHr0rÂÚboolrrÚrstripÚ GNU_TYPES)r>rWr6r7rÚobjr*ršÚstructsrMrÌÚnumbytesÚ isextendedÚorigsizer8r8r9ÚfrombufÅsZ         zTarInfo.frombufcCs8|j t¡}| ||j|j¡}|j ¡t|_| |¡Sr…) r™r]rÇr_r6r7r¾rÌÚ _proc_member)r>rãrWrZr8r8r9Ú fromtarfiles zTarInfo.fromtarfilecCsT|jttfkr| |¡S|jtkr,| |¡S|jtttfkrF|  |¡S|  |¡SdSr…) rr3r2Ú _proc_gnulongrVÚ _proc_sparser;r=ÚSOLARIS_XHDTYPEÚ _proc_paxÚ _proc_builtin)rrãr8r8r9r`s    zTarInfo._proc_membercCsR|j ¡|_|j}| ¡s$|jtkr4|| |j¡7}||_|  |j |j |j ¡|Sr…) r™r¾ràrþrÚSUPPORTED_TYPESÚ_blockr'rÌÚ_apply_pax_inforr6r7)rrãrÌr8r8r9rf&s zTarInfo._proc_builtincCs†|j | |j¡¡}z| |¡}Wntk r>tdƒ‚YnX|j|_|jt krft ||j |j ƒ|_ n|jtkr‚t ||j |j ƒ|_|S)Nú missing or bad subsequent header)r™r]rhr'rar rtrÌrr3r?r6r7r‚r2r)rrãrWÚnextr8r8r9rb7s  zTarInfo._proc_gnulongc CsÚ|j\}}}|`|rª|j t¡}d}tdƒD]n}z0t|||d…ƒ}t||d|d…ƒ} Wntk rzYqœYnX|r’| r’| || f¡|d7}q,t|dƒ}q||_ |j  ¡|_ |j |  |j ¡|_||_ |S)Nrér5rSiø)rr™r]rÇrHrNr0rÂrWrár¾ràrhr'rÌ) rrãr[r]r^rWršrMrÌr\r8r8r9rcMs(      zTarInfo._proc_sparsecCs.|j | |j¡¡}|jtkr&|j}n |j ¡}t  d|¡}|dk rX|  d¡  d¡|d<|  d¡}|dkrr|j }nd}t d¡}d}| ||¡}|s˜q6| ¡\} } t| ƒ} | dkr¼tdƒ‚|| d ¡d| d¡| d…} | | dd|j¡} | tkr| | ||j |j¡} n| | dd|j¡} | || <|| 7}q„z| |¡} Wntk rbtd ƒ‚YnXd |kr|| | |¡nHd |kr–| | ||¡n.|  d ¡dkrÄ|  d¡dkrÄ| | ||¡|jttfkr*|   ||j |j¡|j!| _!d|kr*| j"} |  #¡s| jt$kr$| |  | j¡7} | |_!| S)Ns\d+ hdrcharset=([^\n]+)\nr#r/Ú hdrcharsetZBINARYs(\d+) ([^=]+)=rrGr$rjúGNU.sparse.mapúGNU.sparse.sizezGNU.sparse.majorÚ1zGNU.sparse.minorrFr')%r™r]rhr'rr=rrÚreÚsearchÚgroupr=rBr6ÚcompileÚmatchÚgroupsrIrKrgrÜÚ_decode_pax_fieldr7ÚPAX_NAME_FIELDSrar rtÚ_proc_gnusparse_01Ú_proc_gnusparse_00Ú_proc_gnusparse_10r;rdrirÌràrþrg)rrãrWrrurmr6Zregexršr5rJr'rkrÌr8r8r9reish       $ ÿ  ÿ ÿ     zTarInfo._proc_paxcCshg}t d|¡D]}| t| d¡ƒ¡qg}t d|¡D]}| t| d¡ƒ¡q:tt||ƒƒ|_dS)Ns\d+ GNU.sparse.offset=(\d+)\nr#s\d+ GNU.sparse.numbytes=(\d+)\n)rqÚfinditerrÂrIrsÚlistÚziprá)rrkrrWZoffsetsrur\r8r8r9rzÑszTarInfo._proc_gnusparse_00cCs@dd„|d d¡Dƒ}tt|ddd…|ddd…ƒƒ|_dS)NcSsg|] }t|ƒ‘qSr8)rI)Ú.0Úxr8r8r9Ú ßsz.TarInfo._proc_gnusparse_01..rnú,r$r#)r@r}r~rá)rrkrrár8r8r9ryÜszTarInfo._proc_gnusparse_01cCs¨d}g}|j t¡}| dd¡\}}t|ƒ}t|ƒ|dkrtd|krT||j t¡7}| dd¡\}}| t|ƒ¡q,|j ¡|_t t |ddd…|ddd…ƒƒ|_ dS)NrIr#r$) r™r]rÇr@rIr2rÂr¾ràr}r~rá)rrkrrãZfieldsrárWZnumberr8r8r9r{âs  zTarInfo._proc_gnusparse_10c CsÂ| ¡D]ª\}}|dkr&t|d|ƒq|dkr@t|dt|ƒƒq|dkrZt|dt|ƒƒq|tkr|tkr”zt||ƒ}Wntk r’d}YnX|dkr¦| d¡}t|||ƒq| ¡|_dS)NzGNU.sparse.namer%ror'zGNU.sparse.realsizerrö) r#ÚsetattrrIÚ PAX_FIELDSÚPAX_NUMBER_FIELDSr0rXrr)rrr6r7rJr'r8r8r9riòs"  zTarInfo._apply_pax_infocCs4z| |d¡WStk r.| ||¡YSXdS)NrE)r=ÚUnicodeDecodeError)rr'r6Zfallback_encodingZfallback_errorsr8r8r9rw szTarInfo._decode_pax_fieldcCs"t|tƒ\}}|r|d7}|tS)Nr#)r\rÇ)rrTrbrcr8r8r9rhszTarInfo._blockcCs |jtkSr…)rÚ REGULAR_TYPESr‡r8r8r9rþsz TarInfo.isregcCs| ¡Sr…)rþr‡r8r8r9ÚisfileszTarInfo.isfilecCs |jtkSr…)rrr‡r8r8r9r"sz TarInfo.isdircCs |jtkSr…)rÚSYMTYPEr‡r8r8r9r&sz TarInfo.issymcCs |jtkSr…)rÚLNKTYPEr‡r8r8r9rÿ*sz TarInfo.islnkcCs |jtkSr…)rrCr‡r8r8r9Úischr.sz TarInfo.ischrcCs |jtkSr…)rrDr‡r8r8r9Úisblk2sz TarInfo.isblkcCs |jtkSr…)rÚFIFOTYPEr‡r8r8r9Úisfifo6szTarInfo.isfifocCs |jdk Sr…)rár‡r8r8r9Úissparse:szTarInfo.issparsecCs|jtttfkSr…)rrCrDrr‡r8r8r9Úisdev=sz TarInfo.isdev)rŒ)3rnrorpÚdictÚ __slots__r„Úpropertyr%Úsetterr&rrr­r!rr r(r$r%r&Ú classmethodr?r.Ú staticmethodr/rFr1r:r_rar`rfrbrcrerzryr{rirwrhrþrˆrrrÿr‹rŒrŽrrr8r8r8r9rRs¨è     ý  1  )   2 >  h  c @sàeZdZdZdZdZdZeZe Z dZ e Z eZdZdedd„Zedddefd d „ƒZedfd d „ƒZedgdd„ƒZedhdd„ƒZedidd„ƒZdddddœZdd„Zdd„Zdd„Zdd „Zdjd!d"„Zdkdd$œd%d&„Zdldd'œd(d)„Z dmd*d+„Z!d,d-„Z"dnddd/œd0d1„Z#doddd/œd3d4„Z$d5d6„Z%d7d8„Z&d9d:„Z'd;d<„Z(d=d>„Z)dpd?d@„Z*dAdB„Z+dCdD„Z,dEdF„Z-dGdH„Z.dIdJ„Z/dKdL„Z0dMdN„Z1dOdP„Z2dQdR„Z3dSdT„Z4dqdUdV„Z5dWdX„Z6drdYdZ„Z7d[d\„Z8d]d^„Z9d_d`„Z:dadb„Z;dcdd„Zr8r9Únot_compressed÷sz$TarFile.open..not_compressed)Úkeyrwz%file could not be opened successfullyú:r#r“r”ú|rvzmode must be 'r' or 'w'Frœzundiscernible mode) r0Úsortedr­rhr¾rrr¿r@rŠr†r•r¬) r>r‚rƒr™raÚkwargsr¯r˜ÚfuncZ saved_posÚfilemodeÚstreamrÆr8r®r9rÍsP%            z TarFile.opencKs |dkrtdƒ‚||||f|ŽS)Nr™r›)r0)r>r‚rƒr™r´r8r8r9r¬(szTarFile.taropenr©cKsè|dkrtdƒ‚zddlm}Wntk r<tdƒ‚YnXz|||d||ƒ}Wn.tk r‚|dk r||dkr|tdƒ‚‚YnXz|j|||f|Ž}WnBtk rÈ| ¡|dkrÂtdƒ‚‚Yn| ¡‚YnXd |_ |S) N©rwrxr€úmode must be 'r', 'w' or 'x'r)ÚGzipFilezgzip module is not availablerdrwr¶F) r0Zgziprºrrr¥rr¬r†r•)r>r‚rƒr™Ú compresslevelr´rºrÆr8r8r9Úgzopen0s0zTarFile.gzopenc Ks¸|dkrtdƒ‚zddlm}Wntk r<tdƒ‚YnX||pF|||d}z|j|||f|Ž}WnFttfk r˜| ¡|dkr’t dƒ‚‚Yn| ¡‚YnXd |_ |S) Nr¸r¹r)ÚBZ2Filer)r»rwznot a bzip2 fileF) r0rr½rrr¬r¥ÚEOFErrorr†rr•)r>r‚rƒr™r»r´r½rÆr8r8r9Úbz2openQs&zTarFile.bz2openc Ks¼|dkrtdƒ‚zddlm}m}Wntk r@tdƒ‚YnX||pJ|||d}z|j|||f|Ž}WnF|tfk rœ| ¡|dkr–t dƒ‚‚Yn| ¡‚YnXd |_ |S) Nr¸r¹r)ÚLZMAFiler§r’)Úpresetrwznot an lzma fileF) r0r¦rÀr§rrr¬r¾r†rr•) r>r‚rƒr™rÁr´rÀr§rÆr8r8r9Úxzopenms&zTarFile.xzopenr¬r¼r¿rÂ)r“rŽrr‘cCsˆ|jr dSd|_z`|jdkrn|j ttd¡|jtd7_t |jt ƒ\}}|dkrn|j tt |¡W5|js‚|j ¡XdS)NTrœr$r) r›r•r™r†rƒr^r3rÇrÌr\Ú RECORDSIZE)rrbrcr8r8r9r†”s z TarFile.closecCs"| |¡}|dkrtd|ƒ‚|S)Nzfilename %r not found)Ú _getmemberÚKeyError)rr‚rär8r8r9Ú getmember©s  zTarFile.getmembercCs| ¡|js| ¡|jSr…)Ú_checkr§Ú_loadr¦r‡r8r8r9Ú getmembers´szTarFile.getmemberscCsdd„| ¡DƒS)NcSsg|] }|j‘qSr8r)rrär8r8r9rÂsz$TarFile.getnames..)rÉr‡r8r8r9Úgetnames¾szTarFile.getnamesc Cs^| d¡|dk r|j}|dkr$|}tj |¡\}}| tjd¡}| d¡}| ¡}||_ |dkr€|j stt  |¡}qŽt  |¡}nt  | ¡¡}d}|j}t  |¡rþ|j|jf} |j sæ|jdkræ| |jkræ||j| kræt} |j| }nt} | drü||j| <nht  |¡rt} nVt  |¡r"t} nDt  |¡r>t} t |¡}n(t  |¡rPt} nt   |¡rbt!} ndS||_||_"|j#|_$|j%|_&| tkr–|j'|_(nd|_(|j)|_*| |_+||_,t-räzt- .|j$¡d|_/Wnt0k râYnXt1rzt1 2|j&¡d|_3Wnt0k rYnX| tt!fkrZt4tdƒrZt4tdƒrZt 5|j6¡|_7t 8|j6¡|_9|S)NÚawxrörŒr#rÚmajorÚminor):rÇr‚rzr%Ú splitdriver­rúrûrärãr¡ÚlstatÚstatÚfstatÚfilenoÚst_modeÚS_ISREGÚst_inoÚst_devÚst_nlinkr¨rŠrÚS_ISDIRrÚS_ISFIFOrÚS_ISLNKr‰ÚreadlinkÚS_ISCHRrCÚS_ISBLKrDrƒÚst_uidr)Úst_gidr*Úst_sizer'Úst_mtimer(rrÚpwdÚgetpwuidr+rÅÚgrpZgetgrgidr,rrÌÚst_rdevrrÍr) rr‚Úarcnamer™ZdrvräZstatresrZstmdÚinoderr8r8r9Ú gettarinfoÄs„      ÿ ÿ          zTarFile.gettarinfoT)r¦cCs*| ¡|dkr|}|D] }|rÎ|jdkr6tdƒntt |j¡ƒtd|jpT|j|jp^|jfƒ|  ¡sv|  ¡rtdd|j |j fƒntd|j ƒ|jdkr²tdƒntdt |j¡dd…ƒt|j| ¡ràd nd ƒ|r| ¡rtd |jƒ| ¡rtd |jƒtƒqdS) Nz ??????????z%s/%sz%10sz%d,%dz%10dz????-??-?? ??:??:??z%d-%02d-%02d %02d:%02d:%02dr¸rörŒz-> zlink to )rÇrƒrlrÐr¶r+r)r,r*r‹rŒrrr'r(r°Ú localtimer‚rrrrÿrk)rÚverboser¦rär8r8r9r}'s8    ÿÿ  ÿ  z TarFile.list©Úfilterc Cs6| d¡|dkr|}|jdk rFtj |¡|jkrF| dd|¡dS| d|¡| ||¡}|dkrz| dd|¡dS|dk r¦||ƒ}|dkr¦| dd|¡dS| ¡rÒt|dƒ}|  ||¡W5QRXn`|  ¡r(|  |¡|r2t t  |¡ƒD]*}|j tj ||¡tj ||¡||dqún |  |¡dS) NrËr$ztarfile: Skipped %rr#ztarfile: Unsupported type %rútarfile: Excluded %rr—rë)rÇr‚rzr%r Ú_dbgrèrþrŸÚaddfilerr³ÚlistdirÚaddrÃ)rr‚ræÚ recursiverìräÚfr8r8r9rñMs8      ÿ z TarFile.addcCs¾| d¡t |¡}| |j|j|j¡}|j |¡|jt |ƒ7_|j }|dk r®t ||j|j |dt |j tƒ\}}|dkrœ|j tt|¡|d7}|j|t7_|j |¡dS)NrË)rarr#)rÇrr(rSr6r7r™r^rÌr2r¥r[r'r\rÇr3r¦rÂ)rrär™rWrarbrcr8r8r9rï€s   zTarFile.addfilec CsB|dkrü|j}|dkrætj d¡}|dkrŒz ttƒ}Wntk rJYnBXddl}|jddd}||  |¡W5QRX|jdddd}|rÎz t |}Wn&t k rÂt d|›d ƒd‚YnX||_|St rât d t¡tStSt|tƒrøtd ƒ‚|St|ƒr |Sz t |WSt k r<t d|›d ƒd‚YnXdS) NZ PYTHON_TARFILE_EXTRACTION_FILTERr)ú#)Z interpolationZcomment_prefixesrãrŒ)Zfallbackzfilter z not foundaThe default behavior of tarfile extraction has been changed to disallow common exploits (including CVE-2007-4559). By default, absolute/parent paths are disallowed and some mode bits are cleared. See https://access.redhat.com/articles/7004769 for more details.zrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.)Úextraction_filterrzÚenvironrBrŸÚ_CONFIG_FILENAMEÚFileNotFoundErrorÚ configparserZ ConfigParserZ read_fileÚ_NAMED_FILTERSrÅr0Ú_RH_SAFER_DEFAULTÚwarningsÚwarnÚRuntimeWarningr rr7r9Ú TypeErrorÚcallable)rrìr‚ÚfilerùZconfr8r8r9Ú_get_filter_function™sZ  þþ ø  ÿ  zTarFile._get_filter_functionÚ.)Ú numeric_ownerrìc Csðg}| |¡}|dkr|}|D]F}| |||¡}|dkr:q| ¡rL| |¡|j||| ¡ |dq|jdd„dd|D]n}tj ||j ¡} z,|j || |d|  || ¡|  || ¡Wq|t k rè} z| | ¡W5d} ~ XYq|Xq|dS)N©Ú set_attrsrcSs|jSr…r)ršr8r8r9Úïrz$TarFile.extractall..T)r°Úreverse)r)rÚ_get_extract_tarinforrÂÚ _extract_oneÚsortrzr%rÃr‚ÚchownÚutimeÚchmodr Ú_handle_nonfatal_error) rr%r¦rrìZ directoriesÚfilter_functionrräÚdirpathrªr8r8r9Ú extractallÎs,  ÿ zTarFile.extractallrŒcCs4| |¡}| |||¡}|dk r0| ||||¡dSr…)rr r )rrr%rrrìrrär8r8r9Úextractûs zTarFile.extractc CsÎt|tƒr| |¡}n|}|}z|||ƒ}WnZttfk r\}z| |¡W5d}~XYn,tk r†}z| |¡W5d}~XYnX|dkr¦| dd|j ¡dS|  ¡rÊt   |¡}t j  ||j¡|_|S)Nr$rí)r7r9rÆr¥réÚ_handle_fatal_errorr rrîr‚rÿrrzr%rÃrr)rrrr%räZ unfilteredrªr8r8r9r  s"   zTarFile._get_extract_tarinfoc Csˆ| d¡z"|j|tj ||j¡||dWnVtk rX}z| |¡W5d}~XYn,tk r‚}z|  |¡W5d}~XYnXdS)Nrwr) rÇÚ_extract_memberrzr%rÃr‚r¥rr r)rrär%rrrªr8r8r9r % s þ zTarFile._extract_onecCs"|jdkr‚n| dd|¡dS)Nr#ú tarfile: %s)r¤rî©rrªr8r8r9r2 s zTarFile._handle_nonfatal_errorcCsn|jdkr‚n\t|tƒrP|jdkr6| dd|j¡qj| dd|j|jf¡n| ddt|ƒj|f¡dS)Nrr#rztarfile: %s %rztarfile: %s %s)r¤r7r¥ÚfilenamerîÚstrerrorrrnrr8r8r9r9 s   zTarFile._handle_fatal_errorcCs‚| d¡t|tƒr | |¡}n|}| ¡s6|jtkrB| ||¡S| ¡sR|  ¡rzt|j t ƒrht dƒ‚q~|  | |¡¡SndSdS)Nrwz'cannot extract (sym)link as file object)rÇr7r9rÆrþrrgÚ fileobjectrÿrr™rŠr Ú extractfileÚ_find_link_target)rrrär8r8r9rE s      zTarFile.extractfilecCsT| d¡}| dtj¡}tj |¡}|r>tj |¡s>t |¡| ¡sN|  ¡rh|  dd|j |j f¡n|  d|j ¡|  ¡rŒ| ||¡nŽ| ¡r¢| ||¡nx| ¡r¸| ||¡nb| ¡sÈ| ¡rÖ| ||¡nD| ¡sæ|  ¡rô| ||¡n&|jtkr| ||¡n | ||¡|rP| |||¡|  ¡sP| ||¡| ||¡dS)Nrör#z%s -> %s)rXr­rzrúr%rržÚmakedirsrÿrrîr‚rrþÚmakefilerÚmakedirrŽÚmakefifor‹rŒÚmakedevÚmakelinkrrgÚ makeunknownr rr )rräÚ targetpathrrZ upperdirsr8r8r9rd s4       zTarFile._extract_membercCs@z&|jdkrt |¡n t |d¡Wntk r:YnXdS)NiÀ)rƒrzÚmkdirÚFileExistsError©rrär$r8r8r9r• s   zTarFile.makedirc CsŽ|j}| |j¡|j}t|dƒb}|jdk rn|jD]"\}}| |¡t|||t|ƒq4| |j¡|  ¡nt|||jt|ƒW5QRXdS)Nr˜) r™r¿ràr¥rŸrár[rr'Útruncate)rrär$ÚsourceraÚtargetrÌr'r8r8r9r£ s      zTarFile.makefilecCs"| ||¡| dd|j¡dS)Nr#z9tarfile: Unknown file type %r, extracted as regular file.)rrîrr'r8r8r9r#³ s ÿzTarFile.makeunknowncCs"ttdƒrt |¡ntdƒ‚dS)NÚmkfifozfifo not supported by system)rrzr+r r'r8r8r9r » s  zTarFile.makefifocCsjttdƒrttdƒstdƒ‚|j}|dkr.d}| ¡rB|tjO}n |tjO}t ||t  |j |j ¡¡dS)NÚmknodr!z'special devices not supported by systemrø) rrzr rƒrŒrÐÚS_IFBLKÚS_IFCHRr,r!rr)rrär$rƒr8r8r9r!à s  ÿzTarFile.makedevc Cs°zb| ¡r0tj |¡r t |¡t |j|¡n0tj |j¡rNt  |j|¡n|  |  |¡|¡WnHt k rªz|  |  |¡|¡Wnt k r¤tdƒ‚YnXYnXdS)Nz%unable to resolve link inside archive)rrzr%ÚlexistsÚunlinkÚsymlinkrržrÚlinkrrÚsymlink_exceptionrÅr r'r8r8r9r"Õ s"   ÿ ÿzTarFile.makelinkcCsüttdƒrøt ¡dkrø|j}|j}|sŽztrB|jrBt |j¡d}Wntk rXYnXzt rv|j rvt   |j ¡d}Wntk rŒYnX|dkršd}|dkr¦d}z4|  ¡rÊttdƒrÊt  |||¡nt |||¡Wntk rötdƒ‚YnXdS)NÚgeteuidrr$r;Úlchownzcould not change owner)rrzr4r*r)rär,ZgetgrnamrÅrâr+Úgetpwnamrr5r r¥r )rrär$rÚgÚur8r8r9r î s0  z TarFile.chowncCsB|jdkrdSzt ||j¡Wntk r<tdƒ‚YnXdS)Nzcould not change mode)rƒrzrr¥r r'r8r8r9r s  z TarFile.chmodcCsV|j}|dkrdSttdƒs dSzt |||f¡Wntk rPtdƒ‚YnXdS)Nr z"could not change modification time)r(rrzr r¥r )rrär$r(r8r8r9r  s z TarFile.utimec Csð| d¡|jdk r$|j}d|_|S|j|j ¡krZ|j |jd¡|j d¡sZtdƒ‚d}z|j  |¡}WqÎt k rÆ}z6|j r´|  dd|j|f¡|jt 7_WY¢q^W5d}~XYqÎtk r6}zR|j r|  dd|j|f¡|jt 7_WY¢ q^n|jdkr&tt|ƒƒ‚W5d}~XYn’tk r^|jdkrZtdƒ‚Ynjtk r˜}z|jdkrˆtt|ƒƒ‚W5d}~XYn0tk rÆ}ztt|ƒƒ‚W5d}~XYnXqÎq^|dk ræ|j |¡nd|_|S) NZrar#rYr$z0x%X: %srz empty fileT)rÇr©rÌr™r¾r¿r]rrärarsr¢rîrÇrKr9rqrrrtr¦rÂr§)rÚmrärªr8r8r9rk' sJ         z TarFile.nextc Cs¶| ¡}d}|dk rHz| |¡}Wntk r:d}YnX|d|…}|rXtj |¡}t|ƒD]D}|rz|j|jkr`d}q`|rŽtj |j¡}n|j}||kr`|Sq`|r²t|ƒ‚dS)NFT) rÉÚindexr0rzr%ÚnormpathÚreversedrÌr‚) rr‚räÚ normalizer¦Zskippingr:rÚ member_namer8r8r9rÄ] s,      zTarFile._getmembercCs| ¡}|dkrqqd|_dSrÐ)rkr§rìr8r8r9rÈ… sz TarFile._loadcCs:|jrtd|jjƒ‚|dk r6|j|kr6td|jƒ‚dS)Nz %s is closedzbad operation for mode %r)r›r¥rærnrƒ)rrƒr8r8r9rÇ szTarFile._checkcCs`| ¡r.d tdtj |j¡|jfƒ¡}d}n |j}|}|j||dd}|dkr\t d|ƒ‚|S)NröT)rär=zlinkname %r not found) rrÃrìrzr%rr‚rrÄrÅ)rrärÚlimitrr8r8r9r˜ s  zTarFile._find_link_targetccsŠ|jr|jEdHdSd}|jdk r:| ¡}|d7}|V|t|jƒkrT|j|}n"|jsr| ¡}|svd|_dSndS|d7}|Vq:dS)Nrr#T)r§r¦r©rkr2)rr:rär8r8r9Ú__iter__« s$   zTarFile.__iter__cCs||jkrt|tjddS)N©r)r£rkriÚstderr)rÚlevelÚmsgr8r8r9rîÊ s z TarFile._dbgcCs | ¡|Sr…)rÇr‡r8r8r9Ú __enter__Ð szTarFile.__enter__cCs,|dkr| ¡n|js"|j ¡d|_dSrÐ)r†r•r™r›)rrr'Ú tracebackr8r8r9Ú__exit__Ô s   zTarFile.__exit__) NrwNNNNNNr"NNNN)rwN)rwNr©)rwNr©)rwNN)NNN)T)NT)N)rN)rŒT)TF)NF)N)=rnrorpr£r¡r¢r¤rrSr r6r7rrärßrrõr„r•rÃrr¬r¼r¿rÂr­r†rÆrÉrÊrèr}rñrïrrrr r rrrrrrr#r r!r"r rr rkrÄrÈrÇrr@rîrErGr8r8r8r9rBsšý oZ    ü    c&3 5ÿ -ÿ   ÿ 1! 6 ( cCs2zt|ƒ}| ¡WdStk r,YdSXdS)NTF)rr†r)r‚rÆr8r8r9râ s c Csddl}d}|j|d}|jdddddd |jd d td d |jdd}|jddddd|jdddddd|jdddddd|jdd dd!d| ¡}|jrº|jdkrº| d"d#¡|j dk r4|j }t |ƒrt |d$ƒ }|  ¡t |  ¡tjd%W5QRX|jr0t d& |¡ƒn| d"d' |¡¡nÐ|jdk rŽ|j}t |ƒrxt  |d(¡}|j|jd)W5QRXn| d"d' |¡¡nv|jdk rbt|jƒd"kr¼|jd}tj}n,t|jƒd*krØ|j\}}n| d"| ¡¡t |ƒrNt  |d(¡}|j||jd+W5QRX|jr`|d,kr8d- |¡} n d. ||¡} t | ƒn| d"d' |¡¡n¢|jdk r|j d¡} tj | ¡\} } d/d/d0d0d1d1d1d1d2œ} | | kr¶d3| | nd4}|j}t  | |¡}|D]}| |¡qÒW5QRX|jrt d5 | ¡ƒdS)6Nrz3A simple command-line interface for tarfile module.)Ú descriptionz-vz --verboseÚ store_trueFzVerbose output)ÚactionÚdefaultÚhelpz--filterz zFilter for extraction)ÚmetavarÚchoicesrLT)Zrequiredz-lz--listú zShow listing of a tarfile)rMrLz-ez --extractú+)rOz zExtract tarfile into target dir)ÚnargsrMrLz-cz--create)zzzCreate tarfile from sourcesz-tz--testzTest if a tarfile is validr#z&--filter is only valid for extraction rwrAz{!r} is a tar archive.z{!r} is not a tar archive. r«)rêr$)r%rìrz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.rŽr‘r)r«z.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:rxz{!r} file created.)ÚargparseÚArgumentParserÚ add_argumentrúZadd_mutually_exclusive_groupÚ parse_argsrìrÚexitZtestrrrÉrkrirBrêrSr}rr2rzÚcurdirZ format_helprZcreateÚpopr%Úsplitextrñ)rRrHÚparserrsÚargsr_r“ZtfrWrDZtar_nameÚ_ZextZ compressionsZtar_modeZ tar_filesÚ file_namer8r8r9Úmainð s¢  ÿþ  ÿ þ þ ÿ            ÿ   õ r^Ú__main__)T)lÚversionÚ __author__Ú __credits__ÚbuiltinsrrŸrirzrÔrZrÐr°rVrrqrürârräÚAttributeErrorÚNotImplementedErrorr3r¥Ú NameErrorÚ__all__rûr÷r3rÇrÃr0r+r-r,rArrUrŠr‰rCrDrrZCONTTYPEr3r2rVr;r=rdr rrrrgr‡rYr„rxr8rIr…r‚r Úgetfilesystemencodingr:r?rNrTrXr[rlÚ Exceptionrr rrr r rqrrrsrKrtrurŠÚobjectr–rËÚBufferedReaderrßrérêrírórôrõrrr r rúrrrrr^rnr8r8r8r9Ú s:      ýüÿÿ ú  sh  ?ý u) _