HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.7/__pycache__/tarfile.cpython-37.pyc
B

{aj@srdZdZdZdZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZyddlZWnek
rdZYnXyddlZWnek
rdZYnXeefZyeef7ZWnek
rYnXddd	d
ddd
ddddddddgZdZdZedZdZdZdZdZdZ 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*Z/dZ0d+Z1d,Z2e1Z3e!e"e#e$e'e(e)e%e&e*e+e,fZ4e!e"e)e,fZ5e*e+e,fZ6d-Z7d.d/d0d1hZ8e9e9e9e:e:e:d2Z;ej<d3krd4Z=ne>Z=d5d6Z?d7d8Z@d9d:ZAd;e3fd<d=ZBd>d?ZCdedfd@dAZDdBdCZEdDdEZFGdFd
d
eGZHGdGddeHZIGdHddeHZJGdIddeHZKGdJd
d
eHZLGdKddeHZMGdLdMdMeMZNGdNdOdOeMZOGdPdQdQeMZPGdRdSdSeMZQGdTdUdUeMZRGdVdWdWZSGdXdYdYZTGdZd[d[eUZVGd\d]d]eUZWGd^d_d_e	jXZYGd`ddeUZZGdaddeUZ[dbd	Z\e[jZdcddZ]e^dekrne]dS)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.)openNTarFileTarInfo
is_tarfileTarError	ReadErrorCompressionErrorStreamErrorExtractErrorHeaderErrorENCODINGUSTAR_FORMAT
GNU_FORMAT
PAX_FORMATDEFAULT_FORMATrisustar  sustar00d01234567LKSxgX)pathlinkpathsizemtimeuidgidunamegnamer%r&r+r,)ZatimeZctimer(r)r*r'ntzutf-8cCs(|||}|d||t|tS)z8Convert a string to a null-terminated bytes object.
    N)encodelenNUL)slengthencodingerrorsr5/usr/lib/python3.7/tarfile.pystnsr7cCs*|d}|dkr|d|}|||S)z8Convert a null-terminated bytes object to a string.
    rN)finddecode)r1r3r4pr5r5r6ntss
r<cCs|ddkrfd}x0tt|dD]}|dK}|||d7}q"W|ddkrdt|d|}n@y"t|dd}t|pd	d}Wntk
rtd
YnX|S)z/Convert a number field to a python number.
    r)r#r>asciistrict0zinvalid header)ranger/r<intstrip
ValueErrorInvalidHeaderError)r1nir5r5r6ntisrKr?cCst|}d|kr$d|dkrDnntd|d|fdt}n|tkrd|d|krrd|dkrnnZ|dkrtdg}ntdg}d||}x6t|dD]}|d|d@|dL}qWntd	|S)
z/Convert a python number to a number field.
    rr?r#z%0*orAr@r=r>zoverflow in number field)rEbytesr0r	bytearrayrDinsertrG)rIdigitsformatr1rJr5r5r6itns 2
rQcCs0dttd|}dttd|}||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.
    r@Z
148B8x356BZ
148b8x356b)sumstructZunpack_from)bufZunsigned_chksumZ
signed_chksumr5r5r6calc_chksumss	rUc	Cs|pd}|dkrdS|dkr.t|||dSt||\}}x8t|D],}||}t||krh|d||qFW|dkr||}t||kr|d||dS)zjCopy length bytes from fileobj src to fileobj dst.
       If length is None, copy the entire content.
    i@rNzunexpected end of data)shutilcopyfileobjdivmodrDreadr/write)	srcdstr2	exceptionbufsizeblocks	remainderbrTr5r5r6rWs$


rWcCs ddl}|dtdt|S)z/Deprecated in this location; use stat.filemode.rNz$deprecated in favor of stat.filemoder$)warningswarnDeprecationWarningstatfilemode)moderbr5r5r6rfsrfcCs8ttjdd}|dk	r(||d|}t|dddS)Nr3backslashreplace )end)getattrsysstdoutr.r:print)r1r3r5r5r6_safe_print
sroc@seZdZdZdS)rzBase exception.N)__name__
__module____qualname____doc__r5r5r5r6rsc@seZdZdZdS)r
z%General exception for extract errors.N)rprqrrrsr5r5r5r6r
sc@seZdZdZdS)rz&Exception for unreadable tar archives.N)rprqrrrsr5r5r5r6rsc@seZdZdZdS)rz.Exception for unavailable compression methods.N)rprqrrrsr5r5r5r6rsc@seZdZdZdS)r	z=Exception for unsupported operations on stream-like TarFiles.N)rprqrrrsr5r5r5r6r	sc@seZdZdZdS)rz!Base exception for header errors.N)rprqrrrsr5r5r5r6r sc@seZdZdZdS)EmptyHeaderErrorzException for empty headers.N)rprqrrrsr5r5r5r6rt#srtc@seZdZdZdS)TruncatedHeaderErrorz Exception for truncated headers.N)rprqrrrsr5r5r5r6ru&sruc@seZdZdZdS)EOFHeaderErrorz"Exception for end of file headers.N)rprqrrrsr5r5r5r6rv)srvc@seZdZdZdS)rHzException for invalid headers.N)rprqrrrsr5r5r5r6rH,srHc@seZdZdZdS)SubsequentHeaderErrorz3Exception for missing and invalid extended headers.N)rprqrrrsr5r5r5r6rw/srwc@s0eZdZdZddZddZddZdd	Zd
S)
_LowLevelFilezLow-level file object. Supports reading and writing.
       It is used instead of a regular file object for streaming
       access.
    cCsFtjtjtjBtjBd|}ttdr2|tjO}t||d|_dS)N)rwO_BINARYi)	osO_RDONLYO_WRONLYO_CREATO_TRUNChasattrr{rfd)selfnamergr5r5r6__init__<s

z_LowLevelFile.__init__cCst|jdS)N)r|closer)rr5r5r6rEsz_LowLevelFile.closecCst|j|S)N)r|rYr)rr'r5r5r6rYHsz_LowLevelFile.readcCst|j|dS)N)r|rZr)rr1r5r5r6rZKsz_LowLevelFile.writeN)rprqrrrsrrrYrZr5r5r5r6rx6s
	rxc@steZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
ddZdddZdddZ
ddZddZdS)_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 and is accessed
       blockwise.  Use of gzip or bzip2 compression is possible.
       A stream-like object could be for example: sys.stdin,
       sys.stdout, a socket, a tape device etc.

       _Stream is intended to be used only internally.
    c	Csd|_|dkrt||}d|_|dkr6t|}|}|p<d|_||_||_||_||_d|_	d|_
d|_yL|dkryddl}Wnt
k
rtd	YnX||_|d|_|d
kr||j|_n|n|dkr:yddl}Wnt
k
r
tdYnX|d
kr.d|_||_t|_n
||_n||d
kryddl}Wnt
k
rntdYnX|d
krd|_||_|j|_n
||_n|dkrtd|Wn&|js|jd|_YnXdS)z$Construct a _Stream object.
        TNF*rgzzzlib module is not availablerybz2zbz2 module is not availablexzzlzma module is not availabletarzunknown compression type %r) _extfileobjrx_StreamProxygetcomptyperrgcomptypefileobjr^rTposclosedzlibImportErrorrcrc32crc
_init_read_gzerrorr]_init_write_gzrdbufZBZ2DecompressorcmpOSErrorZ
BZ2CompressorlzmaZLZMADecompressor	LZMAErrorZLZMACompressorr)	rrrgrrr^rrrr5r5r6rYsl












z_Stream.__init__cCst|dr|js|dS)Nr)rrr)rr5r5r6__del__sz_Stream.__del__cCs|jd|jj|jj|jjd|_tdtt		}|
d|d|jdrf|jdd|_|
|j
d	d
tdS)z6Initialize for writing with gzip compression.
        	rz<Lssz.gzNz
iso-8859-1replace)rZcompressobjZDEFLATED	MAX_WBITSZ
DEF_MEM_LEVELrrSpackrEtime_Stream__writerendswithr.r0)rZ	timestampr5r5r6rsz_Stream._init_write_gzcCsR|jdkr|j||j|_|jt|7_|jdkrD|j|}||dS)z&Write string s to the stream.
        rrN)	rrrrrr/rcompressr)rr1r5r5r6rZs

z
_Stream.writecCsR|j|7_x>t|j|jkrL|j|jd|j|j|jd|_qWdS)z]Write string s to the stream if a whole new block
           is ready to be written.
        N)rTr/r^rrZ)rr1r5r5r6Z__writesz_Stream.__writecCs|jr
dSd|_z|jdkr:|jdkr:|j|j7_|jdkr|jr|j|jd|_|jdkr|jt	d|j
|jt	d|jd@Wd|js|j
XdS)	z[Close the _Stream object. No operation should be
           done on it afterwards.
        NTrzrrrz<Ll)rrgrrTrflushrrZrSrrrrr)rr5r5r6rs
z
_Stream.closecCs|j|jj|_d|_|ddkr0td|ddkrFtdt|d}|d|d	@rt|dd
t|d}|	||d@rx|d}|r|t
krPqW|d@rx|d}|r|t
krPqW|d@r|dd
S)z:Initialize for reading a gzip compressed fileobj.
        rr$sznot a gzip filer#zunsupported compression methodr@r?N)rZ
decompressobjrrr
_Stream__readrrordrYr0)rflagZxlenr1r5r5r6rs.
 


z_Stream._init_read_gzcCs|jS)z3Return the stream's file pointer position.
        )r)rr5r5r6tellsz_Stream.tellrcCs\||jdkrNt||j|j\}}xt|D]}||jq.W||ntd|jS)zXSet the stream's file pointer to pos. Negative seeking
           is forbidden.
        rz seeking backwards is not allowed)rrXr^rDrYr	)rrr_r`rJr5r5r6seeksz_Stream.seekNcCsZ|dkr:g}x ||j}|s P||qWd|}n
||}|jt|7_|S)zReturn the next size number of bytes from the stream.
           If size is not defined, return all bytes of the stream
           up to EOF.
        Nr)_readr^appendjoinrr/)rr'trTr5r5r6rYs
z_Stream.readcCs|jdkr||St|j}|jg}xd||kr||j}|sBPy|j|}Wn|jk
rptdYnX|	||t|7}q(Wd
|}||d|_|d|S)z+Return size bytes from the stream.
        rzinvalid compressed datarN)rrr/rr^rZ
decompressr]rrr)rr'crrTr5r5r6rs"





z
_Stream._readcCsnt|j}|jg}x6||krH|j|j}|s0P|||t|7}qWd|}||d|_|d|S)zsReturn size bytes from stream. If internal buffer is empty,
           read another block from the stream.
        rN)r/rTrrYr^rr)rr'rrrTr5r5r6Z__read3s



z_Stream.__read)r)N)rprqrrrsrrrrZrrrrrrYrrr5r5r5r6rNs	F
	

rc@s0eZdZdZddZddZddZdd	Zd
S)rzsSmall proxy class that enables transparent compression
       detection for the Stream interface (mode 'r|*').
    cCs||_|jt|_dS)N)rrY	BLOCKSIZErT)rrr5r5r6rIsz_StreamProxy.__init__cCs|jj|_|jS)N)rrYrT)rr'r5r5r6rYMs
z_StreamProxy.readcCsP|jdrdS|jdddkr8|jdddkr8d	S|jd
rHdSdSdS)
NsrrsBZhr
s1AY&SYr)s]s7zXZrr)rT
startswith)rr5r5r6rQs$z_StreamProxy.getcomptypecCs|jdS)N)rr)rr5r5r6r[sz_StreamProxy.closeN)rprqrrrsrrYrrr5r5r5r6rDs

rc@sjeZdZdZdddZddZddZd	d
ZddZd
dZ	e
jfddZdddZ
ddZddZdS)_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|_|dkr>d|fg}d|_g|_d}|j}xT|D]L\}}||kr~|j	d||df|j	d||||f||7}||}qZW||jkr|j	d||jdfdS)NrrFT)
roffsetr'positionrkrr	map_indexmapr)rrrr'Z	blockinfoZlastposZrealposr5r5r6rhs(

z_FileInFile.__init__cCsdS)Nr5)rr5r5r6rsz_FileInFile.flushcCsdS)NTr5)rr5r5r6readablesz_FileInFile.readablecCsdS)NFr5)rr5r5r6writablesz_FileInFile.writablecCs
|jS)N)rseekable)rr5r5r6rsz_FileInFile.seekablecCs|jS)z*Return the current file position.
        )r)rr5r5r6rsz_FileInFile.tellcCs|tjkr tt|d|j|_nj|tjkr\|dkrFt|j|d|_qt|j||j|_n.|tjkrtt|j||jd|_ntd|jS)z(Seek to a position in the file.
        rzInvalid argument)	ioSEEK_SETminmaxr'rSEEK_CURSEEK_ENDrG)rrwhencer5r5r6rs


z_FileInFile.seekc	Cs|dkr|j|j}nt||j|j}d}x|dkrxZ|j|j\}}}}||jkrd|krlnnPq:|jd7_|jt|jkr:d|_q:Wt|||j}|r|j||j||j|}t||krt	d||7}n|t
|7}||8}|j|7_q.W|S)z!Read data from the file.
        Nrrr#zunexpected end of data)r'rrrrr/rrrYrr0)	rr'rTdatastartstoprr2rar5r5r6rYs.

z_FileInFile.readcCs&|t|}||dt|<t|S)N)rYr/)rrarTr5r5r6readintosz_FileInFile.readintocCs
d|_dS)NT)r)rr5r5r6rsz_FileInFile.close)N)N)rprqrrrsrrrrrrrrrrYrrr5r5r5r6rbs

rcseZdZfddZZS)ExFileObjectcs&t|j|j|j|j}t|dS)N)rroffset_datar'sparsesuperr)rtarfiletarinfor)	__class__r5r6rs
zExFileObject.__init__)rprqrrr
__classcell__r5r5)rr6rsrc@seZdZdZdZdTddZeddZejddZed	d
Z	e	jdd
Z	dd
Z
ddZee
dfddZddZddZddZeddZddZeddZedd Zed!d"Zed#d$Zed%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Z d3d4Z!d5d6Z"d7d8Z#d9d:Z$d;d<Z%d=d>Z&d?d@Z'dAdBZ(dCdDZ)dEdFZ*dGdHZ+dIdJZ,dKdLZ-dMdNZ.dOdPZ/dQdRZ0dSS)UraInformational 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.
    )rrgr)r*r'r(chksumtypelinknamer+r,devmajordevminorrrpax_headersrr_sparse_structs_link_targetrcCsj||_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.
        irrN)rrgr)r*r'r(rREGTYPErrr+r,rrrrrr)rrr5r5r6rs"zTarInfo.__init__cCs|jS)N)r)rr5r5r6r%szTarInfo.pathcCs
||_dS)N)r)rrr5r5r6r%scCs|jS)N)r)rr5r5r6r&szTarInfo.linkpathcCs
||_dS)N)r)rrr5r5r6r&	scCsd|jj|jt|fS)Nz<%s %r at %#x>)rrprid)rr5r5r6__repr__
szTarInfo.__repr__cCsl|j|jd@|j|j|j|j|j|j|j|j	|j
|j|jd
}|dt
krh|ddsh|dd7<|S)z9Return the TarInfo's attributes as a dictionary.
        i)
rrgr)r*r'r(rrrr+r,rrrr/)rrgr)r*r'r(rrrr+r,rrDIRTYPEr)rinfor5r5r6get_infos 
zTarInfo.get_infosurrogateescapecCsT|}|tkr||||S|tkr4||||S|tkrH|||StddS)z<Return a tar header as a string of 512 byte blocks.
        zinvalid formatN)rr
create_ustar_headerrcreate_gnu_headerrcreate_pax_headerrG)rrPr3r4rr5r5r6tobuf(sz
TarInfo.tobufcCsnt|d<t|d||tkr(tdt|d||tkr^||d||\|d<|d<||t||S)z3Return the object as a ustar header block.
        magicrzlinkname is too longrprefix)	POSIX_MAGICr/r.LENGTH_LINKrGLENGTH_NAME_posix_split_name_create_headerr
)rrr3r4r5r5r6r6szTarInfo.create_ustar_headercCst|d<d}t|d||tkr<|||dt||7}t|d||tkrl|||dt||7}|||t	||S)z:Return the object as a GNU header block sequence.
        rrrr)
	GNU_MAGICr/r.r_create_gnu_long_headerGNUTYPE_LONGLINKrGNUTYPE_LONGNAMErr)rrr3r4rTr5r5r6rCszTarInfo.create_gnu_headerc
	Cs0t|d<|j}xddtfddtfddfD]h\}}}||kr@q,y||dd	Wn"tk
rv||||<w,YnXt|||kr,||||<q,Wxhd
D]`\}}||krd||<q||}d|krd|d
krnn
t|t	rt
|||<d||<qW|r||t|}	nd}	|	|
|tddS)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%rr&)r+r+ )r,r,rrArB))r)r?)r*r?)r')r(rrr?r#rr)rrcopyrrr.UnicodeEncodeErrorr/
isinstancefloatstr_create_pax_generic_headerXHDTYPErr
)
rrr3rrZhnamer2rOvalrTr5r5r6rQs4
*zTarInfo.create_pax_headercCs||tdS)zAReturn the object as a pax global header block sequence.
        zutf-8)rXGLTYPE)clsrr5r5r6create_pax_global_headersz TarInfo.create_pax_global_headercCs|d}xltdt|D]R}d|d|}d||d}t|||tkrt|||tkrPqWtd||fS)zUSplit a name longer than 100 chars into a prefix
           and a name part.
        rr#Nzname is too long)splitrDr/rr.
LENGTH_PREFIXrrG)rrr3r4Z
componentsrJrr5r5r6rs
zTarInfo._posix_split_namecCsVt|ddd||t|ddd@d|t|ddd|t|d	dd|t|d
dd|t|ddd|d
|dtt|ddd|||dtt|ddd||t|ddd||t|ddd|t|ddd|t|ddd||g}tdtd|}t	|tdd}|ddt
d|d|dd}|S)zReturn a header block. info is a dictionary with file
           information, format must be one of the *_FORMAT constants.
        rrrrgrir?r)r*r'rr(s        rrrr+rr,rrrrz%dsrNiz%06orAi)r7getrQrrrSrrrrUrL)rrPr3r4partsrTrr5r5r6rs&

&zTarInfo._create_headercCs.tt|t\}}|dkr*|t|t7}|S)zdReturn the string payload filled with zero bytes
           up to the next 512 byte border.
        r)rXr/rr0)Zpayloadr_r`r5r5r6_create_payloadszTarInfo._create_payloadcCsR|||t}i}d|d<||d<t||d<t|d<||t||||S)zTReturn a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
           for name.
        z
././@LongLinkrrr'r)r.r0r/rrr
r
)rrrr3r4rr5r5r6rszTarInfo._create_gnu_long_headerc	Cs:d}x@|D]4\}}y|ddWqtk
r@d}PYqXqWd}|rV|d7}x|D]\}}|d}|r||d}n
|d}t|t|d}d	}	}
x"|tt|
}	|	|
krP|	}
qW|tt|
d
d|d|d
7}q`Wi}d|d<||d<t||d<t|d<||td
d|	|S)zReturn a POSIX.1-2008 extended or global header sequence
           that contains a list of keyword, value pairs. The values
           must be strings.
        Fzutf-8rBTrs21 hdrcharset=BINARY
rrrrA =
z././@PaxHeaderrrr'rr)
itemsr.rr/rrLrrr
r
)rrrr3ZbinarykeywordvalueZrecordslrIr;rr5r5r6rs<

*z"TarInfo._create_pax_generic_headerc	Cstt|dkrtdt|tkr(td|ttkr>tdt|dd}|t|krbt	d|}t
|dd|||_t|dd	|_t|d	d
|_
t|d
d|_t|dd|_t|dd|_||_|dd
|_t
|d
d|||_t
|dd|||_t
|dd|||_t|dd|_t|dd|_t
|dd||}|jtkr|jdrt|_|jtkr6d}g}xrtdD]f}	y0t|||d}
t||d|d}Wntk
rPYnX||
|f|d7}qWt|d}t|dd}
|||
f|_ |!rN|j"d|_|rp|jt#krp|d|j|_|S)zAConstruct a TarInfo object from a 512 byte bytes object.
        rzempty headerztruncated headerzend of file headerzbad checksumrlt|ii	i)iIiQiYirirriii)$r/rtrrucountr0rvrKrUrHr<rrgr)r*r'r(rrrr+r,rrAREGTYPErrGNUTYPE_SPARSErDrGrboolrisdirrstrip	GNU_TYPES)rrTr3r4robjrrstructsrJrnumbytes
isextendedorigsizer5r5r6frombufsZ
zTarInfo.frombufcCs8|jt}|||j|j}|jt|_||S)zOReturn the next TarInfo object from TarFile object
           tarfile.
        )	rrYrr&r3r4rr_proc_member)rrrTr!r5r5r6fromtarfileAszTarInfo.fromtarfilecCsT|jttfkr||S|jtkr,||S|jtttfkrF|	|S|
|SdS)zYChoose the right processing method depending on
           the type and call it.
        N)rrr
_proc_gnulongr_proc_sparserrSOLARIS_XHDTYPE	_proc_pax
_proc_builtin)rrr5r5r6r'Vs



zTarInfo._proc_membercCsR|j|_|j}|s$|jtkr4|||j7}||_|	|j
|j|j|S)zfProcess a builtin type or an unknown type which
           will be treated as a regular file.
        )
rrrisregrSUPPORTED_TYPES_blockr'r_apply_pax_inforr3r4)rrrr5r5r6r-cszTarInfo._proc_builtincCs|j||j}y||}Wntk
r>tdYnX|j|_|jt	krft
||j|j|_
n|jtkrt
||j|j|_|S)zSProcess the blocks that hold a GNU longname
           or longlink member.
        z missing or bad subsequent header)rrYr0r'r(rrwrrrr<r3r4rrr)rrrTnextr5r5r6r)ts

zTarInfo._proc_gnulongc
	Cs|j\}}}|`x|r|jt}d}xvtdD]j}y0t|||d}t||d|d}	Wntk
rzPYnX|r|	r|||	f|d7}q0Wt|d}qW||_	|j
|_|j||j
|_||_
|S)z8Process a GNU sparse header plus extra headers.
        rrri)rrrYrrDrKrGrrrrrr0r'r)
rrr"r$r%rTrrJrr#r5r5r6r*s(zTarInfo._proc_sparsecCs0|j||j}|jtkr&|j}n
|j}t	d|}|dk	rX|
dd|d<|d}|dkrr|j
}nd}td}d}x|||}|sP|\}	}
t|	}	|	dkrtd	||d
d|d|	d}||
dd|j}
|
tkr||||j
|j}n||dd|j}|||
<||	7}qWy||}Wntk
rdtdYnXd|kr~|||nHd
|kr||||n.|ddkr|ddkr|||||jttfkr,| ||j
|j|j!|_!d|kr,|j"}
|#s|jt$kr&|
||j7}
|
|_!|S)zVProcess an extended or global header as described in
           POSIX.1-2008.
        s\d+ hdrcharset=([^\n]+)\nNr#zutf-8
hdrcharsetZBINARYs(\d+) ([^=]+)=rzinvalid headerr$z missing or bad subsequent headerzGNU.sparse.mapzGNU.sparse.sizezGNU.sparse.major1zGNU.sparse.minorrCr')%rrYr0r'rrrrresearchgroupr:rr3compilematchgroupsrErHrjr_decode_pax_fieldr4PAX_NAME_FIELDSr(rrw_proc_gnusparse_01_proc_gnusparse_00_proc_gnusparse_10rr+r1rrr.r/)rrrTrr:r4r3Zregexrr2rrr2rr5r5r6r,sd



$	





 
zTarInfo._proc_paxcCspg}x(td|D]}|t|dqWg}x(td|D]}|t|dq@Wtt|||_dS)z?Process a GNU tar extended sparse header, version 0.0.
        s\d+ GNU.sparse.offset=(\d+)\nr#s\d+ GNU.sparse.numbytes=(\d+)\nN)r6finditerrrEr8listzipr)rr2rrTZoffsetsr:r#r5r5r6r?szTarInfo._proc_gnusparse_00cCs@dd|ddD}tt|ddd|ddd|_dS)z?Process a GNU tar extended sparse header, version 0.1.
        cSsg|]}t|qSr5)rE).0xr5r5r6
<listcomp>sz.TarInfo._proc_gnusparse_01.<locals>.<listcomp>zGNU.sparse.map,Nr$r#)rrBrCr)rr2rrr5r5r6r>szTarInfo._proc_gnusparse_01cCsd}g}|jt}|dd\}}t|}xJt||dkrvd|krV||jt7}|dd\}}|t|q.W|j|_t	t
|ddd|ddd|_dS)z?Process a GNU tar extended sparse header, version 1.0.
        Nr
r#r$)rrYrrrEr/rrrrBrCr)rr2rrZfieldsrrTZnumberr5r5r6r@szTarInfo._proc_gnusparse_10c	Csx|D]\}}|dkr(t|d|q
|dkrBt|dt|q
|dkr\t|dt|q
|tkr
|tkryt||}Wntk
rd}YnX|dkr|d}t|||q
W||_dS)	zoReplace fields with supplemental information from a previous
           pax extended or global header.
        zGNU.sparse.namer%zGNU.sparse.sizer'zGNU.sparse.realsizerrN)	rsetattrrE
PAX_FIELDSPAX_NUMBER_FIELDSrGrrr)rrr3r4rrr5r5r6r1/s"

zTarInfo._apply_pax_infocCs.y||dStk
r(|||SXdS)z1Decode a single field from a pax record.
        rBN)r:UnicodeDecodeError)rrr3Zfallback_encodingZfallback_errorsr5r5r6r<FszTarInfo._decode_pax_fieldcCs"t|t\}}|r|d7}|tS)z_Round up a byte count by BLOCKSIZE and return it,
           e.g. _block(834) => 1024.
        r#)rXr)rrr_r`r5r5r6r0NszTarInfo._blockcCs
|jtkS)N)r
REGULAR_TYPES)rr5r5r6r.Wsz
TarInfo.isregcCs|S)N)r.)rr5r5r6isfileYszTarInfo.isfilecCs
|jtkS)N)rr)rr5r5r6r[sz
TarInfo.isdircCs
|jtkS)N)rSYMTYPE)rr5r5r6issym]sz
TarInfo.issymcCs
|jtkS)N)rLNKTYPE)rr5r5r6islnk_sz
TarInfo.islnkcCs
|jtkS)N)rCHRTYPE)rr5r5r6ischrasz
TarInfo.ischrcCs
|jtkS)N)rBLKTYPE)rr5r5r6isblkcsz
TarInfo.isblkcCs
|jtkS)N)rFIFOTYPE)rr5r5r6isfifoeszTarInfo.isfifocCs
|jdk	S)N)r)rr5r5r6issparsegszTarInfo.issparsecCs|jtttfkS)N)rrRrTrV)rr5r5r6isdevisz
TarInfo.isdevN)r)1rprqrrrs	__slots__rpropertyr%setterr&rrrrrrrrclassmethodrrstaticmethodrr
rrr&r(r'r-r)r*r,r?r>r@r1r<r0r.rMrrOrQrSrUrWrXrYr5r5r5r6rsT

1
3?
h	c
@seZdZdZdZdZdZdZeZ	e
ZdZe
ZeZd\dd	Zedddefd
dZed]dd
Zed^ddZed_ddZed`ddZdddddZddZddZddZd d!Zdad"d#Zdbdd%d&d'Zdcdd(d)d*Z ddd+d,Z!dedd.d/d0Z"dfdd.d2d3Z#d4d5Z$dgd6d7Z%d8d9Z&d:d;Z'd<d=Z(d>d?Z)d@dAZ*dBdCZ+dDdEZ,dFdGZ-dHdIZ.dJdKZ/dhdLdMZ0dNdOZ1didPdQZ2dRdSZ3dTdUZ4dVdWZ5dXdYZ6dZd[Z7dS)jrz=The TarFile Class provides an interface to tar archives.
    rFr#Nryrc
Csddddd}||krtd||_|||_|sh|jdkrTtj|sTd|_d|_t||j}d	|_n@|d
krt|drt	|j
ttfr|j
}t|dr|j|_d
|_|rtj
|nd
|_
||_|d
k	r||_|d
k	r||_|d
k	r||_|d
k	r||_|d
k	r||_|	|_|
d
k	r0|jtkr0|
|_ni|_|d
k	rF||_|d
k	rV||_|
|_d	|_g|_d	|_|j|_i|_y|jdkrd
|_ |!|_ |jdkr2x|j"|jy|j#|}|j$|WnTt%k
r|j"|jPYn0t&k
r*}zt't|Wd
d
}~XYnXqW|jdkr|d
|_|jr||j(|j)}|j*||jt+|7_Wn&|js|j,d
|_YnXd
S)aOpen 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+bwbZxb)ryarzrEz!mode must be 'r', 'a', 'w' or 'x'rarzFNrrgTry)rarzrE)-rGrg_moder|r%exists	bltn_openrrrrrrLabspathrrPrdereferenceignore_zerosr3r4rrdebug
errorlevelcopybufsizermembers_loadedrrinodesfirstmemberr2rr(rrvrrrrrZr/r)rrrgrrPrrfrgr3r4rrhrirjZmodeserTr5r5r6rs





$
zTarFile.__init__c

s|s|std|dkrfdd}xttj|dD]b}tj|}|dk	rX|}	y||d|f|Sttfk
r|dk	r||	w4Yq4Xq4Wtdnd	|kr|d	d
\}
}|
pd}
|pd}|jkrtj|}ntd||||
|f|Sd
|kr|d
d
\}
}|
p*d}
|p4d}|
dkrHtdt	||
|||}y||
|f|}Wn|
YnXd|_|S|dkrj|||f|StddS)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)ryzr:*csj|dkS)Ntaropen)	OPEN_METH)r)rr5r6not_compressed sz$TarFile.open.<locals>.not_compressed)keyNryz%file could not be opened successfully:r#rzunknown compression type %r|)ryrzzmode must be 'r' or 'w'F)rarzrEzundiscernible mode)
rGsortedrqrkrrrrrrrrrp)
rrrgrr^kwargsrrrfuncZ	saved_posrfstreamrr5)rr6rsP%







zTarFile.opencKs |dkrtd||||f|S)zCOpen uncompressed tar archive name for reading or writing.
        )ryrarzrEz!mode must be 'r', 'a', 'w' or 'x')rG)rrrgrrwr5r5r6rpQszTarFile.taropenrc	Ks|dkrtdyddl}|jWn ttfk
rBtdYnXy|||d||}Wn.tk
r|dk	r|dkrtdYnXy|j|||f|}WnBtk
r|	|dkrtdYn|	YnXd	|_
|S)
zkOpen gzip compressed tar archive name for reading or writing.
           Appending is not allowed.
        )ryrzrEzmode must be 'r', 'w' or 'x'rNzgzip module is not availableraryznot a gzip fileF)rGgzipZGzipFilerAttributeErrorrrrrprr)rrrgr
compresslevelrwrzrr5r5r6gzopenYs2
zTarFile.gzopenc	Ks|dkrtdyddl}Wntk
r8tdYnX|j|pD|||d}y|j|||f|}WnFttfk
r||dkrt	dYn|YnXd	|_
|S)
zlOpen bzip2 compressed tar archive name for reading or writing.
           Appending is not allowed.
        )ryrzrEzmode must be 'r', 'w' or 'x'rNzbz2 module is not available)r|ryznot a bzip2 fileF)rGrrrZBZ2FilerprEOFErrorrrr)rrrgrr|rwrrr5r5r6bz2open{s(zTarFile.bz2openc	Ks|dkrtdyddl}Wntk
r8tdYnX|j|pD|||d}y|j|||f|}WnH|jtfk
r||dkrt	dYn|YnXd	|_
|S)
zkOpen lzma compressed tar archive name for reading or writing.
           Appending is not allowed.
        )ryrzrEzmode must be 'r', 'w' or 'x'rNzlzma module is not available)presetryznot an lzma fileF)rGrrrZLZMAFilerprr~rrr)rrrgrrrwrrr5r5r6xzopens&zTarFile.xzopenrpr}rr)rrrrcCs|jr
dSd|_z`|jdkrn|jttd|jtd7_t|jt\}}|dkrn|jtt|Wd|j	s|j
XdS)zlClose the TarFile. In write-mode, two finishing zero blocks are
           appended to the archive.
        NT)rarzrEr$r)rrgrrZr0rrrX
RECORDSIZErr)rr_r`r5r5r6rs
z
TarFile.closecCs"||}|dkrtd||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.
        Nzfilename %r not found)
_getmemberKeyError)rrrr5r5r6	getmembers
zTarFile.getmembercCs||js||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.
        )_checkrl_loadrk)rr5r5r6
getmembersszTarFile.getmemberscCsdd|DS)zReturn the members of the archive as a list of their names. It has
           the same order as the list returned by getmembers().
        cSsg|]
}|jqSr5)r)rDrr5r5r6rFsz$TarFile.getnames.<locals>.<listcomp>)r)rr5r5r6getnamesszTarFile.getnamescCsl|d|dk	r|j}|dkr$|}tj|\}}|tjd}|d}|}||_	|dkrt
tdr~|js~t|}qt
|}nt|}d}|j}t
|r|j|jf}	|js|jdkr|	|jkr||j|	krt}
|j|	}nt}
|	drt||j|	<nht
|rt}
nVt
|r0t}
nDt
|rLt}
t|}n(t
|r^t }
nt
!|rpt"}
ndS||_||_#|j$|_%|j&|_'|
tkr|j(|_)nd|_)|j*|_+|
|_,||_-t.ryt./|j%d|_0Wnt1k
rYnXt2r&yt23|j'd|_4Wnt1k
r$YnX|
t t"fkrht
tdrht
td	rht5|j6|_7t8|j6|_9|S)
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.
        awxNrlstatrr#rmajorminor):rrr|r%
splitdriverseplstriprrrrfrrefstatfilenost_modeS_ISREGst_inost_devst_nlinkrmrPrS_ISDIRrS_ISFIFOrVS_ISLNKrNreadlinkS_ISCHRrRS_ISBLKrTrgst_uidr)st_gidr*st_sizer'st_mtimer(rrpwdgetpwuidr+rgrpZgetgrgidr,rst_rdevrrr)rrarcnamerZdrvrZstatresrZstmdinoderr5r5r6
gettarinfos~	




zTarFile.gettarinfoT)rkcCs||dkr|}x|D]}|rtt|jtd|jp@|j|jpJ|jf|	sb|
r|tdd|j|jfntd|j
tdt|jddt|j|rdnd	|r|rtd
|j|rtd|jtqWdS)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%s/%sz%10sz%d,%dz%10dz%d-%02d-%02d %02d:%02d:%02drrrz-> zlink to )rrorerfrgr+r)r,r*rSrUrrr'rZ	localtimer(rrrOrrQrn)rverboserkrr5r5r6rBSs*
zTarFile.list)filterc	Cs:|d|dkr|}|jdk	rFtj||jkrF|dd|dS|d||||}|dkrz|dd|dS|dk	r||}|dkr|dd|dS|rt|d}|	||WdQRXnd|
r,|	||r6xHtt|D]*}|j
tj||tj||||d	qWn
|	|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.
        rNr$ztarfile: Skipped %rr#ztarfile: Unsupported type %rztarfile: Excluded %rr_)r)rrr|r%re_dbgrr.rdaddfilerrvlistdiraddr)rrr	recursiverrfr5r5r6rss4



zTarFile.addcCs|dt|}||j|j|j}|j||jt	|7_|j
}|dk	rt||j|j|dt
|jt\}}|dkr|jtt||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().
        rN)r^rr#)rrrrPr3r4rrZrr/rjrWr'rXrr0rkr)rrrrTr^r_r`r5r5r6rs

zTarFile.addfile.)
numeric_ownercCsg}|dkr|}xF|D]>}|r<||t|}d|_|j||||dqW|jddd|x|D]}tj	||j
}y,|j|||d||||
||Wqvtk
r}z"|jdkrւn|dd	|Wdd}~XYqvXqvWdS)
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.
        Ni)	set_attrsrcSs|jS)N)r)rar5r5r6<lambda>rz$TarFile.extractall.<locals>.<lambda>)rs)rr#ztarfile: %s)rrrrgextractsortreverser|r%rrchownutimechmodr
rir)rr%rkrZdirectoriesrdirpathror5r5r6
extractalls,




zTarFile.extractallrc
Cs|dt|tr ||}n|}|r>tj||j|_	y"|j
|tj||j||dWntk
r}zH|j
dkrn6|jdkr|dd|jn|dd|j|jfWdd}~XYnBtk
r}z"|j
dkrn|dd|Wdd}~XYnXdS)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.
        ry)rrrNr#ztarfile: %sztarfile: %s %r)rrrrrQr|r%rrr_extract_memberrrrifilenamerstrerrorr
)rmemberr%rrrror5r5r6rs(	



(
zTarFile.extractcCs|dt|tr ||}n|}|s6|jtkrB|||S|sR|	rzt|j
trhtdq~|
||SndSdS)zExtract 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. Otherwise, None is
           returned.
        ryz'cannot extract (sym)link as file objectN)rrrrr.rr/
fileobjectrQrOrrr	extractfile_find_link_target)rrrr5r5r6r
s


zTarFile.extractfilecCsT|d}|dtj}tj|}|r>tj|s>t||sN|	rh|
dd|j|jfn|
d|j|
r|||n|r|||nx|r|||nb|s|r|||nD|s|	r|||n&|jtkr|||n||||rP|||||	sP||||||dS)z\Extract the TarInfo object tarinfo to a physical
           file called targetpath.
        rr#z%s -> %sN)rrr|rr%dirnamercmakedirsrQrOrrrr.makefilermakedirrWmakefiforSrUmakedevmakelinkrr/makeunknownrrr)rr
targetpathrrZ	upperdirsr5r5r6r,s4


zTarFile._extract_membercCs*yt|dWntk
r$YnXdS)z,Make a directory called targetpath.
        iN)r|mkdirFileExistsError)rrrr5r5r6r]szTarFile.makedirc	Cs|j}||j|j}t|df}|jdk	rrx,|jD]"\}}||t|||t|q6W||j|	nt|||jt|WdQRXdS)z'Make a file called targetpath.
        r`N)
rrrrjrdrrWrr'truncate)rrrsourcer^targetrr'r5r5r6rgs


zTarFile.makefilecCs"||||dd|jdS)zYMake a file from a TarInfo object with an unknown type
           at targetpath.
        r#z9tarfile: Unknown file type %r, extracted as regular file.N)rrr)rrrr5r5r6rwszTarFile.makeunknowncCs"ttdrt|ntddS)z'Make a fifo called targetpath.
        mkfifozfifo not supported by systemN)rr|rr
)rrrr5r5r6rs
zTarFile.makefifocCs^ttdrttdstd|j}|r6|tjO}n
|tjO}t||t	|j
|jdS)z<Make a character or block device called targetpath.
        mknodrz'special devices not supported by systemN)rr|r
rgrUreS_IFBLKS_IFCHRrrrr)rrrrgr5r5r6rs
zTarFile.makedevcCsyL|rt|j|n0tj|jr8t|j|n||	||WnHt
k
ry||	||Wntk
rtdYnXYnXdS)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)
rOr|symlinkrr%rcrlinkrrsymlink_exceptionrr
)rrrr5r5r6rs

zTarFile.makelinkcCsttdrtdkr|j}|j}|sytr<t|jd}Wntk
rRYnXyt	rjt	
|jd}Wntk
rYnXy4|rttdrt
|||nt|||Wntk
rtdYnXdS)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$lchownzcould not change ownerN)rr|rr*r)rZgetgrnamr,rrgetpwnamr+rOrrrr
)rrrrgur5r5r6rs(z
TarFile.chowncCs>ttdr:yt||jWntk
r8tdYnXdS)zASet file permissions of targetpath according to tarinfo.
        rzcould not change modeN)rr|rrgrr
)rrrr5r5r6rs

z
TarFile.chmodcCsHttdsdSyt||j|jfWntk
rBtdYnXdS)zBSet modification time of targetpath according to tarinfo.
        rNz"could not change modification time)rr|rr(rr
)rrrr5r5r6rs
z
TarFile.utimec
Cs|d|jdk	r$|j}d|_|S|j|jkrZ|j|jd|jdsZtdd}xby|j	|}WnHt
k
r}z0|jr|dd|j|f|jt
7_wbWdd}~XYntk
r,}zL|jr|dd|j|f|jt
7_wbn|jdkrtt|Wdd}~XYntk
rT|jdkrPtdYnjtk
r}z|jdkr~tt|Wdd}~XYn0tk
r}ztt|Wdd}~XYnXPqbW|dk	r|j|nd	|_|S)
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.
        ZraNr#zunexpected end of datar$z0x%X: %srz
empty fileT)rrnrrrrrYrrr(rvrgrrrHrrtrurwrkrrl)rmrror5r5r6r2sL


zTarFile.nextcCsn|}|dk	r"|d||}|r2tj|}x6t|D]*}|rTtj|j}n|j}||kr<|Sq<WdS)z}Find an archive member by name from bottom to top.
           If tarinfo is given, it is used as the starting point.
        N)rindexr|r%normpathreversedr)rrr	normalizerkrmember_namer5r5r6r	szTarFile._getmembercCs"x|}|dkrPqWd|_dS)zWRead through the entire archive file and look for readable
           members.
        NT)r2rl)rrr5r5r6r+	s
z
TarFile._loadcCs:|jrtd|jj|dk	r6|j|kr6td|jdS)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)rrrrprg)rrgr5r5r6r5	szTarFile._checkcCs`|r.dtdtj|j|jf}d}n
|j}|}|j||dd}|dkr\t	d||S)zZFind the target member of a symlink or hardlink member in the
           archive.
        rNT)rrzlinkname %r not found)
rOrrr|r%rrrrr)rrrlimitrr5r5r6r>	s zTarFile._find_link_targetccs|jr|jEdHdSd}|jdk	r:|}|d7}|VxN|t|jkrV|j|}n"|jst|}|sxd|_dSndS|d7}|Vq<WdS)z$Provide an iterator object.
        Nrr#T)rlrkrnr2r/)rrrr5r5r6__iter__Q	s&
zTarFile.__iter__cCs||jkrt|tjddS)z.Write debugging output to sys.stderr.
        )fileN)rhrnrlstderr)rlevelmsgr5r5r6rp	s
zTarFile._dbgcCs||S)N)r)rr5r5r6	__enter__v	szTarFile.__enter__cCs,|dkr|n|js"|jd|_dS)NT)rrrr)rrr	tracebackr5r5r6__exit__z	s


zTarFile.__exit__)
NryNNNNNNrNNNN)ryN)ryNr)ryNr)ryNN)NNN)T)NT)N)rN)rT)TF)NF)N)8rprqrrrsrhrfrgrirrPrr3r4rrrrrr]rrrpr}rrrqrrrrrrBrrrrrrrrrrrrrrrr2rrrrrrrrr5r5r5r6rmsv
lZ!

d 3
(&
0
	6


	cCs.yt|}|dStk
r(dSXdS)zfReturn True if name points to a tar archive that we
       are able to handle, else return False.
    TFN)rrr)rrr5r5r6r	sc	Csddl}d}|j|d}|jdddddd	|jd
d}|jdd
ddd|jdddddd|jdddddd|jddddd|}|jdk	r|j}t|rt|d }|t	|t
jdWdQRX|jrt	d 
|n|d!d"
|n|jdk	r\|j}t|rFt|d#}|j|jd$WdQRXn|d!d"
|nv|jdk	r,t|jd!kr|jd}tj}n,t|jd%kr|j\}}n|d!|t|rt|d#}|j|d&WdQRX|jr*|d'krd(
|}	nd)
||}	t	|	n|d!d"
|n|jdk	r|jd}
tj|
\}}d*d*d+d+d,d,d,d,d-}
||
krd.|
|nd/}|j}t|
| }x|D]}||qWWdQRX|jrt	d0
|
dS)1Nrz3A simple command-line interface for tarfile module.)descriptionz-vz	--verbose
store_trueFzVerbose output)actiondefaulthelpT)Zrequiredz-lz--listz	<tarfile>zShow listing of a tarfile)metavarrz-ez	--extract+)z	<tarfile>z<output_dir>zExtract tarfile into target dir)nargsrrz-cz--create)z<name>z<file>zCreate tarfile from sourcesz-tz--testzTest if a tarfile is validry)rz{!r} is a tar archive.r#z{!r} is not a tar archive.
zr:*)rr$)r%rz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.rrr)z.gzz.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:rzz{!r} file created.)argparseArgumentParseradd_argumentZadd_mutually_exclusive_group
parse_argsZtestrrrrnrlrrrPexitrBrrr/r|curdirZformat_helprZcreatepopr%splitextr)rrparserr8argsr[rZtfrrZtar_name_ZextZcompressionsZtar_modeZ	tar_files	file_namer5r5r6main	s









r__main__)_rsversion
__author____credits__builtinsrrdrlr|rrVrerrSrr6rrrr{NotImplementedErrorrr	NameError__all__r0rrrrrrrrrrPrNrRrTrrVZCONTTYPErrrrrr+r
rrrr/rLr rIr=rrErJrrgetfilesystemencodingr7r<rKrQrUrWrfro	Exceptionrr
rrr	rrtrurvrHrwrxrobjectrrBufferedReaderrrrrrrpr5r5r5r6<module>s



wh"W