%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/tarfile.cpython-38.pyc

U

nan@sjdZdZdZdZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZzddlZWnek
rdZYnXzddlZWnek
rdZYnXeefZzeef7ZWnek
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,Z2e2Z3e!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@dAZDdBdCZEGdDd
d
eFZGGdEddeGZHGdFddeGZIGdGddeGZJGdHd
d
eGZKGdIddeGZLGdJdKdKeLZMGdLdMdMeLZNGdNdOdOeLZOGdPdQdQeLZPGdRdSdSeLZQGdTdUdUZRGdVdWdWZSGdXdYdYeTZUGdZd[d[eTZVGd\d]d]e	jWZXGd^ddeTZYGd_ddeTZZd`d	Z[eZjZdadbZ\e]dckrfe\dS)dz,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,)Zatimectimer(r)r*r'ntutf-8cCs(|||}|d||t|tS)z8Convert a string to a null-terminated bytes object.
    N)encodelenNUL)slengthencodingerrorsr7#/usr/local/lib/python3.8/tarfile.pystnsr9cCs*|d}|dkr|d|}|||S)z8Convert a null-terminated bytes object to a string.
    rN)finddecode)r3r5r6pr7r7r8ntss
r>cCs|ddkrbd}tt|dD]}|dK}|||d7}q |ddkrdt|d|}n@z"t|dd}t|p|d	d}Wntk
rtd
YnX|S)z/Convert a number field to a python number.
    r)r#r@asciistrict0invalid header)ranger1r>intstrip
ValueErrorInvalidHeaderError)r3nir7r7r8ntisrNrAcCst|}d|kr$d|dkrDnntd|d|fdt}n|tkrd|d|krrd|dkrnnV|dkrtdg}ntdg}d||}t|dD]}|d|d@|dL}qntd	|S)
z/Convert a python number to a number field.
    rrAr#z%0*orCrBr?r@zoverflow in number field)rHbytesr2r	bytearrayrGinsertrJ)rLdigitsformatr3rMr7r7r8itns 2
rTcCs0dttd|}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.
    rBZ
148B8x356BZ
148b8x356b)sumstructunpack_from)bufZunsigned_chksumZ
signed_chksumr7r7r8calc_chksumss	rYc	Cs|pd}|dkrdS|dkr.t|||dSt||\}}t|D],}||}t||krf|d||qD|dkr||}t||kr|d||dS)zjCopy length bytes from fileobj src to fileobj dst.
       If length is None, copy the entire content.
    i@rNunexpected end of data)shutilcopyfileobjdivmodrGreadr1write)	srcdstr4	exceptionbufsizeblocks	remainderbrXr7r7r8r\s$


r\cCs8ttjdd}|dk	r(||d|}t|dddS)Nr5backslashreplace )end)getattrsysstdoutr0r<print)r3r5r7r7r8_safe_printsrnc@seZdZdZdS)rzBase exception.N__name__
__module____qualname____doc__r7r7r7r8r
sc@seZdZdZdS)r
z%General exception for extract errors.Nror7r7r7r8r

sc@seZdZdZdS)rz&Exception for unreadable tar archives.Nror7r7r7r8rsc@seZdZdZdS)rz.Exception for unavailable compression methods.Nror7r7r7r8rsc@seZdZdZdS)r	z=Exception for unsupported operations on stream-like TarFiles.Nror7r7r7r8r	sc@seZdZdZdS)rz!Base exception for header errors.Nror7r7r7r8rsc@seZdZdZdS)EmptyHeaderErrorzException for empty headers.Nror7r7r7r8rtsrtc@seZdZdZdS)TruncatedHeaderErrorz Exception for truncated headers.Nror7r7r7r8rusruc@seZdZdZdS)EOFHeaderErrorz"Exception for end of file headers.Nror7r7r7r8rv"srvc@seZdZdZdS)rKzException for invalid headers.Nror7r7r7r8rK%srKc@seZdZdZdS)SubsequentHeaderErrorz3Exception for missing and invalid extended headers.Nror7r7r7r8rw(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)NrwO_BINARYi)	osO_RDONLYO_WRONLYO_CREATO_TRUNChasattrr|rfd)selfnamemoder7r7r8__init__5s

z_LowLevelFile.__init__cCst|jdSN)r}closerrr7r7r8r>sz_LowLevelFile.closecCst|j|Sr)r}r^rrr'r7r7r8r^Asz_LowLevelFile.readcCst|j|dSr)r}r_rrr3r7r7r8r_Dsz_LowLevelFile.writeN)rprqrrrsrrr^r_r7r7r7r8rx/s
	rxc@sreZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
ddZdddZddZ
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|_zL|dkrzddl}Wnt
k
rtd	YnX||_|d|_|d
kr||j|_n|n|dkr:zddl}Wnt
k
r
tdYnX|d
kr.d|_||_t|_n
||_n||d
krzddl}Wnt
k
rntdYnX|d
krd|_||_|j|_n
||_n|dkrtd|Wn&|js|jd|_YnXdS)z$Construct a _Stream object.
        TNF*rgzzzlib module is not availablerzbz2bz2 module is not availablexzlzma module is not availabletarunknown compression type %r) _extfileobjrx_StreamProxygetcomptyperrcomptypefileobjrcrXposclosedzlibImportErrorrcrc32crc
_init_read_gzerrorrb_init_write_gzrdbufBZ2DecompressorcmpOSError
BZ2CompressorlzmaLZMADecompressor	LZMAErrorLZMACompressorr)	rrrrrrcrrrr7r7r8rRsl












z_Stream.__init__cCst|dr|js|dS)Nr)rrrrr7r7r8__del__sz_Stream.__del__cCs|jd|jj|jj|jjd|_tdtt		}|
d|d|jdrf|jdd|_t
j|j|_|
|jd	d
tdS)z6Initialize for writing with gzip compression.
        	r<Lss.gzNz
iso-8859-1replace)rcompressobjDEFLATED	MAX_WBITS
DEF_MEM_LEVELrrVpackrHtime_Stream__writerendswithr}r%basenamer0r2)rZ	timestampr7r7r8rsz_Stream._init_write_gzcCsR|jdkr|j||j|_|jt|7_|jdkrD|j|}||dS)z&Write string s to the stream.
        rrN)	rrrrrr1rcompressrrr7r7r8r_s

z
_Stream.writecCsN|j|7_t|j|jkrJ|j|jd|j|j|jd|_qdS)z]Write string s to the stream if a whole new block
           is ready to be written.
        N)rXr1rcrr_rr7r7r8Z__writesz_Stream.__writecCs|jr
dSd|_z|jdkr:|jdkr:|j|j7_|jdkr|jr|j	|jd|_|jdkr|j	t
d|j|j	t
d|j
d@W5|js|jXdS)	z[Close the _Stream object. No operation should be
           done on it afterwards.
        NTr{rrrrl)rrrrrrrXrflushr_rVrrrrr7r7r8rs
z
_Stream.closecCs|j|jj|_d|_|ddkr0td|ddkrFtdt|d}|d|d	@rt|dd
t|d}|	||d@r|d}|r|t
krqq|d@r|d}|r|t
krqq|d@r|dd
S)z:Initialize for reading a gzip compressed fileobj.
        rr$snot a gzip filer#zunsupported compression methodrBrAN)r
decompressobjrrr
_Stream__readrrordr^r2)rflagZxlenr3r7r7r8rs*
 


z_Stream._init_read_gzcCs|jS)z3Return the stream's file pointer position.
        )rrr7r7r8tellsz_Stream.tellrcCsX||jdkrJt||j|j\}}t|D]}||jq,||ntd|jS)zXSet the stream's file pointer to pos. Negative seeking
           is forbidden.
        rz seeking backwards is not allowed)rr]rcrGr^r	)rrrdrerMr7r7r8seeksz_Stream.seekcCs,|dk	st||}|jt|7_|S)z5Return the next size number of bytes from the stream.N)AssertionError_readrr1)rr'rXr7r7r8r^s
z_Stream.readcCs|jdkr||St|j}|jg}||kr|jrB|j}d|_n|j|j}|sVqz|j	|}Wn|j
k
rtdYnX|||t|7}q&d
|}||d|_|d|S)z+Return size bytes from the stream.
        rrzinvalid compressed dataN)rrr1rrXrr^rcr
decompressrbrappendjoinrr'ctrXr7r7r8r
s(




z
_Stream._readcCsjt|j}|jg}||krF|j|j}|s.qF|||t|7}qd|}||d|_|d|S)zsReturn size bytes from stream. If internal buffer is empty,
           read another block from the stream.
        rN)r1rXrr^rcrrrr7r7r8Z__read(s


z_Stream.__readN)r)rprqrrrsrrrr_rrrrrr^rrr7r7r7r8rGs
F
	

rc@s0eZdZdZddZddZddZdd	Zd
S)rzsSmall proxy class that enables transparent compression
       detection for the Stream interface (mode 'r|*').
    cCs||_|jt|_dSr)rr^	BLOCKSIZErX)rrr7r7r8r>sz_StreamProxy.__init__cCs|jj|_|jSr)rr^rXrr7r7r8r^Bs
z_StreamProxy.readcCsP|jdrdS|jdddkr8|jdddkr8d	S|jd
rHdSdSdS)
NsrrsBZhr
s1AY&SYr)s]s7zXZrr)rX
startswithrr7r7r8rFs$z_StreamProxy.getcomptypecCs|jdSr)rrrr7r7r8rPsz_StreamProxy.closeN)rprqrrrsrr^rrr7r7r7r8r9s

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}|D]L\}}||kr||j	d||df|j	d||||f||7}||}qX||jkr|j	d||jdfdS)NrrFT)
roffsetr'positionrjrr	map_indexmapr)rrrr'Z	blockinfoZlastposZrealposr7r7r8r]s(


z_FileInFile.__init__cCsdSrr7rr7r7r8rvsz_FileInFile.flushcCsdSNTr7rr7r7r8readableysz_FileInFile.readablecCsdS)NFr7rr7r7r8writable|sz_FileInFile.writablecCs
|jSr)rseekablerr7r7r8rsz_FileInFile.seekablecCs|jS)z*Return the current file position.
        )rrr7r7r8rsz_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_ENDrJ)rrwhencer7r7r8rs


z_FileInFile.seekc	Cs
|dkr|j|j}nt||j|j}d}|dkr|j|j\}}}}||jkr`|krhqnqq6|jd7_|jt|jkr6d|_q6t|||j}|r|j||j||j|}t||krt	d||7}n|t
|7}||8}|j|7_q,|S)z!Read data from the file.
        Nrrr#rZ)r'rrrrr1rrr^rr2)	rr'rXdatastartstoprr4rfr7r7r8r^s,

z_FileInFile.readcCs&|t|}||dt|<t|Sr)r^r1)rrfrXr7r7r8readintosz_FileInFile.readintocCs
d|_dSr)rrr7r7r8rsz_FileInFile.close)N)N)rprqrrrsrrrrrrrrrr^rrr7r7r7r8rWs

rcseZdZfddZZS)ExFileObjectcs&t|j|j|j|j}t|dSr)rroffset_datar'sparsesuperr)rtarfiletarinfor	__class__r7r8rs

zExFileObject.__init__)rprqrrr
__classcell__r7r7rr8rsrc@seZdZdZedddddddd	d
ddd
dddddddddZdeddZeddZej	ddZeddZ
e
j	ddZ
ddZd d!Ze
ed"fd#d$Zd%d&Zd'd(Zd)d*Zed+d,Zd-d.Zed/d0Zed1d2Zed3d4Zed5d6Zed7d8Zed9d:Zd;d<Zd=d>Zd?d@ZdAdBZ dCdDZ!dEdFZ"dGdHZ#dIdJZ$dKdLZ%dMdNZ&dOdPZ'dQdRZ(dSdTZ)dUdVZ*dWdXZ+dYdZZ,d[d\Z-d]d^Z.d_d`Z/dadbZ0dcddZ1dS)fraInformational 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.
    zName of the archive member.zPermission bits.z6User ID of the user who originally stored this member.z7Group ID of the user who originally stored this member.zSize in bytes.zTime of last modification.zHeader checksum.zFile type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.zcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.z
User name.zGroup name.zDevice major number.zDevice minor number.zThe tar header starts here.zThe file's data starts here.zMA dictionary containing key-value pairs of an associated pax extended header.zSparse member information.N)rrr)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)rrr)r*r'r(rREGTYPErrr+r,rrrrrrrrr7r7r8rs"zTarInfo.__init__cCs|jS)z(In pax headers, "name" is called "path".rrr7r7r8r%szTarInfo.pathcCs
||_dSrrrr7r7r8r%
scCs|jS)z0In pax headers, "linkname" is called "linkpath".rrr7r7r8r&szTarInfo.linkpathcCs
||_dSrr)rrr7r7r8r&scCsd|jj|jt|fS)Nz<%s %r at %#x>)rrpridrr7r7r8__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.
        )
rrr)r*r'r(rrrr+r,rrrr/)rrr)r*r'r(rrrr+r,rrDIRTYPEr)rinfor7r7r8get_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_headerrJ)rrSr5r6rr7r7r8tobuf2s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_MAGICr1r0LENGTH_LINKrJLENGTH_NAME_posix_split_name_create_headerr
)rrr5r6r7r7r8r@s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.
        rrrr)
	GNU_MAGICr1r0r_create_gnu_long_headerGNUTYPE_LONGLINKrGNUTYPE_LONGNAMErr)rrr5r6rXr7r7r8r	MszTarInfo.create_gnu_headerc
	Cs*t|d<|j}ddtfddtfddfD]j\}}}||kr>q*z||dd	Wn$tk
rv||||<Yq*YnXt|||kr*||||<q*d
D]`\}}||krd||<q||}d|krd|d
krnn
t|t	rt
|||<d||<q|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.
        rrr%rr&)r+r+ )r,r,rrCrD))r)rA)r*rA)r')r(rrrAr#rr)rrcopyrrr0UnicodeEncodeErrorr1
isinstancefloatstr_create_pax_generic_headerXHDTYPErr
)
rrr5rrZhnamer4rRvalrXr7r7r8r
[s8

*
zTarInfo.create_pax_headercCs||tdS)zAReturn the object as a pax global header block sequence.
        r/)rXGLTYPE)clsrr7r7r8create_pax_global_headersz TarInfo.create_pax_global_headercCs~|d}tdt|D]T}d|d|}d||d}t|||tkrt|||tkrqvqtd||fS)zUSplit a name longer than 100 chars into a prefix
           and a name part.
        rr#Nzname is too long)splitrGr1rr0
LENGTH_PREFIXrrJ)rrr5r6Z
componentsrMr
r7r7r8rs
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.
        rrrrrrrAr)r*r'rr(s        rrrr+rr,rrr
rz%dsrNiz%06orCi)r9getrTrrrVrrrrYrO)rrSr5r6partsrXrr7r7r8rs(

&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)r]r1rr2)payloadrdrer7r7r8_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)r0r2r1rrr
r))r"rrr5r6rr7r7r8rszTarInfo._create_gnu_long_headerc	Cs2d}|D]8\}}z|ddWqtk
rBd}YqFYqXqd}|rV|d7}|D]\}}|d}|r||d}n
|d}t|t|d}d	}	}
|tt|
}	|	|
krq|	}
q|tt|
d
d|d|d
7}q^i}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.
        Fr/rDTrs21 hdrcharset=BINARY
rrrrC =
z././@PaxHeaderrrr'rr)
itemsr0rr1rrOrrr
r))r"rrr5binarykeywordvaluerecordslrLr=rr7r7r8rs<

(z"TarInfo._create_pax_generic_headerc	Csvt|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|_|jtkr8d}g}tdD]l}	z0t|||d}
t||d|d}Wntk
rYqYnX||
|f|d7}qt|d}t|dd}
|||
f|_ |!rP|j"d|_|rr|jt#krr|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)$r1rtrrucountr2rvrNrYrKr>rrr)r*r'r(rrrr+r,rrAREGTYPErrGNUTYPE_SPARSErGrJrboolrisdirrstrip	GNU_TYPES)r"rXr5r6robjr
rstructsrMrnumbytes
isextendedorigsizer7r7r8frombufsZ
zTarInfo.frombufcCs8|jt}|||j|j}|jt|_||S)zOReturn the next TarInfo object from TarFile object
           tarfile.
        )	rr^rrGr5r6rr_proc_member)r"rrXrBr7r7r8fromtarfileKs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_sparserr!SOLARIS_XHDTYPE	_proc_pax
_proc_builtin)rrr7r7r8rH`s



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_inforr5r6)rrrr7r7r8rNmszTarInfo._proc_builtincCs|j||j}z||}Wntk
r>tdYnX|j|_|jt	krft
||j|j|_
n|jtkrt
||j|j|_|S)zSProcess the blocks that hold a GNU longname
           or longlink member.
         missing or bad subsequent header)rr^rQr'rIrrwrrrr>r5r6rrr)rrrXnextr7r7r8rJ~s

zTarInfo._proc_gnulongc
	Cs|j\}}}|`|r|jt}d}tdD]n}z0t|||d}t||d|d}	Wntk
rzYqYnX|r|	r|||	f|d7}q,t|d}q||_	|j
|_|j||j
|_||_
|S)z8Process a GNU sparse header plus extra headers.
        rrr:i)rrr^rrGrNrJrr>rrrrQr'r)
rrrCrErFrXrrMrrDr7r7r8rKs(
zTarInfo._proc_sparsecCs.|j||j}|jtkr&|j}n
|j}t	d|}|dk	rX|
dd|d<|d}|dkrr|j
}nd}td}d}|||}|sq6|\}	}
t|	}	|	dkrtd	||d
d|d|	d}||
dd|j}
|
tkr||||j
|j}n||dd|j}|||
<||	7}qz||}Wntk
rbtdYnXd|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#r/
hdrcharsetZBINARYs(\d+) ([^=]+)=rrFr$rSGNU.sparse.mapGNU.sparse.sizezGNU.sparse.major1zGNU.sparse.minorrEr')%rr^rQr'rr!rrresearchgroupr<r&r5compilematchgroupsrHrKrir_decode_pax_fieldr6PAX_NAME_FIELDSrIrrw_proc_gnusparse_01_proc_gnusparse_00_proc_gnusparse_10rrLrRrrrOrP)rrrXrr^rVr5Zregexrr4r/r0rTrr7r7r8rMsh



$	





 
zTarInfo._proc_paxcCshg}td|D]}|t|dqg}td|D]}|t|dq:tt|||_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)rZfinditerrrHr\listzipr)rrTrrXZoffsetsr^rDr7r7r8rcszTarInfo._proc_gnusparse_00cCs@dd|ddD}tt|ddd|ddd|_dS)z?Process a GNU tar extended sparse header, version 0.1.
        cSsg|]}t|qSr7)rH).0xr7r7r8
<listcomp>&sz.TarInfo._proc_gnusparse_01.<locals>.<listcomp>rW,Nr$r#)r$rfrgr)rrTrrr7r7r8rb#szTarInfo._proc_gnusparse_01cCsd}g}|jt}|dd\}}t|}t||dkrtd|krT||jt7}|dd\}}|t|q,|j|_t	t
|ddd|ddd|_dS)z?Process a GNU tar extended sparse header, version 1.0.
        Nr,r#r$)rr^rr$rHr1rrrrfrgr)rrTrrfieldsrrXZnumberr7r7r8rd)szTarInfo._proc_gnusparse_10c	Cs|D]\}}|dkr&t|d|q|dkr@t|dt|q|dkrZt|dt|q|tkr|tkrzt||}Wntk
rd}YnX|dkr|d}t|||q||_dS)	zoReplace fields with supplemental information from a previous
           pax extended or global header.
        zGNU.sparse.namer%rXr'zGNU.sparse.realsizerrN)	r-setattrrH
PAX_FIELDSPAX_NUMBER_FIELDSrJr@rr)rrr5r6r/r0r7r7r8rR9s"

zTarInfo._apply_pax_infocCs4z||dWStk
r.|||YSXdS)z1Decode a single field from a pax record.
        rDN)r<UnicodeDecodeError)rr0r5Zfallback_encodingZfallback_errorsr7r7r8r`PszTarInfo._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#)r]r)rr;rdrer7r7r8rQXszTarInfo._blockcCs
|jtkSz4Return True if the Tarinfo object is a regular file.)r
REGULAR_TYPESrr7r7r8rOasz
TarInfo.isregcCs|Srq)rOrr7r7r8isfileeszTarInfo.isfilecCs
|jtkS)z!Return True if it is a directory.)rrrr7r7r8r?isz
TarInfo.isdircCs
|jtkS)z%Return True if it is a symbolic link.)rSYMTYPErr7r7r8issymmsz
TarInfo.issymcCs
|jtkS)z!Return True if it is a hard link.)rLNKTYPErr7r7r8islnkqsz
TarInfo.islnkcCs
|jtkS)z(Return True if it is a character device.)rCHRTYPErr7r7r8ischrusz
TarInfo.ischrcCs
|jtkS)z$Return True if it is a block device.)rBLKTYPErr7r7r8isblkysz
TarInfo.isblkcCs
|jtkS)zReturn True if it is a FIFO.)rFIFOTYPErr7r7r8isfifo}szTarInfo.isfifocCs
|jdk	Sr)rrr7r7r8issparseszTarInfo.issparsecCs|jtttfkS)zCReturn True if it is one of character device, block device or FIFO.)rrxrzr|rr7r7r8isdevsz
TarInfo.isdev)r)2rprqrrrsdict	__slots__rpropertyr%setterr&rrrrrrr	r
classmethodr#rstaticmethodrr)rrrGrIrHrNrJrKrMrcrbrdrRr`rQrOrsr?rurwryr{r}r~rr7r7r7r8rs





1


	

2
>

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#Nrzrc
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|_z|jdkrd
|_ |!|_ |jdkr2|j"|jz|j#|}|j$|WnXt%k
r|j"|jYq2Yn0t&k
r,}zt't|W5d
}~XYnXq|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+bwbxbrzar{ri!mode must be 'r', 'a', 'w' or 'x'rr{FNrrTrzrr{ri)-rJr_moder}r%exists	bltn_openrrrrrrOabspathrrSrdereferenceignore_zerosr5r6rrdebug
errorlevelcopybufsizermembers_loadedrrinodesfirstmemberrTrrIrrvrrr#rr_r1r)rrrrrSrrrr5r6rrrrZmodeserXr7r7r8rs






"
zTarFile.__init__c

s|s|std|dkrfdd}tj|dD]j}tj|}|dk	rV|}	z||d|f|WSttfk
r|dk	r||	Yq2Yq2Xq2tdnd	|kr|d	d
\}
}|
pd}
|pd}|jkrtj|}ntd||||
|f|Sd
|kr|d
d
\}
}|
p.d}
|p8d}|
dkrLtdt	||
|||}z||
|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)rzr:*csj|dkS)Ntaropen)	OPEN_METH)rr"r7r8not_compressed<sz$TarFile.open.<locals>.not_compressedkeyNrzz%file could not be opened successfully:r#rr|ryzmode must be 'r' or 'w'Frzundiscernible mode)
rJsortedrrjrrrrr$rrrr)
r"rrrrckwargsrrfuncZ	saved_posfilemodestreamrr7rr8rsP%







zTarFile.opencKs |dkrtd||||f|S)zCOpen uncompressed tar archive name for reading or writing.
        rr)rJ)r"rrrrr7r7r8rmszTarFile.taropenrcKs|dkrtdzddlm}Wntk
r<tdYnXz|||d||}Wn.tk
r|dk	r||dkr|td	YnXz|j|||f|}WnBtk
r||dkrtd	Yn|YnXd
|_	|S)zkOpen gzip compressed tar archive name for reading or writing.
           Appending is not allowed.
        rzr{rimode must be 'r', 'w' or 'x'r)GzipFilezgzip module is not availablerfNrzrF)
rJgziprrrrrrrr)r"rrr
compresslevelrrrr7r7r8gzopenus0zTarFile.gzopenc	Ks|dkrtdzddlm}Wntk
r<tdYnX||pF|||d}z|j|||f|}WnFttfk
r||dkrt	dYn|YnXd	|_
|S)
zlOpen bzip2 compressed tar archive name for reading or writing.
           Appending is not allowed.
        rrr)BZ2Filer)rrzznot a bzip2 fileF)rJrrrrrrEOFErrorrrr)r"rrrrrrrr7r7r8bz2opens&zTarFile.bz2openc		Ks|dkrtdzddlm}m}Wntk
r@tdYnX||pJ|||d}z|j|||f|}WnF|tfk
r||dkrt	dYn|YnXd	|_
|S)
zkOpen lzma compressed tar archive name for reading or writing.
           Appending is not allowed.
        rrr)LZMAFilerr)presetrzznot an lzma fileF)rJrrrrrrrrrr)	r"rrrrrrrrr7r7r8xzopens&zTarFile.xzopenrrrr)rrrrcCs|jr
dSd|_z`|jdkrn|jttd|jtd7_t	|jt
\}}|dkrn|jtt
|W5|js|jXdS)zlClose the TarFile. In write-mode, two finishing zero blocks are
           appended to the archive.
        NTrr$r)rrrrrr_r2rrr]
RECORDSIZE)rrdrer7r7r8rs
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)rrrr7r7r8	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.
        )_checkr_loadrrr7r7r8
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|]
}|jqSr7r)rhrr7r7r8rjsz$TarFile.getnames.<locals>.<listcomp>)rrr7r7r8getnamesszTarFile.getnamescCs^|d|dk	r|j}|dkr$|}tj|\}}|tjd}|d}|}||_	|dkr|j
stt|}qt|}nt
|}d}|j}t|r|j|jf}	|j
s|jdkr|	|jkr||j|	krt}
|j|	}nt}
|	dr||j|	<nht|rt}
nVt|r"t}
nDt|r>t}
t|}n(t|rPt}
nt |rbt!}
ndS||_||_"|j#|_$|j%|_&|
tkr|j'|_(nd|_(|j)|_*|
|_+||_,t-rzt-.|j$d|_/Wnt0k
rYnXt1rzt12|j&d|_3Wnt0k
rYnX|
tt!fkrZt4tdrZt4tdrZt5|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.
        awxNrrr#rmajorminor):rrr}r%
splitdriverseplstriprrrlstatstatfstatfilenost_modeS_ISREGst_inost_devst_nlinkrrvrS_ISDIRrS_ISFIFOr|S_ISLNKrtreadlinkS_ISCHRrxS_ISBLKrzrst_uidr)st_gidr*st_sizer'st_mtimer(rrpwdgetpwuidr+rgrpgetgrgidr,rrst_rdevrrr)rrarcnamerZdrvrZstatresrZstmdinoderr7r7r8
gettarinfo	s	




zTarFile.gettarinfoT)rcCs||dkr|}|D]}|rtt|jtd|jp>|j|jpH|jf|	s`|
rztdd|j|jfntd|j
tdt|jddt|j|rdnd	|r|rtd
|j|rtd|jtqdS)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 )rrnrrrr+r)r,r*ryr{rrr'r	localtimer(rr?rurrwrm)rverboserrr7r7r8rfls0
zTarFile.listfilterc	Cs6|d|dkr|}|jdk	rFtj||jkrF|dd|dS|d||||}|dkrz|dd|dS|dk	r||}|dkr|dd|dS|rt|d}|	||W5QRXn`|
r(|	||r2tt|D]*}|j
tj||tj||||d	qn
|	|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 %rrr)rrr}r%r_dbgrrOraddfiler?rlistdiraddr)rrr	recursiverrfr7r7r8rs8




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)rcrr#)rrrrSr5r6rr_rr1rr\r'r]rr2rr)rrrrXrcrdrer7r7r8rs

zTarFile.addfile.
numeric_ownercCsg}|dkr|}|D]>}|r:||t|}d|_|j||||dq|jddd||D]}tj	||j
}z,|j|||d||||
||Wqptk
r}z"|jdkrЂn|dd	|W5d}~XYqpXqpdS)
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.
        N	set_attrsrcSs|jSrr)rr7r7r8<lambda>rz$TarFile.extractall.<locals>.<lambda>rrr#tarfile: %s)r?rrrextractsortreverser}r%rrchownutimechmodr
rr)rr%rrZdirectoriesrdirpathrr7r7r8
extractalls.


zTarFile.extractallrc
Cs|dt|tr ||}n|}|r>tj||j|_	z"|j
|tj||j||dWntk
r}zH|j
dkrn6|jdkr|dd|jn|dd|j|jfW5d}~XYnBtk
r}z"|j
dkrn|dd|W5d}~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.
        rzrrNr#rztarfile: %s %r)rrrrrwr}r%rrr_extract_memberrrrfilenamerstrerrorr
)rmemberr%rrrrr7r7r8rs*	




(
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.
        rzz'cannot extract (sym)link as file objectN)rrrrrOrrP
fileobjectrwrurrr	extractfile_find_link_target)rrrr7r7r8r&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)r@rr}rr%dirnamermakedirsrwrurrrrOmakefiler?makedirr}makefiforyr{makedevmakelinkrrPmakeunknownrrr)rr
targetpathrrZ	upperdirsr7r7r8rEs4


zTarFile._extract_membercCs*zt|dWntk
r$YnXdS)z,Make a directory called targetpath.
        rN)r}mkdirFileExistsErrorrrrr7r7r8rvszTarFile.makedirc	Cs|j}||j|j}t|db}|jdk	rn|jD]"\}}||t|||t|q4||j|	nt|||jt|W5QRXdS)z'Make a file called targetpath.
        rN)
rrrrrrr\rr'truncate)rrrsourcerctargetrr'r7r7r8rs


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)rrrr
r7r7r8rszTarFile.makeunknowncCs"ttdrt|ntddS)z'Make a fifo called targetpath.
        mkfifozfifo not supported by systemN)rr}rr
r
r7r7r8rs
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
rr{rS_IFBLKS_IFCHRrrrr)rrrrr7r7r8rs
zTarFile.makedevcCszb|r0tj|r t|t|j|n0tj|jrNt	|j|n|
|||WnHtk
rz|
|||Wnt
k
rtdYnXYnXdS)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)rur}r%lexistsunlinksymlinkrrrlinkrrsymlink_exceptionrr
r
r7r7r8rs"
zTarFile.makelinkcCsttdrtdkr|j}|j}|sztr<t|jd}Wntk
rRYnXzt	rjt	
|jd}Wntk
rYnXz4|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)rgetgrnamr,rrgetpwnamr+rurrrr
)rrrrgur7r7r8rs(z
TarFile.chowncCs4zt||jWntk
r.tdYnXdS)zASet file permissions of targetpath according to tarinfo.
        zcould not change modeN)r}rrrr
r
r7r7r8rsz
TarFile.chmodcCsHttdsdSzt||j|jfWntk
rBtdYnXdS)zBSet modification time of targetpath according to tarinfo.
        rNz"could not change modification time)rr}rr(rr
r
r7r7r8rs
z
TarFile.utimec
Cs|d|jdk	r$|j}d|_|S|j|jkrZ|j|jd|jdsZtdd}z|j	|}Wqt
k
r}z6|jr|dd|j|f|jt
7_WYq^W5d}~XYqtk
r6}zR|jr|dd|j|f|jt
7_WY q^n|jdkr&tt|W5d}~XYntk
r^|jdkrZtdYnjtk
r}z|jdkrtt|W5d}~XYn0tk
r}ztt|W5d}~XYnXqq^|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#rZr$z0x%X: %srz
empty fileT)rrrrrrr^rrrIrvrrrrKrrtrurwrrr)rmrrr7r7r8rTsJ



zTarFile.nextcCsn|}|dk	r"|d||}|r2tj|}t|D].}|rRtj|j}n|j}||kr:|Sq:dS)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	normalizerrmember_namer7r7r8r/	szTarFile._getmembercCs|}|dkrqqd|_dS)zWRead through the entire archive file and look for readable
           members.
        NT)rTr)rrr7r7r8rF	sz
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)rrrrpr)rrr7r7r8rP	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)rr!zlinkname %r not found)
rurrr}r%rrrrr)rrrlimitrr7r7r8rY	s zTarFile._find_link_targetccs|jr|jEdHdSd}|jdk	r:|}|d7}|V|t|jkrT|j|}n"|jsr|}|svd|_dSndS|d7}|Vq:dS)z$Provide an iterator object.
        Nrr#T)rrrrTr1)rrrr7r7r8__iter__l	s$
zTarFile.__iter__cCs||jkrt|tjddS)z.Write debugging output to sys.stderr.
        fileN)rrmrkstderr)rlevelmsgr7r7r8r	s
zTarFile._dbgcCs||Sr)rrr7r7r8	__enter__	szTarFile.__enter__cCs,|dkr|n|js"|jd|_dSr)rrrr)rrr0	tracebackr7r7r8__exit__	s


zTarFile.__exit__)
NrzNNNNNNrNNNN)rzN)rzNr)rzNr)rzNN)NNN)T)NT)N)rN)rT)TF)NF)N)8rprqrrrsrrrrrrSrr5r6rrrrrrrrrrrrrrrrrrrfrrrrrrrrrrrrrrrrTrrrrr$rr*r,r7r7r7r8rs
oZ 


c 3
(&
1
6


	cCs2zt|}|WdStk
r,YdSXdS)zfReturn True if name points to a tar archive that we
       are able to handle, else return False.
    TFN)rrr)rrr7r7r8r	sc	Csddl}d}|j|d}|jdddddd	|jd
d}|jdd
ddd|jdddddd|jdddddd|jddddd|}|jdk	r|j}t|rt|d }|t	|t
jdW5QRX|jrt	d 
|n|d!d"
|n|jdk	r\|j}t|rFt|d#}|j|jd$W5QRXn|d!d"
|nr|jdk	r,t|jd!kr|jd}tj}n,t|jd%kr|j\}}n|d!|t|rt|d#}|j|d&W5QRX|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|
|}|D]}||qW5QRX|jrt	d0
|
dS)1Nrz3A simple command-line interface for tarfile module.)descriptionz-vz	--verbose
store_trueFzVerbose output)actiondefaulthelpT)requiredz-lz--list	<tarfile>zShow listing of a tarfile)metavarr1z-ez	--extract+)r3z<output_dir>zExtract tarfile into target dir)nargsr4r1z-cz--create)z<name>z<file>zCreate tarfile from sourcesz-tz--testzTest if a tarfile is validrzr%z{!r} is a tar archive.r#z{!r} is not a tar archive.
r)rr$)r%rz{!r} file is extracted.z+{!r} file is extracted into {!r} directory.rrr)rz.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:r{z{!r} file created.)argparseArgumentParseradd_argumentadd_mutually_exclusive_group
parse_argstestrrrrmrkr'rrSexitrfrrr1r}curdirformat_helprZcreatepopr%splitextr)r7r-parserr\argsr`rZtfr>r)Ztar_name_extZcompressionsZtar_modeZ	tar_files	file_namer7r7r8main	s









rG__main__)^rsversion
__author____credits__builtinsrrrkr}rr[rrrVrrZrrrAttributeErrorNotImplementedErrorrr	NameError__all__r2rrrrrrr%rr<rvrtrxrzrr|ZCONTTYPErrr=rr!rLr
rrrrPrrrArnrarrHrorrgetfilesystemencodingr9r>rNrTrYr\rn	Exceptionrr
rrr	rrtrurvrKrwrxrobjectrrBufferedReaderrrrrrGrpr7r7r7r8<module>s



shD!W


Zerion Mini Shell 1.0