o 0¦iv´ã @sdZdZdZdZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZzddlZWn eyGdZYnwzddlZWn eyYdZYnweefZzeef7ZWn eynYnwgd¢ZdZd Zed Zd Zd Zd Zd Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3e3Z4e"e#e$e%e(e)e*e&e'e+e,e-f Z5e"e#e*e-fZ6e+e,e-fZ7dZ8hd £Z9e:e:e:e;e;e;d!œZne ?¡Z>d$d%„Z@d&d'„ZAd(d)„ZBd*e4fd+d,„ZCd-d.„ZDdedfd/d0„ZEd1d2„ZFGd3d4„d4eGƒZHGd5d6„d6eHƒZIGd7d8„d8eHƒZJGd9d:„d:eHƒZKGd;d<„d„d>eHƒZMGd?d@„d@eMƒZNGdAdB„dBeMƒZOGdCdD„dDeMƒZPGdEdF„dFeMƒZQGdGdH„dHeMƒZRGdIdJ„dJƒZSGdKdL„dLƒZTGdMdN„dNeUƒZVGdOdP„dPeUƒZWGdQdR„dRe jXƒZYGdSdT„dTeHƒZZGdUdV„dVeZƒZ[GdWdX„dXeZƒZ\GdYdZ„dZeZƒZ]Gd[d\„d\eZƒZ^Gd]d^„d^eZƒZ_Gd_d`„d`eZƒZ`eZeeIfZadudbdc„Zbddde„Zcdfdg„Zddhdi„ZeecedeedjœZfeUƒZge hdk¡ZiGdldm„dmeUƒZjGdndo„doeUƒZkdpdq„ZlekjZdrds„Zmendtk�remƒdSdS)vz,Read from and write to tar format archives. 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_FORMATró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Úgname>r+r&r%r,)ZatimeÚctimer(r)r*r'Úntúutf-8cCs8|durtdƒ‚| ||¡}|d|…|t|ƒtS)z8Convert a string to a null-terminated bytes object. Nzmetadata cannot contain None)Ú ValueErrorÚencodeÚlenÚNUL)ÚsÚlengthÚencodingÚerrors©r8ú./opt/alt/python310/lib64/python3.10/tarfile.pyÚstn s r:cCs*| d¡}|dkr|d|…}| ||¡S)z8Convert a null-terminated bytes object to a string. réÿÿÿÿN)ÚfindÚdecode)r4r6r7Úpr8r8r9Únts¨s   r?cCs |ddvr2d}tt|ƒdƒD]}|dK}|||d7}q|ddkr0dt|ƒd| }|Szt|ddƒ}t| ¡p?d dƒ}W|StyOtd ƒ‚w) z/Convert a number field to a python number. r)é€éÿr#érAéÚasciiÚstrictÚ0úinvalid header)Úranger2r?ÚintÚstripr0ÚInvalidHeaderError)r4ÚnÚir8r8r9Únti°s  û  þÿrNrBcCsâ|}t|ƒ}d|krd|dkr%nntd|d|fdƒt}|S|tkrmd|d |krs  rœc@sjeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z e j fdd„Z ddd„Z dd„Zdd„ZdS)Ú _FileInFilezA thin wrapper around an existing file object that provides a part of its data as an individual file object. NcCsÎ||_||_||_d|_t|ddƒ|_d|_|durd|fg}d|_g|_d}|j}|D]&\}}||kr>|j  d||df¡|j  d||||f¡||7}||}q,||jkre|j  d||jdf¡dSdS)Nrr†FT) rŸÚoffsetr'Úpositionrhr†r¡Ú map_indexÚmaprÊ)r…rŸrÔr'Z blockinfoZlastposZrealposr8r8r9rˆbs*    ÿz_FileInFile.__init__cCsdSr‰r8r‹r8r8r9r»{óz_FileInFile.flushcCódS©NTr8r‹r8r8r9Úreadable~rØz_FileInFile.readablecCrÙ©NFr8r‹r8r8r9Úwritable�rØz_FileInFile.writablecCs |j ¡Sr‰)rŸÚseekabler‹r8r8r9rÞ„ó z_FileInFile.seekablecCrÄ)z*Return the current file position. )rÕr‹r8r8r9rŇrÆz_FileInFile.tellcCsš|tjkrtt|dƒ|jƒ|_|jS|tjkr4|dkr't|j|dƒ|_|jSt|j||jƒ|_|jS|tjkrItt|j||jƒdƒ|_|jStdƒ‚)z(Seek to a position in the file. rzInvalid argument) ÚioÚSEEK_SETÚminÚmaxr'rÕÚSEEK_CURÚSEEK_ENDr0)r…rÕÚwhencer8r8r9rÇŒs  ÷û üÿz_FileInFile.seekc Cs|dur |j|j}n t||j|jƒ}d}|dkr… |j|j\}}}}||jkr0|kr3nnn|jd7_|jt|jƒkrEd|_qt|||jƒ}|rp|j ||j|¡|j |¡}t|ƒ|krkt dƒ‚||7}n|t |7}||8}|j|7_|dks|S)z!Read data from the file. Nr“rTr#rY) r'rÕrâr×rÖr2rŸrÇr]rr3) r…r'rWÚdataÚstartÚstoprÔr5rdr8r8r9r]œs2ù    íz_FileInFile.readcCs&| t|ƒ¡}||dt|ƒ…<t|ƒSr‰)r]r2)r…rdrWr8r8r9Úreadinto»sz_FileInFile.readintocCs d|_dSrÚ)r¡r‹r8r8r9rŠÀrßz_FileInFile.closer‰)rorprqrrrˆr»rÛrÝrÞrÅràrárÇr]rêrŠr8r8r8r9rÓ\s   rÓcóeZdZ‡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__©rorprqrˆÚ __classcell__r8r8ròr9rìÄsrìc@s eZdZdS)Ú FilterErrorN)rorprqr8r8r8r9röÑsröcrë)ÚAbsolutePathErrorcs ||_tƒ d|j›d�¡dS)Nzmember z has an absolute path©rñrïrˆr†©r…rñròr8r9rˆÕszAbsolutePathError.__init__rôr8r8ròr9r÷Ôór÷crë)ÚOutsideDestinationErrorcó.||_||_tƒ |j›d|›d�d¡dS)Nz would be extracted to ú, ú which is outside the destination©rñÚ_pathrïrˆr†©r…rñr%ròr8r9rˆÚó  ÿz OutsideDestinationError.__init__rôr8r8ròr9rûÙrúrûcrë)ÚSpecialFileErrorcó||_tƒ |j›d�¡dS)Nz is a special filerørùròr8r9rˆáózSpecialFileError.__init__rôr8r8ròr9ràrúrcrë)ÚAbsoluteLinkErrorcr)Nz is a link to an absolute pathrørùròr8r9rˆærzAbsoluteLinkError.__init__rôr8r8ròr9rårúrcrë)ÚLinkOutsideDestinationErrorcrü)Nz would link to rýrþrÿrròr8r9rˆërz$LinkOutsideDestinationError.__init__rôr8r8ròr9rêrúrcrë)ÚLinkFallbackErrorcs2||_||_tƒ d|j›d�d|›d�¡dS)Nzlink z would be extracted as a zcopy of z, which was rejectedrÿrròr8r9rˆòs   ÿzLinkFallbackError.__init__rôr8r8ròr9rñrúrTcCsi}|j}tjj|tjjd�}| dtjf¡r$|j dtj¡}|d<tj |¡r.t |ƒ‚tjjtj  ||¡tjjd�}tj  ||g¡|krLt ||ƒ‚|j }|dur†|d@}|r}| ¡sa| ¡rn|d@si|dM}|dO}n| ¡sv| ¡ryd}nt|ƒ‚||j kr†||d<|�r|jdur’d|d <|jdur›d|d <|jdur¤d|d <|jdur­d|d <| ¡s¶| ¡�rtj |j¡rÁt|ƒ‚tj |j¡}||jkrÑ||d <| ¡rãtj  |tj |¡|j¡}ntj  ||j¡}tjj|tjjd�}tj  ||g¡|k�rt||ƒ‚|S)N)rEú/r†iíé@i¶ÿÿÿé€r‡r)r*r+r,Úlinkname)r†r~r%ÚrealpathÚ ALLOW_MISSINGrÒÚsepÚlstripÚisabsr÷rËÚ commonpathrûr‡ÚisregÚislnkÚisdirÚissymrr)r*r+r,r rÚnormpathÚdirnamer)ÚmemberÚ dest_pathZfor_dataÚ new_attrsr†Z target_pathr‡Z normalizedr8r8r9Ú_get_filtered_attrsýsl ÿ         þÿÿ rcCs|Sr‰r8)rrr8r8r9Úfully_trusted_filterArØrcCs,t||dƒ}|r|jdi|¤ddi¤ŽS|S)NFÚdeepr8©rr³©rrrr8r8r9Ú tar_filterDó r!cCs,t||dƒ}|r|jdi|¤ddi¤ŽS|S)NTrFr8rr r8r8r9Ú data_filterJr"r#)Z fully_trustedr™rçs([0-9]{1,20}) c @s,eZdZdZed|idd“dd“dd“dd “d d “d d “dd“dd“dd“dd“dd“dd“dd“dd“dd“d d!“d"d#“d$d%“d&d%“d'd%“ŽZd}d)d*„Zed+d,„ƒZej d-d,„ƒZed.d/„ƒZ e j d0d/„ƒZ d1d2„Z e e e e e e e e d3e d4œ d5d6„Z d7d8„Zeed9fd:d;„Zdd?„Zd@dA„ZedBdC„ƒZdDdE„ZedFdG„ƒZedHdI„ƒZedJdK„ƒZedLdM„ƒZedNdO„ƒZedPdQ„ƒZdRdS„ZdTdU„Z dVdW„Z!dXdY„Z"dZd[„Z#d\d]„Z$d^d_„Z%d`da„Z&dbdc„Z'ddde„Z(dfdg„Z)dhdi„Z*djdk„Z+dldm„Z,dndo„Z-dpdq„Z.drds„Z/dtdu„Z0dvdw„Z1dxdy„Z2dzd{„Z3d%S)~raInformational 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†zName of the archive member.r‡zPermission bits.r)z6User ID of the user who originally stored this member.r*z7Group ID of the user who originally stored this member.r'zSize in bytes.r(zTime of last modification.ÚchksumzHeader checksum.Útypez–File type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.r zcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.r+z User name.r,z Group name.ÚdevmajorzDevice major number.ÚdevminorzDevice minor number.rÔzThe tar header starts here.rízThe file's data starts here.Ú pax_headerszMA dictionary containing key-value pairs of an associated pax extended header.rîzSparse member information.rðNÚ_sparse_structsÚ _link_targetr’cCsj||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_i|_dS)zXConstruct a TarInfo object. name is the optional name of the member. i¤rr’N)r†r‡r)r*r'r(r$ÚREGTYPEr%r r+r,r&r'rÔrírîr(©r…r†r8r8r9rˆƒs" zTarInfo.__init__cCrÄ)z(In pax headers, "name" is called "path".©r†r‹r8r8r9r%›rÆz TarInfo.pathcCó ||_dSr‰r-r,r8r8r9r% ó cCrÄ)z0In pax headers, "linkname" is called "linkpath".©r r‹r8r8r9r&¤rÆzTarInfo.linkpathcCr.r‰r0)r…r r8r8r9r&©r/cCsd|jj|jt|ƒfS)Nz<%s %r at %#x>)róror†Úidr‹r8r8r9Ú__repr__­szTarInfo.__repr__T) r†r(r‡r r)r*r+r,rÚ_KEEPc CsŽ| rt |¡} nt |¡} || ur|| _|| ur|| _|| ur"|| _|| ur)|| _|| ur0|| _|| ur7|| _|| ur>|| _|| urE|| _ | S)zGReturn a deep copy of self with the given attributes replaced. ) ÚcopyZdeepcopyr†r(r‡r r)r*r+r,) r…r†r(r‡r r)r*r+r,rr3Úresultr8r8r9r³°s(  zTarInfo.replacecCs€|jdurd}n|jd@}|j||j|j|j|j|j|j|j|j |j |j |j dœ }|dt kr>|d d¡s>|dd7<|S)z9Return the TarInfo's attributes as a dictionary. Néÿ) r†r‡r)r*r'r(r$r%r r+r,r&r'r%r†r )r‡r†r)r*r'r(r$r%r r+r,r&r'ÚDIRTYPEr¸)r…r‡Úinfor8r8r9Úget_infoÌs(  ózTarInfo.get_infoÚsurrogateescapecCsv| ¡}| ¡D]\}}|durtd|ƒ‚q|tkr"| |||¡S|tkr-| |||¡S|tkr7| ||¡Stdƒ‚)zsD þ  þ €    €zTarInfo.create_pax_headercCs| |td¡S)zAReturn the object as a pax global header block sequence. r/)rSÚXGLTYPE)Úclsr(r8r8r9Úcreate_pax_global_headerNsz TarInfo.create_pax_global_headercCs|| d¡}tdt|ƒƒD]-}d |d|…¡}d ||d…¡}t| ||¡ƒtkr9t| ||¡ƒtkr9||fSq tdƒ‚)zUSplit a name longer than 100 chars into a prefix and a name part. r r#Nzname is too long)ÚsplitrHr2rËr1Ú LENGTH_PREFIXrEr0)r…r†r6r7Z componentsrMrBr8r8r9rFTs €þzTarInfo._posix_split_namec Cs¦| d¡ttfv}|r t| dd¡d|ƒ}t| dd¡d|ƒ}ntdd||ƒ}tdd||ƒ}| dt¡}|durr8r8r8r9rS©sB þ  ü( ÿz"TarInfo._create_pax_generic_headerc Csft|ƒdkr tdƒ‚t|ƒtkrtdƒ‚| t¡tkrtdƒ‚t|dd…ƒ}|t|ƒvr1t 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|_|jtk�rd}g}tdƒD]0} zt|||d…ƒ} t||d|d…ƒ} Wn tyóYn w| | | f¡|d7}qÏt|dƒ} t|dd…ƒ} || | f|_ | !¡�r |j  "d¡|_ |�r1|jt#v�r1|d|j |_ |S)zAConstruct a TarInfo object from a 512 byte bytes object. rz empty headerztruncated headerzend of file headeré”éœz bad checksumrélété|éˆé�ii i)iIiQiYiôr i‚r¿rMéiâiãiï)$r2rtrÏruÚcountr3rvrNrXrKr?r†r‡r)r*r'r(r$r%r r+r,r&r'ÚAREGTYPEr¸r7ÚGNUTYPE_SPARSErHr0rÊÚboolr)rÚrstripÚ GNU_TYPES)rWrWr6r7r$ÚobjrBr ÚstructsrMrÔÚnumbytesÚ isextendedÚorigsizer8r8r9ÚfrombufÜs\      ÿ    zTarInfo.frombufcCs8|j t¡}| ||j|j¡}|j ¡t|_| |¡S)zOReturn the next TarInfo object from TarFile object tarfile. ) rŸr]rÏrxr6r7rÅrÔÚ _proc_member)rWrðrWrsr8r8r9Ú fromtarfiles  zTarInfo.fromtarfilecCsP|jttfvr | |¡S|jtkr| |¡S|jtttfvr#|  |¡S|  |¡S)zYChoose the right processing method depending on the type and call it. ) r%rKrJÚ _proc_gnulongroÚ _proc_sparserTrVÚSOLARIS_XHDTYPEÚ _proc_paxÚ _proc_builtin)r…rðr8r8r9ry0s     zTarInfo._proc_membercCsh|j ¡|_|j}| ¡s|jtvr|| |j¡7}||_|  |j |j |j ¡|  ¡r2|j d¡|_|S)zfProcess a builtin type or an unknown type which will be treated as a regular file. r )rŸrÅrírr%ÚSUPPORTED_TYPESÚ_blockr'rÔÚ_apply_pax_infor(r6r7rr†rq)r…rðrÔr8r8r9r=s zTarInfo._proc_builtinc Cs¦|j | |j¡¡}z| |¡}Wnty$}ztt|ƒƒd‚d}~ww|j|_|j t kr8t ||j |j ƒ|_n|j tkrFt ||j |j ƒ|_| ¡rQ|j d¡|_|S)zSProcess the blocks that hold a GNU longname or longlink member. Nr )rŸr]r�r'rzr rwrRrÔr%rKr?r6r7r†rJr rÚ removesuffix)r…rðrWÚnextrÎr8r8r9r{Ss€ÿ  zTarInfo._proc_gnulongc CsÖ|j\}}}|`|rS|j t¡}d}tdƒD]4}zt|||d…ƒ}t||d|d…ƒ} Wn ty:Ynw|rF| rF| || f¡|d7}qt|dƒ}|s ||_ |j  ¡|_ |j |  |j ¡|_||_ |S)z8Process a GNU sparse header plus extra headers. rérMrliø)r)rŸr]rÏrHrNr0rÊrprîrÅrír�r'rÔ) r…rðrtrvrwrWr rMrÔrur8r8r9r|ns,    ÿ  ô zTarInfo._proc_sparsec CsÐ|j | |j¡¡}|jtkr|j}n|j ¡}d}d}g}t|ƒ|krµ||dkrµt   ||¡}s6t dƒ‚z t |  d¡ƒ}Wn tyJt dƒ‚w|dkrSt dƒ‚||t|ƒkr_t dƒ‚| d¡|d} || d¡d| …} |  d¡\} } } | r‡| dks‡|| dkr‹t dƒ‚| || | f¡| dkr¥|dur¥| d kr£|j}nd }||7}t|ƒ|krµ||dks*|dur»d }|D]*\}} } | | d d |j¡}|tvrÚ| | ||j|j¡}n | | d d |j¡}|||<q½z| |¡}Wnt�y}ztt|ƒƒd‚d}~wwd |v�r| ||¡n#d |v�r| ||¡n| d ¡dk�r3| d¡dk�r3| |||¡|jtt fv�rf| !||j|j¡|j"|_"d|v�rf|j#}| $¡�s[|jt%v�rc|| |j¡7}||_"|S)zVProcess an extended or global header as described in POSIX.1-2008. rNrGr#érarÑs hdrcharsetsBINARYr/úGNU.sparse.mapúGNU.sparse.sizezGNU.sparse.majorÚ1zGNU.sparse.minorrFr')&rŸr]r�r'r%rVr(r4r2Ú_header_length_prefix_reÚmatchrKrIÚgroupr0rèrgÚ partitionrÊr6Ú_decode_pax_fieldr7ÚPAX_NAME_FIELDSrzr rwrRÚ_proc_gnusparse_01Ú_proc_gnusparse_00r[Ú_proc_gnusparse_10rTr}r‚rÔrírr€)r…rðrWr(r r6Ú raw_headersr‹r5Zheader_value_end_offsetZkeyword_and_valueZ raw_keywordZequalsZ raw_valuercr?r„rÎrÔr8r8r9r~Šs„   ÿ Ú) ÿ ÿ ÿ €ÿ    zTarInfo._proc_paxc Cs˜g}g}|D];\}}}|dkr&z | t| ¡ƒ¡Wqty%tdƒ‚w|dkrAz | t| ¡ƒ¡Wqty@tdƒ‚wqtt||ƒƒ|_dS)z?Process a GNU tar extended sparse header, version 0.0. sGNU.sparse.offsetrGsGNU.sparse.numbytesN)rÊrIr=r0rKÚlistÚziprî)r…r„r“ZoffsetsruÚ_rcr?r8r8r9r‘s" ÿ ÿýzTarInfo._proc_gnusparse_00cCs@dd„|d d¡Dƒ}tt|ddd…|ddd…ƒƒ|_dS)z?Process a GNU tar extended sparse header, version 0.1. cSsg|]}t|ƒ‘qSr8)rI)Ú.0Úxr8r8r9Ú sz.TarInfo._proc_gnusparse_01..r‡ú,Nr$r#)rYr”r•rî)r…r„r(rîr8r8r9r�s(zTarInfo._proc_gnusparse_01cCs¶d}g}|j t¡}| dd¡\}}t|ƒ}t|ƒ|dkrAd|vr*||j t¡7}| dd¡\}}| t|ƒ¡t|ƒ|dks|j ¡|_t t |ddd…|ddd…ƒƒ|_ dS)z?Process a GNU tar extended sparse header, version 1.0. Nrbr#r$) rŸr]rÏrYrIr2rÊrÅrír”r•rî)r…r„r(rðZfieldsrîrWZnumberr8r8r9r’s ü (zTarInfo._proc_gnusparse_10c CsÀ| ¡D]T\}}|dkrt|d|ƒq|dkr t|dt|ƒƒq|dkr-t|dt|ƒƒq|tvrX|tvrIzt||ƒ}Wn tyHd}Ynw|dkrR| d¡}t|||ƒq| ¡|_dS) zoReplace fields with supplemental information from a previous pax extended or global header. zGNU.sparse.namer%rˆr'zGNU.sparse.realsizerr N) r;ÚsetattrrIÚ PAX_FIELDSÚPAX_NUMBER_FIELDSr0rqr4r()r…r(r6r7rcr?r8r8r9r‚-s& ÿ  €zTarInfo._apply_pax_infocCs.z| |d¡WSty| ||¡YSw)z1Decode a single field from a pax record. rE)r=ÚUnicodeDecodeError)r…r?r6Zfallback_encodingZfallback_errorsr8r8r9rŽDs  ÿzTarInfo._decode_pax_fieldcCs2|dkrtdƒ‚t|tƒ\}}|r|d7}|tS)z_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. rzinvalid offsetr#)rKr\rÏ)r…rmrbrcr8r8r9r�Ls zTarInfo._blockcCs |jtvS©z4Return True if the Tarinfo object is a regular file.)r%Ú REGULAR_TYPESr‹r8r8r9rXr/z TarInfo.isregcCs| ¡SrŸ)rr‹r8r8r9Úisfile\szTarInfo.isfilecCó |jtkS)z!Return True if it is a directory.)r%r7r‹r8r8r9r`r/z TarInfo.isdircCr¢)z%Return True if it is a symbolic link.)r%ÚSYMTYPEr‹r8r8r9rdr/z TarInfo.issymcCr¢)z!Return True if it is a hard link.)r%ÚLNKTYPEr‹r8r8r9rhr/z TarInfo.islnkcCr¢)z(Return True if it is a character device.)r%r\r‹r8r8r9Úischrlr/z TarInfo.ischrcCr¢)z$Return True if it is a block device.)r%r]r‹r8r8r9Úisblkpr/z TarInfo.isblkcCr¢)zReturn True if it is a FIFO.)r%ÚFIFOTYPEr‹r8r8r9Úisfifotr/zTarInfo.isfifocCs |jduSr‰)rîr‹r8r8r9ÚissparsexrßzTarInfo.issparsecCs|jtttfvS)zCReturn True if it is one of character device, block device or FIFO.)r%r\r]r§r‹r8r8r9Úisdev{sz TarInfo.isdevr8)r’)4rorprqrrÚdictÚ __slots__rˆÚpropertyr%Úsetterr&r2r3r³r9rr r@r<r=r>Ú classmethodrXrFÚ staticmethodrGr_rIrSrxrzryrr{r|r~r‘r�r’r‚rŽr�rr¡rrrr¥r¦r¨r©rªr8r8r8r9r`sÄÿþýüûúùø õ óòñðïîíëêéè      ý :  )   2 >  y  rc@s eZdZdZdZdZdZdZeZ e Z dZ e ZeZdZ    dkdd „Zedddefd d „ƒZedld d „ƒZedmdd„ƒZedmdd„ƒZedndd„ƒZdddddœZdd„Zdd„Zdd„Zd d!„Zdod"d#„Zdpdd%œd&d'„Z dqdd(œd)d*„Z!drd+d,„Z"d-d.„Z#dsddd0œd1d2„Z$d3d4„Z%dtddd0œd6d7„Z&d8d9„Z' drd:d;„Z(dd?„Z*d@dA„Z+ $ dudddBœdCdD„Z,dEdF„Z-dGdH„Z.dIdJ„Z/dKdL„Z0dMdN„Z1dOdP„Z2dQdR„Z3dSdT„Z4dUdV„Z5dWdX„Z6dYdZ„Z7dvd[d\„Z8d]d^„Z9drd_d`„Z:dadb„Z;dcdd„Zdidj„Z?dS)wrz=The TarFile Class provides an interface to tar archives. rFr#Nr{r:c Cs�dddddœ}||vrtdƒ‚||_|||_|s4|jdkr*tj |¡s*d|_d|_t||jƒ}d |_n |d urHt|d ƒrHt |j t t fƒrH|j }t|d ƒrQ|j|_d |_|r\tj  |¡nd |_ ||_|d uri||_|d urp||_|d urw||_|d ur~||_|d ur…||_| |_| d ur•|jtkr•| |_ni|_| d urŸ| |_| d ur¦| |_| |_d |_g|_d |_|j ¡|_i|_z||jdkrÉd |_ | !¡|_ |jdk�r |j "|j¡z|j #|¡}|j $|¡Wn#t%yõ|j "|j¡Ynt&�y}zt't |ƒƒd ‚d }~wwqÐ|jdv�r2d |_|j�r5|j (|j )¡¡}|j *|¡|jt+|ƒ7_Wd SWd SWd S|j�sD|j ,¡d |_‚)aÖOpen 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. Úrbzr+bÚwbZxb©r{Úar|r˜ú!mode must be 'r', 'a', 'w' or 'x'r´r|FNr†r‡Tr{©r´r|r˜)-r0r‡Ú_moder~r%ÚexistsÚ bltn_openr›rƒrOr†rRrOÚabspathrŸrSrñÚ dereferenceÚ ignore_zerosr6r7rr(ÚdebugÚ errorlevelÚ copybufsizer¡ÚmembersÚ_loadedrÅrÔÚinodesÚ firstmemberr„rÇrzrÊrvr rrXr4r^r2rŠ)r…r†r‡rŸrSrñr»r¼r6r7r(r½r¾r¿ZmodesrÎrWr8r8r9rˆœs–   ÿ       €ÿø  ú zTarFile.__init__c sä|s|stdƒ‚|dvro‡fdd„}g}tˆj|d�D]G}tˆˆj|ƒ} |dur-| ¡} z | |d|fi|¤ŽWSttfyb} z| d|›d | ›�¡|durX| | ¡WYd} ~ qd} ~ wwd   |¡} td | ›�ƒ‚d |vr¡|  d d ¡\} }| p~d} |p‚d}|ˆjvr‘tˆˆj|ƒ} ntd|ƒ‚| || |fi|¤ŽSd|vrß|  dd ¡\} }| p°d} |p´d}| dvr½tdƒ‚t || |||ƒ}z ˆ|| |fi|¤Ž}Wn|  ¡‚d|_ |S|dvrîˆj|||fi|¤ŽStdƒ‚)a¥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 'r:xz' open for reading with lzma 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 'w:xz' open for writing with lzma compression 'x' or 'x:' create a tarfile exclusively without compression, raise an exception if the file is already created 'x:gz' create a gzip compressed tarfile, raise an exception if the file is already created 'x:bz2' create a bzip2 compressed tarfile, raise an exception if the file is already created 'x:xz' create an lzma compressed tarfile, raise an exception if the file is already created '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 'r|xz' open an lzma 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 'w|xz' open an lzma compressed stream for writing znothing to open)r{úr:*csˆj|dkS)NÚtaropen)Ú OPEN_METH)rž©rWr8r9Únot_compressed5rŽz$TarFile.open..not_compressed)ÚkeyNr{z - method z: Ú z'file could not be opened successfully: ú:r#r™ršú|rzzmode must be 'r' or 'w'Fr¶zundiscernible mode)r0ÚsortedrÆrhrÅrrrÊrÇrËrYr�rŠr›rÅ)rWr†r‡rŸraÚkwargsrÈZ error_msgsržÚfuncZ saved_posrÎZerror_msgs_summaryÚfilemodeÚstreamrÍr8rÇr9r sZ%   €ü   z TarFile.opencKs$|dvrtdƒ‚||||fi|¤ŽS)zCOpen uncompressed tar archive name for reading or writing. r³rµ)r0)rWr†r‡rŸrÎr8r8r9rÅiszTarFile.taropenr¯c Ksî|dvrtdƒ‚zddlm}Wn tytdƒd‚wz |||d||ƒ}WntyB}z|dur=|dkr=td ƒ|‚‚d}~wwz |j|||fi|¤Ž}Wn!tyj}z| ¡|dkretd ƒ|‚‚d}~w| ¡‚d |_ |S) zkOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. ©r{r|r˜úmode must be 'r', 'w' or 'x'r)ÚGzipFilezgzip module is not availableNrdr{r¼F) r0ZgziprÔr£rr«rrÅrŠr›) rWr†r‡rŸÚ compresslevelrÎrÔrÎrÍr8r8r9Úgzopenqs8  ÿ €ý €zTarFile.gzopenc Ks¸|dvrtdƒ‚zddlm}Wn tytdƒd‚w||p!|||d�}z |j|||fi|¤Ž}Wn#ttfyO}z| ¡|dkrJt d ƒ|‚‚d}~w| ¡‚d |_ |S) zlOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. rÒrÓr)ÚBZ2Filer–N)rÕr{znot a bzip2 fileF) r0r•r×r£rrÅr«ÚEOFErrorrŠrr›) rWr†r‡rŸrÕrÎr×rÍrÎr8r8r9Úbz2open’s*  ÿ €zTarFile.bz2openc Ks¼|dvrtdƒ‚z ddlm}m}Wn tytdƒd‚w||p#|||d�}z |j|||fi|¤Ž}Wn#|tfyQ} z| ¡|dkrLt d ƒ| ‚‚d} ~ w| ¡‚d |_ |S) zkOpen lzma compressed tar archive name for reading or writing. Appending is not allowed. rÒrÓr)ÚLZMAFiler­r˜N)Úpresetr{znot an lzma fileF) r0r¬rÚr­r£rrÅrØrŠrr›) rWr†r‡rŸrÛrÎrÚr­rÍrÎr8r8r9Úxzopen®s*  ÿ €zTarFile.xzopenrÅrÖrÙrÜ)r™r”r•r—cCsœ|jrdSd|_z;|jdvr7|j ttd¡|jtd7_t|jtƒ\}}|dkr7|j tt|¡W|j sB|j  ¡dSdS|j sM|j  ¡ww)zlClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NTr¶r$r) r¡r‡rŸr^r3rÏrÔr\Ú RECORDSIZEr›rŠ)r…rbrcr8r8r9rŠÕs  € ÿ ÿz TarFile.closecCs(| | d¡¡}|durtd|ƒ‚|S)aReturn 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. r Nzfilename %r not found)Ú _getmemberrqÚKeyError)r…r†rñr8r8r9Ú getmemberês zTarFile.getmembercCs| ¡|js | ¡|jS)zŽReturn the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive. )Ú_checkrÁÚ_loadrÀr‹r8r8r9Ú getmembersõszTarFile.getmemberscCsdd„| ¡DƒS)z‹Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). cSsg|]}|j‘qSr8r-)r—rñr8r8r9r™sz$TarFile.getnames..)rãr‹r8r8r9ÚgetnamesÿszTarFile.getnamesc CsJ| d¡|dur |j}|dur|}tj |¡\}}| tjd¡}| d¡}| ¡}||_ |dur@|j s:t  |¡}n t  |¡}nt  | ¡¡}d}|j}t  |¡r|j|jf} |j ss|jdkrs| |jvrs||j| krst} |j| }n;t} | dr~||j| <n/t  |¡r‡t} n't  |¡r�t} nt  |¡rœt} t |¡}nt  |¡r¤t} n t   |¡r¬t!} ndS||_||_"|j#|_$|j%|_&| tkrÅ|j'|_(nd|_(|j)|_*| |_+||_,t-réz t- .|j$¡d|_/Wn t0yèYnwt1�rz t1 2|j&¡d|_3Wn t0�yYnw| tt!fv�r#t4tdƒ�r#t4tdƒ�r#t 5|j6¡|_7t 8|j6¡|_9|S) aÒCreate a TarInfo object from the result of os.stat or equivalent on an existing file. The file is either named by `name', or specified as a file object `fileobj' with a file descriptor. If given, `arcname' specifies an alternative name for the file in the archive, otherwise, the name is taken from the 'name' attribute of 'fileobj', or the 'name' argument. The name should be a text string. ÚawxNr r’r#rÚmajorÚminor):rár†r~r%Ú splitdriver³rrrñrðr»ÚlstatÚstatÚfstatÚfilenoÚst_modeÚS_ISREGÚst_inoÚst_devÚst_nlinkrÂr¤r+ÚS_ISDIRr7ÚS_ISFIFOr§ÚS_ISLNKr£ÚreadlinkÚS_ISCHRr\ÚS_ISBLKr]r‡Úst_uidr)Úst_gidr*Úst_sizer'Úst_mtimer(r%r ÚpwdÚgetpwuidr+rßÚgrpZgetgrgidr,rƒræÚst_rdevr&rçr') r…r†ÚarcnamerŸZdrvrñZstatresr ZstmdÚinoder%r8r8r9Ú gettarinfos„        €        ÿÿzTarFile.gettarinfoT)rÀcCs"| ¡|dur |}|D]‚}|rf|jdurtdƒntt |j¡ƒtd|jp)|j|jp.|jfƒ|  ¡s:|  ¡rGtdd|j |j fƒntd|j ƒ|jdurXtdƒntdt |j¡dd …ƒt|j| ¡rod nd ƒ|r‹| ¡r€td |jƒ| ¡r‹td |jƒtƒq dS)aPrint 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. `members' is optional and must be a subset of the list returned by getmembers(). 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¦r&r'r'r(r¶Ú localtimer†rrr rrk)r…ÚverboserÀrñr8r8r9r”hs:   ÿÿ  ÿæz TarFile.list©ÚfiltercCsP| d¡|dur |}|jdur#tj |¡|jkr#| dd|¡dS| d|¡| ||¡}|dur=| dd|¡dS|durS||ƒ}|durS| dd|¡dS| ¡rut|dƒ�}|  ||¡WdƒdS1snwYdS|  ¡r¡|  |¡|r�t t  |¡ƒD]}|j tj ||¡tj ||¡||d �q‡dSdS|  |¡dS) a!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. `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. råNr$ztarfile: Skipped %rr#ztarfile: Unsupported type %rútarfile: Excluded %rr±r)rár†r~r%rºÚ_dbgrrr¹ÚaddfilerrÍÚlistdirÚaddrË)r…r†rÚ recursiverrñÚfr8r8r9r Žs<    "ÿ ÿþz TarFile.addcCs¾| d¡t |¡}| |j|j|j¡}|j |¡|jt |ƒ7_|j }|durWt ||j|j |d�t |j tƒ\}}|dkrN|j tt|¡|d7}|j|t7_|j |¡dS)aAdd the TarInfo object `tarinfo' to the archive. If `fileobj' is given, it should be a binary file, and tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects directly, or by using gettarinfo(). råN)rarr#)rár4r@rSr6r7rŸr^rÔr2r¿r[r'r\rÏr3rÀrÊ)r…rñrŸrWrarbrcr8r8r9r Ás   zTarFile.addfilecCsh|dur|j}|dur tSt|tƒrtdƒ‚|St|ƒr|Szt|WSty3td|›d�ƒd‚w)NzrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.zfilter z not found) Úextraction_filterrrOrRÚ TypeErrorÚcallableÚ_NAMED_FILTERSrßr0)r…rr8r8r9Ú_get_filter_functionÚs  ÿ  ÿzTarFile._get_filter_functionÚ.)Ú numeric_ownerrc Cs g}| |¡}|dur |}|D]&}| |||¡\}} |durq| ¡r(| | ¡|j||| ¡ ||d�q|jdd„dd�|D]Œ} zsz|| |ƒ}Wntyf} z| | t| ƒ¡WYd} ~ WqAd} ~ ww|durs| | d¡WqAt j   ||j ¡} zt   | ¡} Wnty’| |d¡YWqAwt | j¡s¡| |d ¡WqA|j|| |d �| || ¡| || ¡WqAtyÍ} z | | ¡WYd} ~ qAd} ~ wwdS) a˜Extract 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(). If `numeric_owner` is True, only the numbers for user/group names are used and not the names. The `filter` function will be called on each member just before extraction. It can return a changed TarInfo or None to skip the member. String names of common filters are accepted. N)Ú set_attrsrÚfilter_functioncSrÄr‰r-)r´r8r8r9Ú sz$TarFile.extractall..T)rÉÚreversezexcluded by filterZmissingznot a directory)r)rÚ_get_extract_tarinforrÊÚ _extract_oneÚsortÚ_FILTER_ERRORSÚ_log_no_directory_fixupÚreprr~r%rËr†réÚFileNotFoundErrorrêròríÚchownÚutimeÚchmodr Ú_handle_nonfatal_error)r…r%rÀrrZ directoriesrrrñÚ unfilteredÚexcÚdirpathrérÎr8r8r9Ú extractallìsb ÿ þ€þÿ  þ   €ÿåzTarFile.extractallcCs| dd|j|f¡dS)Nr$z(tarfile: Not fixing up directory %r (%s))rr†)r…rÚreasonr8r8r9r1 s ÿzTarFile._log_no_directory_fixupr’c Cs<| |¡}| |||¡\}}|dur| ||||¡dSdS)a¯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'. File attributes (owner, mtime, mode) are set unless `set_attrs' is False. If `numeric_owner` is True, only the numbers for user/group names are used and not the names. The `filter` function will be called before extraction. It can return a changed TarInfo or None to skip the member. String names of common filters are accepted. N)rrr) r…rr%rrrrrñr$r8r8r9Úextract5 s ÿÿzTarFile.extractc CsÖt|tƒr | |¡}n|}d}z|||ƒ}Wn/ttfy/}z | |¡WYd}~nd}~wtyE}z | |¡WYd}~nd}~ww|durU| dd|j ¡dS|  ¡rgt   |¡}t j  ||j¡|_||fS)zŠGet (filtered, unfiltered) TarInfos from *member* *member* might be a string. Return (None, None) if not found. Nr$r)NN)rOrRràr«röÚ_handle_fatal_errorr r#rr†rr4r~r%rËr r*)r…rrr%r$ÚfilteredrÎr8r8r9rI s(  €€ÿ zTarFile._get_extract_tarinfoc Cs’| d¡z|j|tj ||j¡||||d�WdSty1}z | |¡WYd}~dSd}~wtyH}z |  |¡WYd}~dSd}~ww)z±Extract from filtered tarinfo to disk. filter_function is only used when extracting a *different* member (e.g. as fallback to creating a symlink) r{)rrrÚextraction_rootN) ráÚ_extract_memberr~r%rËr†r«r*r r#)r…rñr%rrrrÎr8r8r9rg s  ü€€ÿzTarFile._extract_onecCs |jdkr‚| dd|¡dS)z=Handle non-fatal error (ExtractError) according to errorlevelr#ú tarfile: %sN)r¾r©r…rÎr8r8r9r#{ s zTarFile._handle_nonfatal_errorcCsp|jdkr‚t|tƒr)|jdur| dd|j¡dS| dd|j|jf¡dS| ddt|ƒj|f¡dS)z1Handle "fatal" error according to self.errorlevelrNr#r.ztarfile: %s %rztarfile: %s %s)r¾rOr«ÚfilenamerÚstrerrorr%ror/r8r8r9r*‚ s   zTarFile._handle_fatal_errorcCsz| d¡t|tƒr| |¡}n|}| ¡s|jtvr!| ||¡S| ¡s)|  ¡r;t|j t ƒr3t dƒ‚|  | |¡¡SdS)a\Extract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file or a link, an io.BufferedReader object is returned. For all other existing members, None is returned. If `member' does not appear in the archive, KeyError is raised. r{z'cannot extract (sym)link as file objectN)rárOrRràrr%r€Ú fileobjectrrrŸr�r Ú extractfileÚ_find_link_target)r…rrñr8r8r9r3Ž s     zTarFile.extractfile©rr,cCs\| d¡}| dtj¡}tj |¡}|rtj |¡st |¡| ¡s'|  ¡r4|  dd|j |j f¡n|  d|j ¡|  ¡rF| ||¡nI| ¡rQ| ||¡n>| ¡r\| ||¡n3| ¡sd| ¡rk| ||¡n$| ¡ss|  ¡r}|j||||d�n|jtvr‰| ||¡n| ||¡|rª| |||¡|  ¡s¬| ||¡| ||¡dSdSdS)zçExtract the filtered TarInfo object tarinfo to a physical file called targetpath. filter_function is only used when extracting a *different* member (e.g. as fallback to creating a symlink) r r#z%s -> %sr5N)rqr³r~rr%rr¸Úmakedirsrrrr†r rÚmakefilerÚmakedirr¨Úmakefifor¥r¦ÚmakedevÚmakelink_with_filterr%r€Ú makeunknownr r"r!)r…rñÚ targetpathrrrr,Z upperdirsr8r8r9r-® s@   ý   üzTarFile._extract_membercCsBz|jdurt |¡WdSt |d¡WdSty YdSw)z,Make a directory called targetpath. NiÀ)r‡r~ÚmkdirÚFileExistsError©r…rñr=r8r8r9r8æ s  ÿzTarFile.makedircCs´|j}| |j¡|j}t|dƒ�?}|jdur7|jD]\}}| |¡t|||t|ƒq| |j¡|  ¡nt|||jt|ƒWdƒdSWdƒdS1sSwYdS)z'Make a file called targetpath. r²N) rŸrÇrír¿r¹rîr[rr'Útruncate)r…rñr=ÚsourceraÚtargetrÔr'r8r8r9r7ô s      ø"úzTarFile.makefilecCs"| ||¡| dd|j¡dS)zYMake a file from a TarInfo object with an unknown type at targetpath. r#z9tarfile: Unknown file type %r, extracted as regular file.N)r7rr%r@r8r8r9r< s  ÿzTarFile.makeunknowncCs ttdƒr t |¡dStdƒ‚)z'Make a fifo called targetpath. Úmkfifozfifo not supported by systemN)rƒr~rDr r@r8r8r9r9 s zTarFile.makefifocCsjttdƒr ttdƒstdƒ‚|j}|durd}| ¡r!|tjO}n|tjO}t ||t  |j |j ¡¡dS)z € ÿ € ÿ €ÿèz TarFile.chownc CsF|jdurdSz t ||j¡WdSty"}ztdƒ|‚d}~ww)zASet file permissions of targetpath according to tarinfo. Nzcould not change mode)r‡r~r"r«r )r…rñr=rÎr8r8r9r"| s  €ÿz TarFile.chmodc CsZ|j}|dur dSttdƒsdSz t |||f¡WdSty,}ztdƒ|‚d}~ww)zBSet modification time of targetpath according to tarinfo. Nr!z"could not change modification time)r(rƒr~r!r«r )r…rñr=r(rÎr8r8r9r!† s  €ÿz TarFile.utimec Cs:| d¡|jdur|j}d|_|S|j|j ¡kr-|j |jd¡|j d¡s-tdƒ‚d} z|j  |¡}WnÑt ye}z!|j r[|  dd|j|f¡|jt 7_WYd}~q/WYd}~n©d}~wty�}z-|j r‡|  dd|j|f¡|jt 7_WYd}~q/|jdkr“tt|ƒƒd‚WYd}~nqd}~wty¯|jdkr­td ƒd‚Yn[tyÌ}z|jdkrÂtt|ƒƒd‚WYd}~nBd}~wtyÞ}ztt|ƒƒd‚d}~wt�y }zzddl}t||jƒrùtd |›�ƒd‚|‚t�y|‚wd}~ww |du�r|j |¡|Sd|_|S) z¨Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. ZraNr#rYTr$z0x%X: %srz empty filez zlib error: )rárÃrÔrŸrÅrÇr]rrñrzrvr¼rrÏrKrRrtrurwÚ Exceptionr¢rOr§r£rÀrÊrÁ)r…ÚmrñrÎr¢r8r8r9r„” st     ý€   ÿ€   ÿ  ÿ€€ ÿ€ù  þz TarFile.nextc Cs´| ¡}d}|dur#z| |¡}Wn tyd}Ynw|d|…}|r+tj |¡}t|ƒD]"}|r<|j|jkr;d}q/|rFtj |j¡}n|j}||krQ|Sq/|rXt|ƒ‚dS)z}Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. FNT) rãÚindexr0r~r%rÚreversedrÔr†) r…r†rñÚ normalizerÀZskippingrVrÚ member_namer8r8r9rÞÓ s2 ý    ÿþzTarFile._getmembercCs | ¡}|dur nqd|_dS)zWRead through the entire archive file and look for readable members. TN)r„rÁrùr8r8r9râû s ý z TarFile._loadcCs>|jr td|jjƒ‚|dur|j|vrtd|jƒ‚dSdS)znCheck if TarFile is still open, and if the operation's mode corresponds to TarFile's mode. z %s is closedNzbad operation for mode %r)r¡r«róror‡)r…r‡r8r8r9rá s ÿzTarFile._checkcCs`| ¡rd tdtj |j¡|jfƒ¡}d}n|j}|}|j||dd�}|dur.t d|ƒ‚|S)zZFind the target member of a symlink or hardlink member in the archive. r NT)rñrXzlinkname %r not found) rrËrr~r%rr†r rÞrß)r…rñr Úlimitrr8r8r9r4 s  zTarFile._find_link_targetccsŠ�|jr |jEdHdSd}|jdur| ¡}|d7}|V |t|jƒkr,|j|}n|js;| ¡}|s:d|_dSndS|d7}|Vq)z$Provide an iterator object. Nrr#T)rÁrÀrÃr„r2)r…rVrñr8r8r9Ú__iter__! s,€   þõzTarFile.__iter__cCs ||jkrt|tjd�dSdS)z.Write debugging output to sys.stderr. ©ÚfileN)r½rkriÚstderr)r…ÚlevelÚmsgr8r8r9r@ s ÿz TarFile._dbgcCs | ¡|Sr‰)rár‹r8r8r9Ú __enter__F szTarFile.__enter__cCs.|dur | ¡dS|js|j ¡d|_dSrÚ)rŠr›rŸr¡)r…r%r?Ú tracebackr8r8r9Ú__exit__J s    zTarFile.__exit__) Nr{NNNNNNr:NNNN)r{N)r{Nr¯)r{NN)NNN©TrÚr‰)rN)r’T)TFrÜ)@rorprqrrr½r»r¼r¾rrSr r6r7rrñrìr2rrˆr¯rÝrrÅrÖrÙrÜrÆrŠràrãrärr”r r rr'rr)rrr#r*r3r-r8r7r<r9r:rHr;r r"r!r„rÞrârár4r[rrarcr8r8r8r9r€sž ýo]    ü   c& 3 ÿE ÿ ÿ  ÿ þ82!  ?(   rcCsBzt|dƒr t|d�}nt|ƒ}| ¡WdSty YdSw)z¤Return True if name points to a tar archive that we are able to handle, else return False. 'name' should be a string, file, or file-like object. r])rŸTF)rƒrrŠr)r†rÍr8r8r9rX s   ÿrc Cshddl}d}|j|d�}|jdddddd �|jd d td d �|jdd�}|jddddd�|jdddddd�|jdddddd�|jdd dd!d�| ¡}|jr]|jdur]| d"d#¡|j dur¤|j }t |ƒr™t |d$ƒ�}|  ¡t |  ¡tjd%�Wdƒn1s†wY|jr—t d& |¡ƒdSdS| d"d' |¡¡dS|jdurÛ|j}t |ƒrÐt  |d(¡�}|j|jd)�WdƒdS1sÉwYdS| d"d' |¡¡dS|jdu�rRt|jƒd"krñ|jd}tj}nt|jƒd*krþ|j\}}n| d"| ¡¡t |ƒ�rGt  |d(¡�}|j||jd+�Wdƒn 1�s%wY|j�rE|d,k�r9d- |¡} nd. ||¡} t | ƒdSdS| d"d' |¡¡dS|jdu�r°|j d¡} tj | ¡\} } d/d/d0d0d1d1d1d1d2œ} | | v�r|d3| | nd4}|j}t  | |¡�}|D]}| |¡�qŠWdƒn 1�sžwY|j�r²t d5 | ¡ƒdSdSdS)6Nrz3A simple command-line interface for tarfile module.)Ú descriptionz-vz --verboseÚ store_trueFzVerbose output)ÚactionÚdefaultÚhelpz--filterz zFilter for extraction)ÚmetavarÚchoicesriT)Zrequiredz-lz--listú zShow listing of a tarfile)rjriz-ez --extractú+)rlz zExtract tarfile into target dir)Únargsrjriz-cz--create)zzzCreate tarfile from sourcesz-tz--testzTest if a tarfile is validr#z&--filter is only valid for extraction r{r\z{!r} is a tar archive.z{!r} is not a tar archive. rÄ)rr$)r%rrz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.r”r—r•)r±z.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:r|z{!r} file created.)ÚargparseÚArgumentParserÚ add_argumentrZadd_mutually_exclusive_groupÚ parse_argsrr)ÚexitÚtestrrrãrkrir^rrSr”rr2r~ÚcurdirZ format_helpr'ZcreateÚpopr%Úsplitextr )roreÚparserrŒÚargsr_r™Ztfrur`Ztar_namer–ZextZ compressionsZtar_modeZ tar_filesÚ file_namer8r8r9Úmaink s²  ÿþ  ÿ þ þ ÿ   þÿ "ÿ    ÿ  ÿ ú  õ ÿÿèr{Ú__main__rd)orrÚversionÚ __author__Ú __credits__Úbuiltinsrr¹rir~ràrZrêr¶rVr4ÚreÚwarningsrür£rþÚAttributeErrorÚNotImplementedErrorrMr«Ú NameErrorÚ__all__r3rÏrÝrHrCrErDrZr+rnr¤r£r\r]r7r§ZCONTTYPErKrJrorTrVr}r rrrr€r rrrœr�rPrIr�r†r Úgetfilesystemencodingr:r?rNrTrXr[rlrTrr rrr r rtrurvrKrwryr�ÚobjectrœrÓÚBufferedReaderrìrör÷rûrrrrrrrr!r#rr3ÚcompilerŠrrrr{ror8r8r8r9Ús(   ÿ  ÿ ÿ üÿÿú  sh  Dý &a _ ÿ