Qf֧ dZdZdZdZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZ ddlZ ddlZeeefZgdZdZd Zed zZd Zd Zd Zd ZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2e2Z3e!e"e#e$e'e(e)e%e&e*e+e,f Z4e!e"e)e,fZ5e*e+e,fZ6dZ7hd Z8e9e9e9e:e:e:d!Z;ejxd"k(rd#Z=nej|Z=d$Z?d%Z@d&ZAd'e3fd(ZBd)ZCdedfd*ZDd+ZEGd,d-eFZGGd.d/eGZHGd0d1eGZIGd2d3eGZJGd4d5eGZKGd6d7eGZLGd8d9eLZMGd:d;eLZNGd<d=eLZOGd>d?eLZPGd@dAeLZQGdBdCZRGdDdEZSGdFdGeTZUGdHdIeTZVGdJdKe jZXGdLdMeGZYGdNdOeYZZGdPdQeYZ[GdRdSeYZ\GdTdUeYZ]GdVdWeYZ^dedXZ_dYZ`dZZad[Zbe`eaebd\ZceTZdejd]ZfGd^d_eTZgGd`daeTZhdbZiehj ZdcZjekddk(rejyy#e$rdZYwxYw#e$rdZYwxYw)fz,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)TarFileTarInfo is_tarfileTarError ReadErrorCompressionError StreamError ExtractError HeaderErrorENCODING USTAR_FORMAT GNU_FORMAT PAX_FORMATDEFAULT_FORMATrfully_trusted_filter data_filter tar_filter FilterErrorAbsoluteLinkErrorOutsideDestinationErrorSpecialFileErrorAbsolutePathErrorLinkOutsideDestinationErrorisustar sustar00d01234567LKSxgX)pathlinkpathsizemtimeuidgidunamegname>r/r6r5r0)atimectimer2r3r4r1ntutf-8cv| td|j||}|d||t|z tzzS)z8Convert a string to a null-terminated bytes object. Nzmetadata cannot contain None) ValueErrorencodelenNUL)slengthencodingerrorss ./opt/alt/python312/lib64/python3.12/tarfile.pystnrEsC y788 6"A Wf:#a&C/ //c\|jd}|dk7r|d|}|j||S)z8Convert a null-terminated bytes object to a string. rN)finddecode)r@rBrCps rDntsrLs4 u ABw bqE 88Hf %%rFc6|ddvrMd}tt|dz D]}|dz}|||dzz }|ddk(rdt|dz z|z }|S t|dd}t|j xsd d}|S#t $r t d wxYw) z/Convert a number field to a python number. r)r-rOasciistrict0invalid header)ranger>rLintstripr<InvalidHeaderError)r@nis rDntir\s  t~ s1vz"A !GA 1q5MA# Q45=#a&1*%)*A H  7Aw)AAGGI$a(A H 7$%56 6 7s +BBrPc|}t|}d|cxkr d|dz zkr nntd|dz |fzdtz}|S|tk(rzd|dz z |cxkr d|dz zkrbn td |dk\r t dg}nt dg}d|z|z}t |dz D]}|j d|dz|dz}|Std ) z/Convert a python number to a number field. rrPr-z%0*orRrQrNrOzoverflow in number field)rWbytesr?r bytearrayrVinsertr<)rZdigitsformat original_nr@r[s rDitnrdsJ AAA!fqj!! &FQJ?*G 4s : H : 36A:#6"6!"Qcfqj>Q"Q344 65'"A5'"Av !Avz"A HHQE " !GA# H344rFcdttjd|z}dttjd|z}||fS)aCalculate 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. rQ 148B8x356B 148b8x356b)sumstruct unpack_from)bufunsigned_chksum signed_chksums rD calc_chksumsrnsGC 2 2< EFFO#f00sCDDM M ))rFcx|xsd}|dk(ry|tj|||yt||\}}t|D]:}|j |}t ||kr|d|j |<|dk7r8|j |}t ||kr|d|j |y)zjCopy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. i@rNunexpected end of data)shutil copyfileobjdivmodrVreadr>write) srcdstrA exceptionbufsizeblocks remainderbrks rDrrrrs"G { ~3W-vw/FI 6]hhw s8g 45 5 #  A~hhy! s8i 45 5 # rFcttjdd}|!|j|dj |}t |dy)NrBbackslashreplace )end)getattrsysstdoutr=rJprint)r@rBs rD _safe_printrs@szz:t4H HHX1 2 9 9( C !rFceZdZdZy)rzBase exception.N__name__ __module__ __qualname____doc__rFrDrrsrFrceZdZdZy)r z%General exception for extract errors.NrrrFrDr r s/rFr ceZdZdZy)rz&Exception for unreadable tar archives.NrrrFrDrrs0rFrceZdZdZy)r z.Exception for unavailable compression methods.NrrrFrDr r s8rFr ceZdZdZy)r z=Exception for unsupported operations on stream-like TarFiles.NrrrFrDr r sGrFr ceZdZdZy)r z!Base exception for header errors.NrrrFrDr r s+rFr ceZdZdZy)EmptyHeaderErrorzException for empty headers.NrrrFrDrr s&rFrceZdZdZy)TruncatedHeaderErrorz Exception for truncated headers.NrrrFrDrr#s*rFrceZdZdZy)EOFHeaderErrorz"Exception for end of file headers.NrrrFrDrr&s,rFrceZdZdZy)rYzException for invalid headers.NrrrFrDrYrY)s(rFrYceZdZdZy)SubsequentHeaderErrorz3Exception for missing and invalid extended headers.NrrrFrDrr,s=rFrc(eZdZdZdZdZdZdZy) _LowLevelFilezLow-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. ctjtjtjztjzd|}t tdr|tj z}tj||d|_y)NrwO_BINARYi) osO_RDONLYO_WRONLYO_CREATO_TRUNChasattrrrfd)selfnamemodes rD__init__z_LowLevelFile.__init__9sarzz)BJJ6   2z " BKK D''$e,rFcBtj|jyN)rcloserrs rDrz_LowLevelFile.closeBs rFcBtj|j|Sr)rrtrrr1s rDrtz_LowLevelFile.readEswwtww%%rFcDtj|j|yr)rrurrr@s rDruz_LowLevelFile.writeHs !rFN)rrrrrrrtrurrFrDrr3s -&rFrcZeZdZdZdZdZdZdZdZdZ dZ d Z dd Z d Z d Zd Zy)_StreamaClass 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 that works with bytes, and the method is accessed blockwise. Use of gzip or bzip2 compression is possible. A stream-like object could be for example: sys.stdin.buffer, sys.stdout.buffer, a socket, a tape device etc. _Stream is intended to be used only internally. cd|_|t||}d|_|dk(rt|}|j}|xsd|_||_||_||_||_d|_ d|_ d|_ |dk(r[ ddl }||_ |jd|_|d k(r"|j"|_|j'y|j)|y|d k(rI ddl}|d k(r(d|_|j/|_t2|_y|j5||_y|d k(rN ddl} |d k(r.d|_| j9|_| j:|_y| j=|_y|dk7rtd|zy#t$r td dwxYw#t$r td dwxYw#t$r tddwxYw#|js|jj?d|_ xYw)z$Construct a _Stream object. TNF*rFrgzzzlib module is not availablerbz2bz2 module is not availablexzlzma module is not availabletarunknown compression type %r) _extfileobjr _StreamProxy getcomptyperrcomptypefileobjryrkposclosedzlib ImportErrorr crc32crcerrorrx _init_read_gz_init_write_gzrdbufBZ2DecompressorcmpOSError BZ2CompressorlzmaLZMADecompressor LZMAErrorLZMACompressorr) rrrrrry compresslevelrrrs rDrz_Stream.__init__Ws  ?#D$/G$D  s?#7+G**,H        - 4U! ::c?3;%)ZZDN&&('' 6U"T3; #DI"224DH%,DN"00?DHT!U3; #DI#446DH%)^^DN#224DHU"&'Dx'OPP#E#U*+IJPTTU#T*+HItST#U*+IJPTTU ## ""$DK sy:GFAGGG F($,GG(G.G22G%G;GF%%G(F>>GGG0H cXt|dr|js|jyyy)Nr)rrrrs rD__del__z_Stream.__del__s# 4 "4;; JJL,7 "rFct|jj||jj|jj |jjd|_t jdttj}|jd|zdz|jjdr|jdd|_ tjj|j|_ |j|jj!dd t"zy) z6Initialize for writing with gzip compression. rDErFc*|jdk(r+|jj||j|_|xjt |z c_|jdk7r|j j|}|j|y)z&Write string s to the stream. rrN) rrrrrr>rcompressrrs rDruz _Stream.writesg ==D yyq$((3DH CF ==E !!!!$A QrFcZ|xj|z c_t|j|jkDrt|jj |jd|j|j|jd|_t|j|jkDrsyy)z]Write string s to the stream if a whole new block is ready to be written. N)rkr>ryrrurs rD__writez_Stream.__writesr A $((mdll* LL  txx 6 7xx .DH$((mdll*rFc|jryd|_ |jdk(r<|jdk7r-|xj|jj z c_|jdk(r|jr|j j|jd|_|jdk(ru|j jtjd|j|j jtjd|jdz|js|j jyy#|js|j jwwxYw) z[Close the _Stream object. No operation should be done on it afterwards. NTrrrFrrl)rrrrkrflushrrurirrrrrrs rDrz _Stream.closes  ;;   %yyCDMMU$:DHHNN,,yyCDHH ""488,==D(LL&&v{{4'BCLL&&v{{4J9N'OP## ""$$4## ""$$s DE)E=c|jj|jj |_d|_|j ddk7r t d|j ddk7r tdt|j d}|j d|d zrIt|j dd t|j dzz}|j||d zr |j d}|r |tk(rn|d zr |j d}|r |tk(rn|dzr|j dy y )z:Initialize for reading a gzip compressed fileobj. rFr.snot a gzip filer-zunsupported compression methodrQrPN) r decompressobjrrr _Stream__readrr ordrtr?)rflagxlenr@s rDrz_Stream._init_read_gzs+99**DII,?,?+?@  ;;q>[ (-. . ;;q>W $"#CD D4;;q>" A !8t{{1~&s4;;q>/B)BBD IIdO !8KKNAH "9KKNAH !8 KKN rFc|jS)z3Return the stream's file pointer position. )rrs rDtellz _Stream.tells xxrFc||jz dk\rnt||jz |j\}}t|D]}|j |j|j ||jSt d)zXSet the stream's file pointer to pos. Negative seeking is forbidden. rz seeking backwards is not allowed)rrsryrVrtr )rrrzr{r[s rDseekz _Stream.seekst >Q  &sTXX~t|| D FI6] $,,'# IIi xx@A ArFcd|j|}|xjt|z c_|S)z5Return the next size number of bytes from the stream.)_readrr>)rr1rks rDrtz _Stream.read s)jj CH rFc(|jdk(r|j|St|j}|jg}||kr|jr|j}d|_n(|j j |j}|snA |jj|}|j||t|z }||krdj|}||d|_|d|S#|j$r}td|d}~wwxYw)z+Return size bytes from the stream. rrFzinvalid compressed dataN)rrr>rrkrrtryr decompressrxrappendjoin)rr1ctrkes rDrz _Stream._reads ==E !;;t$ $  N YYK$hxxhhll'' 5 Bhh))#. HHSM SMA$h HHQKdeH $x >> B 9:A BsC11D D  Dc*t|j}|jg}||krM|jj|j}|sn%|j ||t|z }||krMdj |}||d|_|d|S)zsReturn size bytes from stream. If internal buffer is empty, read another block from the stream. rFN)r>rkrrtryrr)rr1rrrks rD__readz_Stream.__read/s M XXJ$h,,##DLL1C HHSM SMA $h HHQKTU8$xrFN)r)rrrrrrrrurrrrrrtrrrrFrDrrKsF ENF"/%,> 6rFrc(eZdZdZdZdZdZdZy)rzsSmall proxy class that enables transparent compression detection for the Stream interface (mode 'r|*'). cZ||_|jjt|_yr)rrt BLOCKSIZErk)rrs rDrz_StreamProxy.__init__Es <<$$Y/rFcP|jj|_|jSr)rrtrkrs rDrtz_StreamProxy.readIsLL%% xxrFc|jjdry|jdddk(r|jdddk(ry |jjd ry y ) NsrrsBZhr s1AY&SYr)s]s7zXZrr)rk startswithrs rDrz_StreamProxy.getcomptypeMsV 88   / XXa]f $!B9)D XX !C DrFc8|jjyr)rrrs rDrz_StreamProxy.closeWs rFN)rrrrrrtrrrrFrDrr@s0rFrcheZdZdZd dZdZdZdZdZdZ e jfd Z d d Z d Zd Zy) _FileInFilezA thin wrapper around an existing file object that provides a part of its data as an individual file object. Nc||_||_||_d|_||_d|_|d|fg}d|_g|_d}|j}|D]U\}}||kDr|jjd||df|jjd|||z|f||z }||z}W||jkr*|jjd||jdfyy)NrFT) roffsetr1positionrr map_indexmapr)rrrr1r blockinfolastposrealposs rDrz_FileInFile.__init__ds       T I++%LFD >? HHOOT66D='B C tOGtmG & TYY  HHOOUGTYY= > rFcyrrrs rDrz_FileInFile.flush}s rFcyNTrrs rDreadablez_FileInFile.readablesrFcyNFrrs rDwritablez_FileInFile.writablesrFc6|jjSr)rseekablers rDr%z_FileInFile.seekables||$$&&rFc|jS)z*Return the current file position. )rrs rDrz_FileInFile.tell}}rFc.|tjk(r1tt|d|j|_|j S|tj k(rc|dkr*t|j |zd|_|j St|j |z|j|_|j S|tjk(r>tt|j|z|jd|_|j Std)z(Seek to a position in the file. rzInvalid argument) ioSEEK_SETminmaxr1rSEEK_CURSEEK_ENDr<)rrwhences rDrz_FileInFile.seeks R[[ Ha 0$))rrrtrr?) rr1rkdatastartstoprrAr|s rDrtz_FileInFile.readsD <99t}},DtTYY67DQh,0HHT^^,D)eT6DMM0D0NNa'N~~TXX6)*tdmm34F !!&DMME,A"BCLL%%f-q6V##$<==qsV|# FND MMV #M'Qh( rFch|jt|}||dt|t|Sr)rtr>)rr|rks rDreadintoz_FileInFile.readintos,iiA)3s8 3xrFcd|_yr)rrs rDrz_FileInFile.closes  rFr)rrrrrrr r#r%rr)r*rrtr5rrrFrDrr^sB ?2 ' %'KK > rFrceZdZfdZxZS) ExFileObjectct|j|j|j|j|j }t ||yr)rr offset_datar1rsparsesuperr)rtarfiletarinfor __class__s rDrzExFileObject.__init__s;goow/B/B gllGNN< !rFrrrr __classcell__r?s@rDr8r8s ""rFr8c eZdZy)rN)rrrrrFrDrrsrFrceZdZfdZxZS)rcN||_t| d|jdy)Nzmember z has an absolute pathr>r<rrrr>r?s rDrzAbsolutePathError.__init__s&  77<<"22GHIrFr@rBs@rDrrsJJrFrceZdZfdZxZS)rcf||_||_t| |jd|ddzy)Nz would be extracted to , which is outside the destinationr>_pathr<rrrr>r/r?s rDrz OutsideDestinationError.__init__s;   GLL++B4("M=> ?rFr@rBs@rDrr ??rFrceZdZfdZxZS)rcL||_t| |jdy)Nz is a special filerFrGs rDrzSpecialFileError.__init__s$  GLL++=>?rFr@rBs@rDrrs@@rFrceZdZfdZxZS)rcL||_t| |jdy)Nz is a link to an absolute pathrFrGs rDrzAbsoluteLinkError.__init__s$  GLL++IJKrFr@rBs@rDrrsLLrFrceZdZfdZxZS)rcf||_||_t| |jd|ddzy)Nz would link to rJrKrLrNs rDrz$LinkOutsideDestinationError.__init__s:   GLL+?4("E=> ?rFr@rBs@rDrrrOrFrci}|j}tjj|}|j dtj fr1|jj dtj zx}|d<tjj|r t|tjjtjj||}tjj||g|k7r t|||j}|y|dz}|r^|js|jr|dzs|dz}|dz}n.|js|j!rd}n t#|||jk7r||d<|rk|j$d|d<|j&d|d <|j(d|d <|j*d|d <|js|j!rtjj|j,r t/||j!rItjj|tjj1||j,}n*tjj||j,}tjj|}tjj||g|k7r t3|||S) N/ri@irr3r4r5r6)rrr/realpathrseplstripisabsrr commonpathrrisregislnkisdirissymrr3r4r5r6linknamerdirnamer)member dest_pathfor_data new_attrsr target_pathrs rD_get_filtered_attrsrjs^I ;;D  +I RVV}%#);;#5#5cBFFl#CCy  ww}}T ''''""277<< 4#@AK ww; 23y@%fk:: ;;D e| ||~e|FND 6<<>'v.. 6;;  $If  :: !#Ie  :: !#Ie  << #!%Ig  << #!%Ig  <<>V\\^ww}}V__-'//||~ ggll9+-77??4+@+1??< !ggll9+1??< ''**;7Kww!!; ":;yH1&+FF rFc|Srr)rerfs rDrr2s MrFcPt||d}|r|jdi|ddiS|S)NFdeeprrjrrerfrhs rDrr5s1#FIu=Iv~~6 666 MrFcPt||d}|r|jdi|ddiS|S)NTrmFrrnros rDrr;s1#FItZd?Zd@Z dAZ!dBZ"dCZ#dDZ$dEZ%dFZ&dGZ'dHZ(dIZ)dJZ*dKZ+dLZ,dMZ-dNZ.dOZ/dPZ0dQZ1dRZ2dSZ3y%)VraInformational 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. rzName of the archive member.rzPermission bits.r3z6User ID of the user who originally stored this member.r4z7Group ID of the user who originally stored this member.r1zSize in bytes.r2zTime of last modification.chksumzHeader checksum.typezFile type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.rczcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.r5z User name.r6z Group name.devmajorzDevice major number.devminorzDevice minor number.rzThe 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_targetc||_d|_d|_d|_d|_d|_d|_t|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_i|_y)zXConstruct a TarInfo object. name is the optional name of the member. irrN)rrr3r4r1r2rsREGTYPErtrcr5r6rurvrr:r;rwrrs rDrzTarInfo.__init__ts}             rFc|jS)z(In pax headers, "name" is called "path".rrs rDr/z TarInfo.pathsyyrFc||_yrr~r|s rDr/z TarInfo.paths  rFc|jS)z0In pax headers, "linkname" is called "linkpath".rcrs rDr0zTarInfo.linkpathr'rFc||_yrr)rrcs rDr0zTarInfo.linkpaths   rFc`d|jj|jt|fzS)Nz<%s %r at %#x>)r?rridrs rD__repr__zTarInfo.__repr__s&4>>#:#:499RX"NNNrFT) rr2rrcr3r4r5r6rm_KEEPc | rtj|} ntj|} || ur|| _|| ur|| _|| ur|| _|| ur|| _|| ur|| _|| ur|| _|| ur|| _|| ur|| _ | S)zGReturn a deep copy of self with the given attributes replaced. ) copydeepcopyrr2rrcr3r4r5r6) rrr2rrcr3r4r5r6rmrresults rDrzTarInfo.replaces ]]4(FYYt_F u FK   FL u FK 5 &FO e FJ e FJ   FL   FL rFc|jd}n|jdz}|j||j|j|j|j |j |j|j|j|j|j|jd }|dtk(r!|djds |dxxdz cc<|S)z9Return the TarInfo's attributes as a dictionary. N) rrr3r4r1r2rsrtrcr5r6rurvrtrrW)rrr3r4r1r2rsrtrcr5r6rurvDIRTYPEr)rrinfos rDget_infozTarInfo.get_infos 99 D99v%D            <7 "4<+@+@+E LC L rFsurrogateescapec.|j}|jD]\}}| td|z|tk(r|j |||S|t k(r|j |||S|tk(r|j||Std)zr= LENGTH_LINKr< LENGTH_NAME_posix_split_name_create_headerr)rrrBrCs rDrzTarInfo.create_ustar_headers$W tJ&&x8 9K G34 4 tF|""8V4 5 C+/+A+A$v,PXZ`+a (DNDL""4xHHrFcZt|d<d}t|dj||tkDr||j |dt ||z }t|dj||t kDr||j |dt||z }||j|t||zS)z:Return the object as a GNU header block sequence. rrFrcr) GNU_MAGICr>r=r_create_gnu_long_headerGNUTYPE_LONGLINKrGNUTYPE_LONGNAMErr)rrrBrCrks rDrzTarInfo.create_gnu_headers"W  tJ&&x8 9K G 4//Z0@BRT\^de eC tF|""8V4 5 C 4//V >NPXZ`a aCT((z8VLLLrFc\t|d<|jj}ddtfddtfddfD];\}}}||vr ||j dd t|||kDs4||||<=d D]e\}}d }||} t| t} | r t| n| } d | cxkr d |dz zks nd ||<d}n | r| ||<d}|sS||vsXt| ||<g|r|j|t|} nd} | |j|tddzS#t $r ||||<YwxYw)zReturn the object as a ustar header block. If it cannot be represented this way, prepend a pax extended header sequence with supplement information. rrr/rcr0)r5r5 )r6r6rrRrS))r3rP)r4rP)r1 )r2rFrrPr-TrFr)rrwrrrr=UnicodeEncodeErrorr> isinstancefloatroundstr_create_pax_generic_headerXHDTYPErr) rrrBrwrhnamerAra needs_paxval val_is_floatval_intrks rDrzTarInfo.create_pax_headers~ $W &&++- - J /T&(>$@ D% # T !!'84 4:'%)$Z E"!$@(RLD&It*C%c51L$0eCjcG3! "33T  %T  T4$'H D!%R* 11+wQCCT((|WiPPPG& %)$Z E" sDD+*D+c0|j|tdS)zAReturn the object as a pax global header block sequence. r:)rXGLTYPE)clsrws rDcreate_pax_global_headerz TarInfo.create_pax_global_header?s--k7GLLrFcR|jd}tdt|D]t}dj|d|}dj||d}t|j ||t ksNt|j ||t ksq||fStd)zUSplit a name longer than 100 chars into a prefix and a name part. rWr-Nzname is too long)splitrVr>rr= LENGTH_PREFIXrr<)rrrBrC componentsr[rs rDrzTarInfo._posix_split_nameEsZZ_ q#j/*AXXj!n-F88JqrN+D6==623}D Hf56+Et|+/0 0rFch|jdttfv}|r;t|jddd|}t|jddd|}nt dd||}t dd||}|jdt }| t dt |jd dd ||t|jd dd zd|t|jd dd|t|jddd|t|jddd|t|jddd|d|t |jddd |||jdtt |jddd||t |jddd||||t |jddd||g}tjdtzdj|} t| t dd} | ddtd| zdz| ddz} | S) zReturn a header block. info is a dictionary with file information, format must be one of the *_FORMAT constants. rtrurrPrvrNzTarInfo.type must not be Nonerrrrr3r4r1rr2s rcrr5rr6rrz%dsrFiz%06orRi)getCHRTYPEBLKTYPErdrEr{r<rrirr rrnr^) rrbrBrChas_device_fieldsrurvfiletypepartsrkrss rDrzTarInfo._create_headerUs !HHV,'0BB 488J2Av>H488J2Av>H2q(F3H2q(F3H88FG,  <= = $c8V < #f,a 8 "Av . "Av . #R 0 !$b& 1   R(#x @ HHWk * "%r8V < "%r8V <   2&Xv > $kk%)+SXXe_=c9*+./2%4j5F!2G<r r?)payloadrzr{s rD_create_payloadzTarInfo._create_payloads9 #3w<; q=  I-4 4GrFc|j||tz}i}d|d<||d<t||d<t|d<|j |t |||j |zS)zTReturn a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence for name. z ././@LongLinkrrtr1r)r=r?r>rrrr)rrrtrBrCrs rDrzTarInfo._create_gnu_long_headerst {{8V,s2&V V 4yV !W !!$ hG##D)* *rFcd}|jD]\}} |jddd}|r|dz }|jD]\}}|jd}|r|j|d}n|jd}t|t|zdz}d x} } |tt | z} | | k(rn| } |t t | d d z|zd z|zd zz }i} d| d<|| d<t|| d<t | d<|j| td d|j|zS#t$rd}YwxYw)zReturn a POSIX.1-2008 extended or global header sequence that contains a list of keyword, value pairs. The values must be strings. Fr:rSTrFs21 hdrcharset=BINARY rrrrR = z././@PaxHeaderrrtr1rr) rr=rr>rr^rrrr) rrwrtrBbinarykeywordrrecordslrZrKrs rDrz"TarInfo._create_pax_generic_headers)//1NGU  Wh/2  0 0G)//1NGUnnW-G X/@A W-G s5z)A-AIACF O6  uSVW-4w>EMPUU UG!2('V V 7|V #W !!$ gyI##G,- -I&  sD99 E E clt|dk(r tdt|tk7r td|j t tk(r t dt|dd}|t|vr td|}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||}|j$t0k(r&|jj3dr t4|_|j$t6k(rxd}g}t9dD]@} t|||dz} t||dz|dz} |j=| | f|dz }Bt?|d} t|dd} || | f|_ |jCr |jjEd|_ |r)|j$tFvr|dz|jz|_ |S#t:$rYwxYw)zAConstruct a TarInfo object from a 512 byte bytes object. rz empty headerztruncated headerzend of file headerz bad checksumrlt|ii i)iIiQiYirWirriii)$r>rr rcountr?rr\rnrYrLrrr3r4r1r2rsrtrcr5r6rurvAREGTYPErrGNUTYPE_SPARSErVr<rboolrxrarstrip GNU_TYPES)rrkrBrCrsobjrrstructsr[rnumbytes isextendedorigsizes rDfrombufzTarInfo.frombufs s8q=">2 2 s8y &'9: : 99S>Y & !56 6SS\" c* *$^4 4es1Sz8V4s3s|$c#cl#c#cl#s3s|$C %  s3<3s3<6: C h7 C h7 3s3<( 3s3<( SS\8V4 88x CHH$5$5c$:CH 88~ %CG1X Sr!23F"3sRxb#9:H12r c#hJ3s3<(H#*J"AC  99;xxs+CH chhi/|chh.CH "s$%J&& J32J3c|jjt}|j||j|j }|jj tz |_|j|S)zOReturn the next TarInfo object from TarFile object tarfile. ) rrtr rrBrCrr _proc_member)rr=rkrs rD fromtarfilezTarInfo.fromtarfile s^ oo""9-kk#w//@__))+i7 ((rFc|jttfvr|j|S|jtk(r|j |S|jt ttfvr|j|S|j|S)zYChoose the right processing method depending on the type and call it. ) rtrr _proc_gnulongr _proc_sparserrSOLARIS_XHDTYPE _proc_pax _proc_builtin)rr=s rDrzTarInfo._proc_member!sx 99)+;< <%%g. . YY. ($$W- - YY7G_= =>>'* *%%g. .rFc|jj|_|j}|js|jt vr||j |jz }||_|j|j|j|j|jr |jjd|_|S)zfProcess a builtin type or an unknown type which will be treated as a regular file. rW)rrr:r_rtSUPPORTED_TYPES_blockr1r_apply_pax_inforwrBrCrarr)rr=rs rDrzTarInfo._proc_builtin.s#??//1!! ::<499O; dkk$)), ,F W00'2B2BGNNS ::< ((-DI rFcF|jj|j|j} |j |}|j|_|jtk(r't||j|j|_n9|jtk(r&t||j|j|_|j#r |jj%d|_|S#t $r}t t|dd}~wwxYw)zSProcess the blocks that hold a GNU longname or longlink member. NrW)rrtrr1rr rrrrtrrLrBrCrrrcra removesuffix)rr=rknextrs rDrzTarInfo._proc_gnulongDsoo""4;;tyy#9: :##G,D kk 99( (C!1!17>>BDI YY* *W%5%5w~~FDM ::< ..s3DI ! :'A/T 9 :sC== D DD c |j\}}}|`|r|jjt}d}t dD]D} t |||dz}t ||dz|dz} |r| r|j|| f|dz }Ft|d}|r||_ |jj|_ |j|j|jz|_||_ |S#t $rYywxYw)z8Process a GNU sparse header plus extra headers. rrri)rxrrtr rVr\r<rrr;rr:rr1r) rr=rrrrkrr[rrs rDrzTarInfo._proc_sparse_s )-(<(<%X  //&&y1CC2Y Sr!23F"3sRxb#9:HhNNFH#56r c#hJ "??//1))DKK ,BB  "s%C55 DDc|jj|j|j}|jt k(r |j }n|j j}d}d}g}t||kDr||dk7rtj||x}s td t|jd}|dkr td||zt|kDr td|jd|zdz } ||j!ddz| } | j#d\} } } | r | dk7s|| dk7r td|j%|| | f| dk(r|| d k(r |j&}nd }||z }t||kDr ||dk7r|d }|D]x\}} } |j)| d d |j*}|t,vr)|j)| ||j&|j*}n|j)| d d |j*}|||<z |j/|}d |vr|j7||nRd |vr|j9||n;|j;d dk(r'|j;ddk(r|j=||||jt>t@fvr|jC||j&|j*|jD|_"d|vrS|jF}|jIs|jtJvr||j|jz }||_"|S#t$r tdwxYw#t0$r}t3t5|dd}~wwxYw)zVProcess an extended or global header as described in POSIX.1-2008. rNrUr-rrs hdrcharsetsBINARYr:GNU.sparse.mapGNU.sparse.sizezGNU.sparse.major1zGNU.sparse.minorrTr1)&rrtrr1rtrrwrr>_header_length_prefix_rematchrYrWgroupr<r2r partitionrrB_decode_pax_fieldrCPAX_NAME_FIELDSrr rr_proc_gnusparse_01_proc_gnusparse_00r_proc_gnusparse_10rrrrr:r_r)rr=rkrwrrB raw_headersrrAheader_value_end_offsetkeyword_and_value raw_keywordequals raw_valuerrrrrs rDrzTarInfo._proc_pax{s oo""4;;tyy#9: 99 !--K!--224K  #hnST!15;;CEEEE()9:: ;U[[^, z()9::V|c#h&()9::&+kk!nv&=&A # #EIIaL1$45L M ->-H-H-N *K&D.C8O4PTX4X()9::    Y? @m+0@ )&//H&H 6MCM#hnST!1R  H/: *FK,,['7NN$G/)..y(GDTDT(..y'7($)K #/:( :##G,D { *  # #D+ 6 + -  # #D+ 6 __/ 0C 7KOOL^<_cf.> O++DK$))::<499O#Cdkk$))44F!' y ;()9:: ;| :'A/T 9 :s$1M"MM N&M;;Ncrg}g}|D]d\}}}|dk(r* |jt|j6|dk(s< |jt|jft t |||_y#t$r t dwxYw#t$r t dwxYw)z?Process a GNU tar extended sparse header, version 0.0. sGNU.sparse.offsetrUsGNU.sparse.numbytesN)rrWrJr<rYlistzipr;)rrroffsetsr_rrs rDrzTarInfo._proc_gnusparse_00s!, Aw..?NN3u||~#6722?OOC $78"-3w12 "?,-=>>? "?,-=>>?s(B (B! B!B6c |djdDcgc] }t|}}tt|ddd|ddd|_ycc}w)z?Process a GNU tar extended sparse header, version 0.1. r,Nr.r-)rrWr r r;)rrrwxr;s rDrzTarInfo._proc_gnusparse_01sZ#..>"?"E"Ec"JK"JQ#a&"JK3vcc{F14a4L9: LsAc d}g}|jjt}|jdd\}}t |}t ||dzkrgd|vr"||jjtz }|jdd\}}|j t |t ||dzkrg|jj|_tt|ddd|ddd|_ y)z?Process a GNU tar extended sparse header, version 1.0. Nrr-r.) rrtr rrWr>rrr:r r r;)rrrwr=fieldsr;rknumbers rDrzTarInfo._proc_gnusparse_10soo""9-iiq) V&kFQJ&Cw++I66))E1-KFC MM#f+ & &kFQJ& #??//13vcc{F14a4L9: rFc|jD]\}}|dk(rt|d||dk(rt|dt|5|dk(rt|dt|Q|tvsZ|tvr t ||}|dk(r|j d}t||||j|_y#t $rd}YHwxYw) zoReplace fields with supplemental information from a previous pax extended or global header. zGNU.sparse.namer/rr1zGNU.sparse.realsizerrWN) rsetattrrW PAX_FIELDSPAX_NUMBER_FIELDSr<rrrw)rrwrBrCrrs rDrzTarInfo._apply_pax_infos*//1NGU++fe,--fc%j111fc%j1J&//" 1' :5 Af$!LL-Egu-2"'++- &" !"s4B== C  C cj |j|dS#t$r|j||cYSwxYw)z1Decode a single field from a pax record. rS)rJUnicodeDecodeError)rrrBfallback_encodingfallback_errorss rDrzTarInfo._decode_pax_field5s< D<<(3 3! D<< 1?C C Ds 22cHt|t\}}|r|dz }|tzS)z_Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. r-)rsr )rrrzr{s rDrzTarInfo._block=s,#5)4  aKF !!rFc&|jtvSz4Return True if the Tarinfo object is a regular file.)rt REGULAR_TYPESrs rDr_z TarInfo.isregFsyyM))rFc"|jSr)r_rs rDisfilezTarInfo.isfileJszz|rFc(|jtk(S)z!Return True if it is a directory.)rtrrs rDraz TarInfo.isdirNyyG##rFc(|jtk(S)z%Return True if it is a symbolic link.)rtSYMTYPErs rDrbz TarInfo.issymRr$rFc(|jtk(S)z!Return True if it is a hard link.)rtLNKTYPErs rDr`z TarInfo.islnkVr$rFc(|jtk(S)z(Return True if it is a character device.)rtrrs rDischrz TarInfo.ischrZr$rFc(|jtk(S)z$Return True if it is a block device.)rtrrs rDisblkz TarInfo.isblk^r$rFc(|jtk(S)zReturn True if it is a FIFO.)rtFIFOTYPErs rDisfifozTarInfo.isfifobsyyH$$rFc|jduSr)r;rs rDissparsezTarInfo.issparsefs{{$&&rFc<|jtttfvS)zCReturn True if it is one of character device, block device or FIFO.)rtrrr.rs rDisdevz TarInfo.isdevisyyWgx888rFr)r)4rrrrdict __slots__rpropertyr/setterr0rrrrrr rrrr classmethodrr staticmethodrrrrrrrrrrrrrrrrrr_r"rarbr`r*r,r/r1r3rrFrDrrQs , ! G H    -  $ > F   * *! "/# $5% &9' *.+ ,- ./ 01 I60 [[__!!O%eeuE88*HEV/" I M8QtMM  ''R** 0-0-d<<|))( /,68wr3(; ; ..D"*$$$$$%'9rFrceZdZdZdZdZdZdZeZ e Z dZ e ZeZdZ d8dZedddefdZed9d Zed:d Zed:d Zed;d Zd ddddZdZdZdZdZddddZ!d?dZ"dZ#d@ddddZ$dAddddZ%d Z&d!Z'd"Z(d#Z)d$Z* dBd%Z+d&Z,d'Z-d(Z.d)Z/d*Z0d+Z1d,Z2d-Z3d.Z4d/Z5dCd0Z6d1Z7d?d2Z8d3Z9d4Z:d5Z;d6Z dereference ignore_zerosrBrCrrwdebug errorlevel copybufsizermembers_loadedrrinodes firstmemberrrrrrr rrrrur>r)rrrrrbr>rGrHrBrCrwrIrJrKmodesrrks rDrzTarFile.__init__sT= u @A A 4[ yyCt(< ! djj1G$D  &!97<<#u6||w'$\\ #D -1BGGOOD)t     DK  "DL  "*D   # ,D   $DM  "t{{j'@*D !D   DJ  !(DO'   ll'')   yyC#' #'99; yyCLL%%dkk2:"&,,":":4"@ ++G4 yyO+# ##,,??@P@P@U@U@WXCLL&&s+KK3s8+K$, * ))$++6&:'A/T9: ## ""$DK s>>A L;6K&BL;&.L8L;L8L33L88L;;0M+c |s |s td|dvrzfd}g}tj|D]:}tj|} ||j } | |d|fi|cSd j|} t d | d |vrb|jd d \} }| xsd} |xsd }|jvrtj|} nt d|z| || |fi|Sd|vrg|jdd \} }| xsd} |xsd }| dvr td|jdd}t|| ||||} || |fi|}d|_|S|dvrj|||fi|Std#t t f$r5} |jd|d| ||j Yd} ~ d} ~ wwxYw#|jxYw)aOpen 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)rr:*c(j|dk(S)Ntaropen) OPEN_METH)rrs rDnot_compressedz$TarFile.open..not_compressed#s}}X.);;rF)keyNrz - method z:  z'file could not be opened successfully: :r-rr|rzmode must be 'r' or 'w'r FrBzundiscernible mode)r<sortedrUrrrr rrrrpoprrrrT)rrrrrykwargsrV error_msgsrfunc saved_posrerror_msgs_summaryfilemoderstreamrs` rDrz TarFile.opens5JG./ / <  <J"3==nEsCMM($;<& ' Ic7=f== F"&:!6 FGYFZ[\ \ D[!%C!3 Hh3H(5H3==(sCMM($;<&'Dx'OPPh:6: : D[!%C!3 Hh3H(5Hz) !:;;"JJ:MT8Xw*,F h9&9"AMH _ $3;;tT7=f= =-..W"#34%% (2aU&CD* Y/ D  s$" F G G*GG Gc 6|dvr td||||fi|S)zCOpen uncompressed tar archive name for reading or writing. r?rA)r<)rrrrr^s rDrTzTarFile.taropenYs- + +@A A4w1&11rFc |dvr td ddlm} |||dz||} |j|||fi|}d |_ |S#t$r t ddwxYw#t $r}||dk(r t d |d}~wwxYw#t $r'}|j|dk(r t d |d}~w|jxYw) zkOpen gzip compressed tar archive name for reading or writing. Appending is not allowed. rrrmode must be 'r', 'w' or 'x'r)GzipFilezgzip module is not availableNr|rrF) r<gziprirr rrrTrr) rrrrrr^rirrs rDgzopenzTarFile.gzopenas  &;< < M % tTCZHG  D$:6:A + M"#AB L M  "ts{ 129    MMOs{ 129   MMO s9AABA B'A;;B C "B..Cc P|dvr td ddlm}||xs|||} |j |||fi|}d |_ |S#t$r t ddwxYw#t tf$r'}|j|dk(r td |d}~w|jxYw) zlOpen bzip2 compressed tar archive name for reading or writing. Appending is not allowed. rgrhr)BZ2FilerN)rrznot a bzip2 fileF) r<rrmrr rTrEOFErrorrrr) rrrrrr^rmrrs rDbz2openzTarFile.bz2opens  &;< < L #'/T4}M  D$:6:A ! L"#@At K L"  MMOs{ 23:   MMO s"AAAB%-"BB%c L|dvr td ddlm}m}||xs|||} |j |||fi|}d |_ |S#t$r t ddwxYw#|tf$r'} |j|dk(r td | d} ~ w|jxYw) zkOpen lzma compressed tar archive name for reading or writing. Appending is not allowed. rgrhr)LZMAFilerrN)presetrznot an lzma fileF) r<rrqrrr rTrnrrr) rrrrrrr^rqrrrs rDxzopenzTarFile.xzopens  &;< < M 07?dD@  D$:6:A ! M"#AB L M8$  MMOs{ 23:   MMO s"AA A B#+"B  B#rTrkrors)rrrrc|jryd|_ |jdvr|jjtt dzz|xj t dzz c_t|j t\}}|dkDr)|jjtt|z z|js|jjyy#|js|jjwwxYw)zlClose the TarFile. In write-mode, two finishing zero blocks are appended to the archive. NTrBr.r) rrrrur?r rrs RECORDSIZErr)rrzr{s rDrz TarFile.closes ;;   %yyO+ ""3)a-#89 A . %+4;; $C! q=LL&&sj9.D'EF## ""$$4## ""$$s BC)Dcf|j|jd}|td|z|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. rWzfilename %r not found) _getmemberrKeyError)rrr>s rD getmemberzTarFile.getmembers6 //$++c"23 ?2T9: :rFcr|j|js|j|jS)zReturn the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive. )_checkrM_loadrLrs rD getmemberszTarFile.getmemberss' || JJL||rFc\|jDcgc]}|jc}Scc}w)zReturn the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). )r}r)rr>s rDgetnameszTarFile.getnamess)-1OO,=>,= ,=>>>s)c.|jd| |j}||}tjj |\}}|j tj d}|jd}|j}||_ |8|jstj|}n9tj|}n#tj|j}d}|j}tj |r|j"|j$f} |jsE|j&dkDr6| |j(vr(||j(| k7rt*} |j(| }nt,} | dr||j(| <ntj.|rt0} ntj2|rt4} njtj6|rt8} tj:|}n9tj<|rt>} ntj@|rtB} ny||_||_"|jF|_$|jJ|_&| t,k(r|jN|_(nd|_(|jR|_*| |_+||_,tZr( t[j\|jHd|_/tbr( tcjd|jLd|_3| t>tBfvrhtitdrXtitdrHtjj|jl|_7tjp|jl|_9|S#t`$rYwxYw#t`$rYwxYw) aCreate 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. awxNrWrr-rmajorminor):r{rrr/ splitdriverr[r\r>r=rGlstatstatfstatfilenost_modeS_ISREGst_inost_devst_nlinkrNr(r{S_ISDIRrS_ISFIFOr.S_ISLNKr&readlinkS_ISCHRrS_ISBLKrrst_uidr3st_gidr4st_sizer1st_mtimer2rtrcpwdgetpwuidr5rxgrpgetgrgidr6rrst_rdevrurrv) rrarcnamerdrvr>statresrcstmdinoderts rD gettarinfozTarFile.gettarinfos E  < zlink to )r{rrrrcr5r3r6r4r*r,rurvr1r2r localtimerrarbrcr`r)rverboserLr>s rDr z TarFile.listXsf ?GG<<' - gll ;<w}}'C 'C'.}}'C 'CEF==?gmmo$(8(8':J:J'KK!MN  56==( 56 ="&.."?"C!DE  w}}BG H==?(8(8 89==? W-=-= => G5rFfiltercb|jd||}|jBtjj ||jk(r|j dd|zy|j d||j ||}||j dd|zy| ||}||j dd|zy|jr(t|d5}|j||dddy|jr|j||ruttj|D]S}|jtjj||tjj|||| Uyy|j|y#1swYyxYw) 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. rNr.ztarfile: Skipped %rr-ztarfile: Unsupported type %rtarfile: Excluded %rr<r)r{rrr/rF_dbgrr_rEaddfilerar\listdiraddr)rrr recursiverr>fs rDrz TarFile.add~sq E ?G 99 RWW__T%:dii%G IIa.5 6  !T//$0 ? IIa7$> ?   WoG !3d:; ==?4&! Wa('&]]_ LL ! 4 01AHHRWW\\$2BGGLL!4L%f62 LL !'&s F%%F.c|jdtj|}|j|j|j|j }|j j||xjt|z c_|j}|t||j |j|t|jt\}}|dkDr.|j jtt|z z|dz }|xj|tzz c_|j j#|y)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(). rN)ryrr-)r{rrrbrBrCrrurr>rKrrr1rsr r?rLr)rr>rrkryrzr{s rDrzTarFile.addfiles E))G$mmDKK D 3 s3x      w||W M &w||Y ? FI1} ""3)i*?#@A!  KK6I- -K G$rFc|M|j}|"tjdtdtSt |t r td|St|r|S t|S#t$rtd|ddwxYw)NzPython 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.r) stacklevelzrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.zfilter z not found) extraction_filterwarningswarnDeprecationWarningrrr TypeErrorcallable_NAMED_FILTERSrxr<)rrs rD_get_filter_functionzTarFile._get_filter_functions >++F~ J'1 6 ,+&#&677M F M G!&) ) Gwvj ;<$ F Gs A''B) numeric_ownerrc@g}|j|}||}|D]]}|j|||}||jr|j||j |||j |_|j dd|D]e}t jj||j} |j|| ||j|| |j|| gy#t$r} |j| Yd} ~ d} ~ wwxYw)aExtract 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_attrsrc|jSrr~)r@s rDz$TarFile.extractall.. sqvvrFT)rWreverse)r)r_get_extract_tarinforar _extract_onesortrr/rrchownutimechmodr _handle_nonfatal_error) rr/rLrr directoriesfilter_functionrer>dirpathrs rD extractallzTarFile.extractalls 33F; ?GF//NG}}""7+   gt7==?7J,9  ; -t<#Gggll46G / 7G= I 7G, 7G, #   /++A.. /s>8C99 DDDcz|j|}|j|||}||j||||yy)aExtract 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)rrer/rrrrr>s rDextractzTarFile.extract sG33F;++FOTJ     gtY F rFct|tr|j|}n|}|} |||}| |jdd|jzy|jrDtj|}tjj||j|_|S#ttf$r}|j |Yd}~d}~wt $r}|j|Yd}~d}~wwxYw)z@Get filtered TarInfo (or None) from member, which might be a strNr.r)rrryrr_handle_fatal_errorr rrrr`rrr/rrcry)rrerr/r> unfilteredrs rDrzTarFile._get_extract_tarinfo! s fc "nnV,GG  +%gt4G ? IIa/*//A B ==?ii(G#%77<<g6F6F#GG % (  $ $Q ' ' +  ' ' * * +s# B))C58C C5C00C5c4|jd |j|tjj ||j ||y#t $r}|j|Yd}~yd}~wt$r}|j|Yd}~yd}~wwxYw)z%Extract from filtered tarinfo to diskrrN) r{_extract_memberrr/rrrrr r)rr>r/rrrs rDrzTarFile._extract_one8 s C +  "'',,tW\\*J+4/< ! > (  $ $Q ' ' +  ' ' * * +s#=A BA00 B<BBcN|jdkDr|jdd|zy)z=Handle non-fatal error (ExtractError) according to errorlevelr- tarfile: %sN)rJrrrs rDrzTarFile._handle_nonfatal_errorE s$ ??Q   IIa* +rFcL|jdkDrt|trY|j |j dd|j zy|j dd|j d|jy|j ddt |jd|y)z1Handle "fatal" error according to self.errorlevelrNr-rz tarfile: r)rJrrfilenamerstrerrorrtrrs rDrzTarFile._handle_fatal_errorL st ??Q   7 #zz! !]QZZ78 !QZZHI IIaT!W-=-=qA BrFc|jdt|tr|j|}n|}|j s|j t vr|j||S|js|jrEt|jtr td|j|j|Sy)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. rz'cannot extract (sym)link as file objectN)r{rrryr_rtr fileobjectr`rbrrr extractfile_find_link_target)rrer>s rDrzTarFile.extractfileX s C fc "nnV,GG ==?gll/A??41 1 ]]_ $,,0""KLL''(>(>w(GHHrFc|jd}|jdtj}tjj |}|r4tjj |stj||js|jr,|jd|jd|jn|jd|j|jr|j||n|jr|j!||n|j#r|j%||n|j's|j)r|j+||nj|js|jr|j-||n7|j.t0vr|j3||n|j|||rI|j5||||js%|j7|||j9||yyy)z\Extract the TarInfo object tarinfo to a physical file called targetpath. rWr-z -> N)rrrr[r/rdrDmakedirsr`rbrrrcr_makefileramakedirr/makefifor*r,makedevmakelinkrtr makeunknownrrr)rr> targetpathrr upperdirss rDrzTarFile._extract_memberx s &&s+ ''RVV4 GGOOJ/ RWW^^I6 KK " ==?gmmo IIaw||W5E5EF G IIa & ==? MM': . ]]_ LL* - ^^  MM': . ]]_  LL* - ]]_  MM': . \\ 0   Wj 1 MM': .  JJw M :==? 7J/ 7J/# rFc |jtj|ytj|dy#t$r#tjj |sYywxYw)z,Make a directory called targetpath. Ni)rrmkdirFileExistsErrorr/rarr>rs rDrzTarFile.makedir sT ||#$U+ 77==,- s!;;)A'&A'c |j}|j|j|j}t |d5}|j d|j D])\}}|j|t |||t|+|j|j|jnt |||jt|dddy#1swYyxYw)z'Make a file called targetpath. r=N) rrr:rKrEr;rrrr1truncate)rr>rsourcerytargetrr1s rDrzTarFile.makefile s G''("" z4 (F~~)$+NNLFDKK'iI%3 GLL)!FFGLL)WM) ( (s BCC cf|j|||jdd|jzy)zYMake a file from a TarInfo object with an unknown type at targetpath. r-z9tarfile: Unknown file type %r, extracted as regular file.N)rrrtrs rDrzTarFile.makeunknown s3 gz* !24;LLA BrFcdttdrtj|ytd)z'Make a fifo called targetpath. mkfifozfifo not supported by systemN)rrrr rs rDrzTarFile.makefifo s& 2x IIj !=> >rFcfttdrttds td|j}|d}|j r|t j z}n|t jz}tj||tj|j|jy)zrrs rDrzTarFile.makedev sr7#72y+AHI I|| <D ==? DLL D DLL D TG,,g.>.>? ArFc: |jrUtjj|rtj|tj |j |ytjj|jr!tj|j|y|j|j||y#t$r> |j|j||Yy#t$r tddwxYwwxYw)zMake 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. z%unable to resolve link inside archiveN)rbrr/lexistsunlinksymlinkrcrDrylinkrrsymlink_exceptionrxr rs rDrzTarFile.makelink s  V}}77??:.IIj) 7++Z877>>'"6"67GGG00*=(()?)?)H)35  V V$$T%;%;G%D%/1 V"#JKQUU V  Vs+A$C'A C1!C D!DDDcttdrtjdk(r|j}|j}|sj t r.|j r"t j|j d} tr.|jr"tj|jd}|d}|d} |jr(ttdrtj|||ytj|||yyy#t$rYwxYw#t$rYuwxYw#t$r}t!d|d}~wwxYw)zSet owner of targetpath according to tarinfo. If numeric_owner is True, use .gid/.uid instead of .gname/.uname. If numeric_owner is False, fall back to .gid/.uid when the search based on name fails. geteuidrr.NrHlchownzcould not change owner)rrrr4r3rr6getgrnamrxrr5getpwnamrbrrrr )rr>rrgurs rDrz TarFile.chown s 2y !bjjla&7 A A w}}LL7:w}}LL7:yy D==?wr8'<IIj!Q/HHZA./'8 !    D"#;rrs rDrz TarFile.chmod$ sF <<   ? HHZ . ?67Q > ?s 0 A  AA c|j}|yttdsy tj|||fy#t$r}t d|d}~wwxYw)zBSet modification time of targetpath according to tarinfo. Nrz"could not change modification time)r2rrrrr )rr>rr2rs rDrz TarFile.utime. sZ  = r7#  L HHZ% 0 LCD! K Ls; A AAcL|jd|j|j}d|_|S|j|jj k7r^|jdk(ry|jj |jdz |jj ds tdd} |jj|} ||j0j3||Sd|_|S#t$rU}|jr?|jdd|j|fz|xjtz c_Yd}~Yd}~d}~wt$rz}|jr?|jdd|j|fz|xjtz c_Yd}~|jdk(rtt|dYd}~d}~wt $r|jdk(r td dY-t"$r/}|jdk(rtt|dYd}~_d}~wt$$r}tt|dd}~wt&$r@} ddl}t+||j,rtd |d|#t.$r|wxYwd}~wwxYw) zReturn the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. raNrr-rpTr.z0x%X: %sz empty filez zlib error: )r{rOrrrrrtrr>rrrHrr rYrrrr ExceptionrrrrrLrrM)rmr>rrs rDrz TarFile.next< sR D    '  A#D H ;;$,,++- -{{a LL  dkkAo .<<$$Q' 899 ,,2248<    LL   ( DLI" $$IIat{{A.>!>?KK9,K%& 6$$IIat{{A.>!>?KK9,K[[A%#CF+5&# <;;!##L1t;$' 6;;!##CF+5$( 2A'T1 !!TZZ0',qc(:;E"G sb<D J# AE J#%AG0$G'J#J# $H66 J#I J#$+J JJJ#c|j}d}| |j|}|d|}|rtjj |}t |D]a}|r|j|jk(rd}!|r*tjj |j}n |j}||k(s_|cS|r t|y#t$rd}YwxYw)z}Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. FNT) r}indexr<rr/normpathreversedrr) rrr> normalizerLskippingr re member_names rDrwzTarFile._getmember} s //#   * g."&5/ 77##D)Dw'F>>V]]2$H gg..v{{; $kk {" ( W% % 1   sC CCcV|j |jd|_y)zWRead through the entire archive file and look for readable members. NT)rrMrs rDr|z TarFile._load s(iik% iik% rFc|jr"td|jjz|'|j|vrtd|jzyy)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)rrr?rr)rrs rDr{zTarFile._check sS ;;.4>>+B+BBC C    55 AB B!6 rFc,|jrQdjtdtjj |j |jf}d}n|j}|}|j||d}|td|z|S)zZFind the target member of a symlink or hardlink member in the archive. rWNT)r>rzlinkname %r not found) rbrrrr/rdrrcrwrx)rr>rclimitres rDrzTarFile._find_link_target s ==?xxtbggoogll.KWM]M]-^ _`HE''HE5DI >2X=> > rFc#RK|jr|jEd{yd}|j|j}|dz }| |t |jkr|j|}n'|js|j}|s d|_yy|dz }|Y7w)z$Provide an iterator object. Nrr-T)rMrLrOrr>)rr r>s rD__iter__zTarFile.__iter__ s <<|| # #     'iikG QJEMs4<<((,,u-\\))+#'DL QJEM $sB'B%BB'cZ||jkrt|tjyy)z.Write debugging output to sys.stderr. fileN)rIrrstderr)rlevelmsgs rDrz TarFile._dbg s# DJJ  #CJJ ' rFc&|j|Sr)r{rs rD __enter__zTarFile.__enter__ s  rFc||jy|js|jjd|_yr)rrrr)rrtr tracebacks rD__exit__zTarFile.__exit__ s2 < JJL## ""$DKrF) NrNNNNNNrNNNN)rN)rNr[)rNN)NNNTrr).N)rT)TFr")>rrrrrIrGrHrJrrbr rBrCrr>r8rrrr8rurrTrkrorsrUrryr}rrr rrrrrrrrrrrrrrrrrrrrrrwr|r{rrrrr!rrFrDrrns EKLJFH FGJAEHL>B)-b^#tZ]/]/~22@6: I%* ? aF$D$L1"1"f%2G.+/%+/ZGG&. +, C@>B&+*0b N B?A$V2DB? L<B&&PC&>( rFrc t|dr.|j}t|}|j|n t|}|j y#t $rYywxYw)zReturn 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. rt)rTF)rrrrrr)rrrs rDrr sX  4 ))+CT"A IIcNT A   sAA A$#A$c ddl}d}|j|}|jddddd |jd d td |j d}|jdddd|jddddd|jddddd|jdd dd!|j }|j r|j|jd"d#|j|j}t|rut|d$5}|jt|jtj%ddd|j r=td&j#|y|jd"d'j#|yy|j$u|j$}t|rzFilter for extraction)metavarchoicesr*T)requiredz-lz--list zShow listing of a tarfile)r+r*z-ez --extract+)r.z zExtract tarfile into target dir)nargsr+r*z-cz--create)zzzCreate tarfile from sourcesz-tz--testzTest if a tarfile is validr-z&--filter is only valid for extraction rrz{!r} is a tar archive.z{!r} is not a tar archive. rR)rr.)r/rr#z{!r} file is extracted.z+{!r} file is extracted into {!r} directory.rrr)rz.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:rz{!r} file created.)argparseArgumentParser add_argumentradd_mutually_exclusive_group parse_argsrrexittestrrr}rrrrrbr rr>rcurdir format_helprcreater]r/splitextr)r1r&parserrargsrvrtfr8rtar_namerext compressionstar_mode tar_files file_names rDmainrE sGK  $ $ $ =F k,-/  N .46  / / / >E tX{79 t[<=? tZs39; tX{8:    D {{t||+ A@A yyii c?c33 cnn&SZZ8 ||.55c:; KK9@@E F  ii c?c5)R -*) KK9@@E F  ! t||  !,,q/CYYF  ! #,,KC KK6--/ 0 c?c5)R 6$++ >*||S=3::3?C2396#v3Fc KK9@@E F  ;;??1%!!(+3  03l/B4,s++KK \\(H -& y!'. << &--h7 8 / !M *)*)>. -s0:P-P:Q"Q-P7:QQQ__main__r")lrversion __author__ __credits__builtinsrrErrr)rqrrrirrerrrrAttributeErrorNotImplementedErrorrr__all__r?r rurrrrrr{rr(r&rrrr.CONTTYPErrrrrrrrrrrr rrrrrWrrr getfilesystemencodingrErLr\rdrnrrrrrr rr r r rrrrYrrrobjectrrBufferedReaderr8rrrrrrrjrrrrrcompilerrrrrErrrFrDrTs:6 H ' $%8'B *   ^                    HgGXWg#%5! #(>+ /   . 9       77d?H(s((*H 0& (N < *"&$ 2 y  8    x  (  (  {  ;  [    K 0rrj6