Hacked By AnonymousFox

Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/tarfile.cpython-38.opt-2.pyc

U

i�f/��@sdZdZdZddlmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZzddlZWnek
r�dZYnXzddlZWnek
r�dZYnXeefZzeef7ZWnek
r�YnXdddd	d
ddd
dddddddgZdZdZedZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%d Z&d!Z'd"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d)Z/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.d/d0hZ8e9e9e9e:e:e:d1�Z;ej<d2k�r�d3Z=ne�>�Z=d4d5�Z?d6d7�Z@d8d9�ZAd:e3fd;d<�ZBd=d>�ZCdedfd?d@�ZDdAdB�ZEGdCd	�d	eF�ZGGdDd
�d
eG�ZHGdEd
�d
eG�ZIGdFd�deG�ZJGdGd�deG�ZKGdHd�deG�ZLGdIdJ�dJeL�ZMGdKdL�dLeL�ZNGdMdN�dNeL�ZOGdOdP�dPeL�ZPGdQdR�dReL�ZQGdSdT�dT�ZRGdUdV�dV�ZSGdWdX�dXeT�ZUGdYdZ�dZeT�ZVGd[d\�d\ejW�ZXGd]d^�d^eG�ZYGd_d`�d`eY�ZZGdadb�dbeY�Z[Gdcdd�ddeY�Z\Gdedf�dfeY�Z]Gdgdh�dheY�Z^dzdjdk�Z_dldm�Z`dndo�Zadpdq�Zbe`eaebdr�ZceT�Zde�eds�ZfGdtd�deT�ZgGdud�deT�Zhdvd�ZiehjZdwdx�Zjekdyk�rej�dS){z0.9.0u"Lars Gustäbel (lars@gustaebel.de)u4Gustavo Niemeyer, Niels Gustäbel, Richard Townsend.�)�openN�TarFile�TarInfo�
is_tarfile�TarError�	ReadError�CompressionError�StreamError�ExtractError�HeaderError�ENCODING�USTAR_FORMAT�
GNU_FORMAT�
PAX_FORMAT�DEFAULT_FORMATr�i�sustar  sustar00�d��0�1�2�3�4�5�6�7�L�K�S�x�g�X��)�path�linkpath�size�mtime�uid�gid�uname�gnamer%r&r+r,)Zatime�ctimer(r)r*r'�nt�utf-8cCs8|dkrtd��|�||�}|d|�|t|�tS)Nzmetadata cannot contain None)�
ValueError�encode�len�NUL)�s�length�encoding�errors�r8�,/opt/alt/python38/lib64/python3.8/tarfile.py�stn�sr:cCs*|�d�}|dkr|d|�}|�||�S)Nr���)�find�decode)r4r6r7�pr8r8r9�nts�s
r?cCs�|ddkrbd}tt|�d�D]}|dK}|||d7}q |ddkr�dt|�d|}n@z"t|dd�}t|��p|d	d�}Wntk
r�td
��YnX|S)Nr)��r#�rA��ascii�strict�0�invalid header)�ranger2r?�int�stripr0�InvalidHeaderError)r4�n�ir8r8r9�nti�srNrBcCs�t|�}d|kr$d|dkrDnntd|d|fd�t}n�|tkr�d|d|krrd|dkr�nnV|dkr�tdg�}ntdg�}d||}t|d�D]}|�d|d@�|dL}q�ntd	��|S)
NrrBr#z%0*orDrCr@rAzoverflow in number field)rI�bytesr3r�	bytearrayrH�insertr0)rL�digits�formatr4rMr8r8r9�itn�s 2
rTcCs0dtt�d|��}dtt�d|��}||fS)NrCZ
148B8x356BZ
148b8x356b)�sum�structZunpack_from)�bufZunsigned_chksumZ
signed_chksumr8r8r9�calc_chksums�s	rXc	Cs�|pd}|dkrdS|dkr.t�|||�dSt||�\}}t|�D],}|�|�}t|�|krf|d��|�|�qD|dkr�|�|�}t|�|kr�|d��|�|�dS)Ni@r�unexpected end of data)�shutil�copyfileobj�divmodrH�readr2�write)	�srcZdstr5�	exception�bufsize�blocks�	remainder�brWr8r8r9r[�s$


r[cCs8ttjdd�}|dk	r(|�|d��|�}t|dd�dS)Nr6�backslashreplace� )�end)�getattr�sys�stdoutr1r=�print)r4r6r8r8r9�_safe_printsrlc@seZdZdS)rN��__name__�
__module__�__qualname__r8r8r8r9rsc@seZdZdS)r
Nrmr8r8r8r9r
sc@seZdZdS)rNrmr8r8r8r9rsc@seZdZdS)rNrmr8r8r8r9rsc@seZdZdS)r	Nrmr8r8r8r9r	sc@seZdZdS)rNrmr8r8r8r9rsc@seZdZdS)�EmptyHeaderErrorNrmr8r8r8r9rq srqc@seZdZdS)�TruncatedHeaderErrorNrmr8r8r8r9rr#srrc@seZdZdS)�EOFHeaderErrorNrmr8r8r8r9rs&srsc@seZdZdS)rKNrmr8r8r8r9rK)srKc@seZdZdS)�SubsequentHeaderErrorNrmr8r8r8r9rt,srtc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
_LowLevelFilecCsFtjtjtjBtjBd�|}ttd�r2|tjO}t�||d�|_dS)N��r�w�O_BINARYi�)	�os�O_RDONLY�O_WRONLY�O_CREAT�O_TRUNC�hasattrryr�fd)�self�name�moder8r8r9�__init__9s��

z_LowLevelFile.__init__cCst�|j�dS�N)rz�closer��r�r8r8r9r�Bsz_LowLevelFile.closecCst�|j|�Sr�)rzr]r��r�r'r8r8r9r]Esz_LowLevelFile.readcCst�|j|�dSr�)rzr^r��r�r4r8r8r9r^Hsz_LowLevelFile.writeN)rnrorpr�r�r]r^r8r8r8r9ru3s	ruc@sneZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�ZdS)�_Streamc	Cs�d|_|dkrt||�}d|_|dkr6t|�}|��}|p<d|_||_||_||_||_d|_	d|_
d|_�zL|dkr�zddl}Wnt
k
r�td��YnX||_|�d�|_|d	kr�|��|j|_n|��n�|d
k�r:zddl}Wnt
k
�r
td��YnX|d	k�r.d|_|��|_t|_n
|��|_n||dk�r�zddl}Wnt
k
�rntd
��YnX|d	k�r�d|_|��|_|j|_n
|��|_n|dk�r�td|��Wn&|j�s�|j��d|_�YnXdS)NTF�*��r�gzzzlib module is not availablerw�bz2�bz2 module is not available�xz�lzma module is not available�tar�unknown compression type %r) �_extfileobjru�_StreamProxy�getcomptyper�r��comptype�fileobjrarW�pos�closed�zlib�ImportErrorr�crc32�crc�
_init_read_gz�errorr`�_init_write_gzr��dbufZBZ2Decompressor�cmp�OSErrorZ
BZ2Compressor�lzmaZLZMADecompressor�	LZMAErrorZLZMACompressorr�)	r�r�r�r�r�rar�r�r�r8r8r9r�Vsl












z_Stream.__init__cCst|d�r|js|��dS)Nr�)rr�r�r�r8r8r9�__del__�sz_Stream.__del__cCs�|j�d|jj|jj|jjd�|_t�dtt	�	���}|�
d|d�|j�d�rf|jdd�|_t
j�|j�|_|�
|j�dd	�t�dS)
N�	r�<Ls�s��.gz���z
iso-8859-1�replace)r�ZcompressobjZDEFLATED�	MAX_WBITSZ
DEF_MEM_LEVELr�rV�packrI�time�_Stream__writer��endswithrzr%�basenamer1r3)r�Z	timestampr8r8r9r��s�z_Stream._init_write_gzcCsR|jdkr|j�||j�|_|jt|�7_|jdkrD|j�|�}|�|�dS)Nr�r�)	r�r�r�r�r�r2r��compressr�r�r8r8r9r^�s

z
_Stream.writecCsN|j|7_t|j�|jkrJ|j�|jd|j��|j|jd�|_qdSr�)rWr2rar�r^r�r8r8r9Z__write�sz_Stream.__writecCs�|jr
dSd|_z�|jdkr:|jdkr:|j|j��7_|jdkr�|jr�|j�	|j�d|_|jdkr�|j�	t
�d|j��|j�	t
�d|j
d@��W5|js�|j��XdS)NTrxr�r�r�r�l��)r�r�r�r�r�r�rWr��flushr^rVr�r�r�r�r8r8r9r��s
z
_Stream.closecCs�|j�|jj�|_d|_|�d�dkr0td��|�d�dkrFtd��t|�d��}|�d�|d	@r�t|�d��d
t|�d��}|�	|�|d@r�|�d�}|r�|t
kr�q�q�|d@r�|�d�}|r�|t
kr�q�q�|d@r�|�d�dS)
Nr�r$s��not a gzip filer#�zunsupported compression method��rCrB�)r�Z
decompressobjr�r�r��
_Stream__readrr�ordr]r3)r��flagZxlenr4r8r8r9r��s*
 


z_Stream._init_read_gzcCs|jSr�)r�r�r8r8r9�tell�sz_Stream.tellrcCsX||jdkrJt||j|j�\}}t|�D]}|�|j�q,|�|�ntd��|jS)Nrz seeking backwards is not allowed)r�r\rarHr]r	)r�r�rbrcrMr8r8r9�seek�sz_Stream.seekcCs |�|�}|jt|�7_|Sr�)�_readr�r2)r�r'rWr8r8r9r]
s
z_Stream.readcCs�|jdkr|�|�St|j�}|jg}||kr�|jrB|j}d|_n|j�|j�}|sVq�z|j�	|�}Wn|j
k
r�td��YnX|�|�|t|�7}q&d�
|�}||d�|_|d|�S)Nr�r�zinvalid compressed data)r�r�r2r�rWr�r]rar��
decompressr`r�append�join�r�r'�c�trWr8r8r9r�s(




z
_Stream._readcCsjt|j�}|jg}||krF|j�|j�}|s.qF|�|�|t|�7}qd�|�}||d�|_|d|�S)Nr�)r2rWr�r]rar�r�r�r8r8r9Z__read,s


z_Stream.__readN)r)rnrorpr�r�r�r^r�r�r�r�r�r]r�r�r8r8r8r9r�KsF
	

r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs||_|j�t�|_dSr�)r�r]�	BLOCKSIZErW)r�r�r8r8r9r�Bsz_StreamProxy.__init__cCs|jj|_|jSr�)r�r]rWr�r8r8r9r]Fs
z_StreamProxy.readcCsP|j�d�rdS|jdd�dkr8|jdd�dkr8d	S|j�d
�rHdSdSdS)
Ns�r�r�sBZhr��
s1AY&SYr�)s]�s�7zXZr�r�)rW�
startswithr�r8r8r9r�Js$z_StreamProxy.getcomptypecCs|j��dSr�)r�r�r�r8r8r9r�Tsz_StreamProxy.closeN)rnrorpr�r]r�r�r8r8r8r9r�=s
r�c@sfeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Ze	j
fdd�Zddd�Zdd�Z
dd�ZdS)�_FileInFileNcCs�||_||_||_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||jdf�dS)Nrr�FT)
r��offsetr'�positionrhr�r��	map_index�mapr�)r�r�r�r'Z	blockinfoZlastposZrealposr8r8r9r�as(


z_FileInFile.__init__cCsdSr�r8r�r8r8r9r�zsz_FileInFile.flushcCsdS�NTr8r�r8r8r9�readable}sz_FileInFile.readablecCsdS)NFr8r�r8r8r9�writable�sz_FileInFile.writablecCs
|j��Sr�)r��seekabler�r8r8r9r��sz_FileInFile.seekablecCs|jSr�)r�r�r8r8r9r��sz_FileInFile.tellcCs�|tjkr tt|d�|j�|_nj|tjkr\|dkrFt|j|d�|_q�t|j||j�|_n.|tjkr�tt|j||j�d�|_ntd��|jS)NrzInvalid argument)	�io�SEEK_SET�min�maxr'r��SEEK_CUR�SEEK_ENDr0)r�r��whencer8r8r9r��s


z_FileInFile.seekc	Cs
|dkr|j|j}nt||j|j�}d}|dk�r|j|j\}}}}||jkr`|krhq�nq�q6|jd7_|jt|j�kr6d|_q6t|||j�}|r�|j�||j|�|j�|�}t|�|kr�t	d��||7}n|t
|7}||8}|j|7_q,|S)Nr�rr#rY)r'r�r�r�r�r2r�r�r]rr3)	r�r'rW�data�start�stopr�r5rdr8r8r9r]�s,

z_FileInFile.readcCs&|�t|��}||dt|��<t|�Sr�)r]r2)r�rdrWr8r8r9�readinto�sz_FileInFile.readintocCs
d|_dSr�)r�r�r8r8r9r��sz_FileInFile.close)N)N)rnrorpr�r�r�r�r�r�r�r�r�r]r�r�r8r8r8r9r�[s

r�cseZdZ�fdd�Z�ZS)�ExFileObjectcs&t|j|j|j|j�}t��|�dSr�)r�r��offset_datar'�sparse�superr�)r��tarfile�tarinfor���	__class__r8r9r��s

�zExFileObject.__init__�rnrorpr��
__classcell__r8r8r�r9r��sr�c@seZdZdS)�FilterErrorNrmr8r8r8r9r��sr�cseZdZ�fdd�Z�ZS)�AbsolutePathErrorcs ||_t��d|j�d��dS)Nzmember z has an absolute path�r�r�r�r��r�r�r�r8r9r��szAbsolutePathError.__init__r�r8r8r�r9r��sr�cseZdZ�fdd�Z�ZS)�OutsideDestinationErrorcs.||_||_t��|j�d|�d�d�dS)Nz would be extracted to �, � which is outside the destination�r��_pathr�r�r��r�r�r%r�r8r9r��s
�z OutsideDestinationError.__init__r�r8r8r�r9r��sr�cseZdZ�fdd�Z�ZS)�SpecialFileErrorcs||_t��|j�d��dS)Nz is a special filer�r�r�r8r9r��szSpecialFileError.__init__r�r8r8r�r9r��sr�cseZdZ�fdd�Z�ZS)�AbsoluteLinkErrorcs||_t��|j�d��dS)Nz is a link to an absolute pathr�r�r�r8r9r��szAbsoluteLinkError.__init__r�r8r8r�r9r��sr�cseZdZ�fdd�Z�ZS)�LinkOutsideDestinationErrorcs.||_||_t��|j�d|�d�d�dS)Nz would link to r�r�r�r�r�r8r9r��s
�z$LinkOutsideDestinationError.__init__r�r8r8r�r9r��sr�TcCs�i}|j}tj�|�}|�dtjf�r@|j�dtj�}|d<tj�|�rTt|��tj�tj�	||��}tj�
||g�|kr�t||��|j}|dk	r�|d@}|r�|�
�s�|��r�|d@s�|dM}|dO}n|��s�|��r�d}nt|��||jkr�||d<|�r�|jdk	�rd|d<|jdk	�r*d|d	<|jdk	�r>d|d
<|jdk	�rRd|d<|���sf|���r�tj�|j��r~t|��|���r�tj�	|tj�|�|j�}ntj�	||j�}tj�|�}tj�
||g�|k�r�t||��|S)N�/r�i��@i�����r�r)r*r+r,)r�rzr%�realpathr��sep�lstrip�isabsr�r��
commonpathr�r��isreg�islnk�isdir�issymr�r)r*r+r,�linknamer��dirnamer�)�member�	dest_pathZfor_data�	new_attrsr�Ztarget_pathr�r8r8r9�_get_filtered_attrs�s^




��
rcCs|Sr�r8)rrr8r8r9�fully_trusted_filter/srcCs(t||d�}|r$|jf|ddi��S|S)NF�deep�rr��rrrr8r8r9�
tar_filter2srcCs(t||d�}|r$|jf|ddi��S|S)NTr	Fr
rr8r8r9�data_filter8sr
)Z
fully_trustedr�r�s([0-9]{1,20}) c@s�eZdZeddddddddd	d
ddd
dddddddd�Zdhdd�Zedd��Zejdd��Zedd��Z	e	jdd��Z	dd�Z
eeeeeeeeded �
d!d"�Zd#d$�Z
eed%fd&d'�Zd(d)�Zd*d+�Zd,d-�Zed.d/��Zd0d1�Zed2d3��Zed4d5��Zed6d7��Zed8d9��Zed:d;��Zed<d=��Zd>d?�Zd@dA�ZdBdC�Z dDdE�Z!dFdG�Z"dHdI�Z#dJdK�Z$dLdM�Z%dNdO�Z&dPdQ�Z'dRdS�Z(dTdU�Z)dVdW�Z*dXdY�Z+dZd[�Z,d\d]�Z-d^d_�Z.d`da�Z/dbdc�Z0ddde�Z1dfdg�Z2dS)irzName of the archive member.zPermission bits.z6User ID of the user who originally stored this member.z7Group ID of the user who originally stored this member.zSize in bytes.zTime of last modification.zHeader checksum.z�File type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.zcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.z
User name.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)r�r�r)r*r'r(�chksum�typerr+r,�devmajor�devminorr�r��pax_headersr�r��_sparse_structs�_link_targetr�cCsj||_d|_d|_d|_d|_d|_d|_t|_d|_	d|_
d|_d|_d|_
d|_d|_d|_i|_dS)Ni�rr�)r�r�r)r*r'r(r�REGTYPErrr+r,rrr�r�r�r�r�r�r8r8r9r�qs"zTarInfo.__init__cCs|jSr��r�r�r8r8r9r%�szTarInfo.pathcCs
||_dSr�rrr8r8r9r%�scCs|jSr��rr�r8r8r9r&�szTarInfo.linkpathcCs
||_dSr�r)r�rr8r8r9r&�scCsd|jj|jt|�fS)Nz<%s %r at %#x>)r�rnr��idr�r8r8r9�__repr__�szTarInfo.__repr__T)
r�r(r�rr)r*r+r,r	�_KEEPc
Cs�|	rt�|�}n
t�|�}||
k	r(||_||
k	r6||_||
k	rD||_||
k	rR||_||
k	r`||_||
k	rn||_||
k	r|||_||
k	r�||_	|Sr�)
�copyZdeepcopyr�r(r�rr)r*r+r,)r�r�r(r�rr)r*r+r,r	r�resultr8r8r9r��s(
zTarInfo.replacecCs�|jdkrd}n
|jd@}|j||j|j|j|j|j|j|j|j	|j
|j|jd�
}|dt
kr||d�d�s||dd7<|S)N�)
r�r�r)r*r'r(rrrr+r,rrrr�r�)r�r�r)r*r'r(rrrr+r,rr�DIRTYPEr�)r�r��infor8r8r9�get_info�s(

�zTarInfo.get_info�surrogateescapecCsz|��}|��D]\}}|dkrtd|��q|tkrD|�|||�S|tkrZ|�|||�S|tkrn|�||�Std��dS)Nz%s may not be Nonezinvalid format)	r!�itemsr0r
�create_ustar_headerr�create_gnu_headerr�create_pax_header)r�rSr6r7r r��valuer8r8r9�tobuf�sz
TarInfo.tobufcCsnt|d<t|d�||��tkr(td��t|d�||��tkr^|�|d||�\|d<|d<|�|t||�S)N�magicrzlinkname is too longr��prefix)	�POSIX_MAGICr2r1�LENGTH_LINKr0�LENGTH_NAME�_posix_split_name�_create_headerr
)r�r r6r7r8r8r9r$�szTarInfo.create_ustar_headercCs�t|d<d}t|d�||��tkr<||�|dt||�7}t|d�||��tkrl||�|dt||�7}||�|t	||�S)Nr)r�rr�)
�	GNU_MAGICr2r1r,�_create_gnu_long_header�GNUTYPE_LONGLINKr-�GNUTYPE_LONGNAMEr/r)r�r r6r7rWr8r8r9r%�szTarInfo.create_gnu_headerc
	Cs*t|d<|j��}ddtfddtfddfD]j\}}}||kr>q*z||�dd	�Wn$tk
rv||||<Yq*YnXt||�|kr*||||<q*d
D]`\}}||kr�d||<q�||}d|kr�d|d
kr�nn
t|t	�r�t
|�||<d||<q�|�r|�|t|�}	nd}	|	|�
|tdd�S)Nr)r�r%rr&)r+r+� )r,r,r4rDrE))r)rB)r*rB)r'�)r(r5rrBr#r�r�)r+rrr-r,r1�UnicodeEncodeErrorr2�
isinstance�float�str�_create_pax_generic_header�XHDTYPEr/r
)
r�r r6rr�Zhnamer5rR�valrWr8r8r9r&s8
�
*
zTarInfo.create_pax_headercCs|�|td�S)Nr/)r:�XGLTYPE)�clsrr8r8r9�create_pax_global_header3sz TarInfo.create_pax_global_headercCs~|�d�}tdt|��D]T}d�|d|��}d�||d��}t|�||��tkrt|�||��tkrqvqtd��||fS)Nr�r#zname is too long)�splitrHr2r�r1�
LENGTH_PREFIXr-r0)r�r�r6r7Z
componentsrMr*r8r8r9r.9s
�zTarInfo._posix_split_namecCs�|�d�ttfk}|r@t|�dd�d|�}t|�dd�d|�}ntdd||�}tdd||�}|�dt�}|dkrxtd��t|�dd�d	||�t|�d
d�d@d|�t|�dd�d|�t|�d
d�d|�t|�dd�d|�t|�dd�d|�d|t|�dd�d	||�|�dt�t|�dd�d||�t|�dd�d||�t|�dd�d|�t|�dd�d|�t|�dd�d||�g}t�	dt
d�|��}	t|	t
d��d}
|	dd�t
d|
d�|	dd�}	|	S)NrrrrBrr�zTarInfo.type must not be Noner�rr�rr)r*r'r5r(s        rr)r+r4r,r*rz%dsr�i����z%06orDi����)�get�CHRTYPE�BLKTYPErTr:rr0r+rVr�r�r�rXrO)r rSr6r7Zhas_device_fieldsrrZfiletype�partsrWrr8r8r9r/Is:
�&zTarInfo._create_headercCs.tt|�t�\}}|dkr*|t|t7}|S)Nr)r\r2r�r3)Zpayloadrbrcr8r8r9�_create_payloadsszTarInfo._create_payloadcCsR|�||�t}i}d|d<||d<t|�|d<t|d<|�|t||�|�|�S)Nz
././@LongLinkr�rr'r))r1r3r2r0r/r
rF)r>r�rr6r7r r8r8r9r1}s�zTarInfo._create_gnu_long_headerc	Cs2d}|��D]8\}}z|�dd�Wqtk
rBd}YqFYqXqd}|rV|d7}|��D]�\}}|�d�}|r�|�|d�}n
|�d�}t|�t|�d}d	}	}
|tt|
��}	|	|
kr�q�|	}
q�|tt|
�d
�d|d|d
7}q^i}d|d<||d<t|�|d<t|d<|�|td
d�|�	|�S)NFr/rETr�s21 hdrcharset=BINARY
r"r�rrD� �=�
z././@PaxHeaderr�rr'r)r�)
r#r1r6r2r9rOr+r/r
rF)r>rrr6Zbinary�keywordr'Zrecords�lrLr>r r8r8r9r:�s<

(�z"TarInfo._create_pax_generic_headerc	Csvt|�dkrtd��t|�tkr(td��|�t�tkr>td��t|dd��}|t|�krbt	d��|�}t
|dd�||�|_t|dd	��|_t|d	d
��|_
t|d
d��|_t|dd��|_t|dd��|_||_|dd
�|_t
|d
d�||�|_t
|dd�||�|_t
|dd�||�|_t|dd��|_t|dd��|_t
|dd�||�}|jtk�r�|j�d��r�t|_|jtk�r8d}g}td�D]l}	z0t|||d��}
t||d|d��}Wntk
�r�Y�qYnX|�|
|f�|d7}�q�t|d�}t|dd��}
|||
f|_ |�!��rP|j�"d�|_|�rr|jt#k�rr|d|j|_|S)Nrzempty headerztruncated headerzend of file header��zbad checksumr�l�t�|��ii	i)iIiQiYi�r�i�r�r5�i�i�i�)$r2rqr�rr�countr3rsrNrXrKr?r�r�r)r*r'r(rrrr+r,rr�AREGTYPEr�r�GNUTYPE_SPARSErHr0r��boolrr�rstrip�	GNU_TYPES)r>rWr6r7r�objr*r��structsrMr��numbytes�
isextended�origsizer8r8r9�frombuf�sZ
zTarInfo.frombufcCs8|j�t�}|�||j|j�}|j��t|_|�|�Sr�)	r�r]r�r_r6r7r�r��_proc_member)r>r�rWrZr8r8r9�fromtarfileszTarInfo.fromtarfilecCsT|jttfkr|�|�S|jtkr,|�|�S|jtttfkrF|�	|�S|�
|�SdSr�)rr3r2�
_proc_gnulongrV�_proc_sparser;r=�SOLARIS_XHDTYPE�	_proc_pax�
_proc_builtin)r�r�r8r8r9r`s



zTarInfo._proc_membercCsR|j��|_|j}|��s$|jtkr4||�|j�7}||_|�	|j
|j|j�|Sr�)
r�r�r�r�r�SUPPORTED_TYPES�_blockr'r��_apply_pax_inforr6r7)r�r�r�r8r8r9rf"szTarInfo._proc_builtincCs�|j�|�|j��}z|�|�}Wntk
r>td��YnX|j|_|jt	krft
||j|j�|_
n|jtkr�t
||j|j�|_|S)N� missing or bad subsequent header)r�r]rhr'rarrtr�rr3r?r6r7r�r2r)r�r�rW�nextr8r8r9rb3s

zTarInfo._proc_gnulongc
	Cs�|j\}}}|`|r�|j�t�}d}td�D]n}z0t|||d��}t||d|d��}	Wntk
rzYq�YnX|r�|	r�|�||	f�|d7}q,t|d�}q||_	|j�
�|_|j|�|j
�|_||_
|S)Nr�r5rSi�)rr�r]r�rHrNr0r�rWr�r�r�rhr'r�)
r�r�r[r]r^rWr�rMr�r\r8r8r9rcIs(
zTarInfo._proc_sparsecCs�|j�|�|j��}|jtkr&|j}n
|j��}d}d}g}t|�|k�rj||dk�rjt	�
||�}sptd��zt|�
d��}Wntk
r�td��YnX|dkr�td��||t|�kr�td��|�d�|d}	||�d�d|	�}
|
�d�\}}}
|�r|dk�s||	dk�r&td��|�|||
f�|dk�r`|dk�r`|
dk�r\|j}nd	}||7}q<|dk�rxd	}|D]X\}}}
|�|d	d	|j�}|tk�r�|�|
||j|j�}n|�|
d	d	|j�}|||<�q|z|�|�}Wntk
�rtd
��YnXd|k�r|�||�nFd|k�r4|�||�n.|�d
�dk�rb|�d�dk�rb|�|||�|jttfk�r�|� ||j|j�|j!|_!d|k�r�|j"}|�#��s�|jt$k�r�||�|j�7}||_!|S)NrrGr#�rHr�s
hdrcharsetsBINARYr/rj�GNU.sparse.map�GNU.sparse.sizezGNU.sparse.major�1zGNU.sparse.minorrFr')%r�r]rhr'rr=rrr2�_header_length_prefix_re�matchrKrI�groupr0r�rg�	partitionr�r6�_decode_pax_fieldr7�PAX_NAME_FIELDSrarrt�_proc_gnusparse_01�_proc_gnusparse_00rB�_proc_gnusparse_10r;rdrir�r�r�rg)r�r�rWrr�r6�raw_headersrrr5Zheader_value_end_offsetZkeyword_and_valueZraw_keywordZequalsZ	raw_valuerJr'rkr�r8r8r9rees|





�
�
�

 
zTarInfo._proc_paxc	Cs�g}g}|D]�\}}}|dkrTz|�t|����Wq�tk
rPtd��Yq�Xq|dkrz|�t|����Wqtk
r�td��YqXqtt||��|_dS)NsGNU.sparse.offsetrGsGNU.sparse.numbytes)r�rIr=r0rK�list�zipr�)r�rkrzZoffsetsr\�_rJr'r8r8r9rx�szTarInfo._proc_gnusparse_00cCs@dd�|d�d�D�}tt|ddd�|ddd���|_dS)NcSsg|]}t|��qSr8)rI)�.0�xr8r8r9�
<listcomp>�sz.TarInfo._proc_gnusparse_01.<locals>.<listcomp>rn�,r$r#)r@r{r|r�)r�rkrr�r8r8r9rw�szTarInfo._proc_gnusparse_01cCs�d}g}|j�t�}|�dd�\}}t|�}t|�|dkrtd|krT||j�t�7}|�dd�\}}|�t|��q,|j��|_t	t
|ddd�|ddd���|_dS)NrIr#r$)r�r]r�r@rIr2r�r�r�r{r|r�)r�rkrr�Zfieldsr�rWZnumberr8r8r9ry�szTarInfo._proc_gnusparse_10c	Cs�|��D]�\}}|dkr&t|d|�q|dkr@t|dt|��q|dkrZt|dt|��q|tkr|tkr�zt||�}Wntk
r�d}YnX|dkr�|�d�}t|||�q|��|_dS)NzGNU.sparse.namer%ror'zGNU.sparse.realsizerr�)	r#�setattrrI�
PAX_FIELDS�PAX_NUMBER_FIELDSr0rXrr)r�rr6r7rJr'r8r8r9ris"

zTarInfo._apply_pax_infocCs4z|�|d�WStk
r.|�||�YSXdS)NrE)r=�UnicodeDecodeError)r�r'r6Zfallback_encodingZfallback_errorsr8r8r9ruszTarInfo._decode_pax_fieldcCs"t|t�\}}|r|d7}|tS)Nr#)r\r�)r�rTrbrcr8r8r9rh'szTarInfo._blockcCs
|jtkSr�)r�
REGULAR_TYPESr�r8r8r9r�0sz
TarInfo.isregcCs|��Sr�)r�r�r8r8r9�isfile4szTarInfo.isfilecCs
|jtkSr�)rrr�r8r8r9r8sz
TarInfo.isdircCs
|jtkSr�)r�SYMTYPEr�r8r8r9r<sz
TarInfo.issymcCs
|jtkSr�)r�LNKTYPEr�r8r8r9r�@sz
TarInfo.islnkcCs
|jtkSr�)rrCr�r8r8r9�ischrDsz
TarInfo.ischrcCs
|jtkSr�)rrDr�r8r8r9�isblkHsz
TarInfo.isblkcCs
|jtkSr�)r�FIFOTYPEr�r8r8r9�isfifoLszTarInfo.isfifocCs
|jdk	Sr�)r�r�r8r8r9�issparsePszTarInfo.issparsecCs|jtttfkSr�)rrCrDr�r�r8r8r9�isdevSsz
TarInfo.isdev)r�)3rnrorp�dict�	__slots__r��propertyr%�setterr&rrr�r!rrr(r$r%r&�classmethodr?r.�staticmethodr/rFr1r:r_rar`rfrbrcrerxrwryrirurhr�r�rrr�r�r�r�r�r�r8r8r8r9rNs��




�
1

)
	

2
>

y	c
@s�eZdZdZdZdZdZeZe	Z
dZeZ
eZdZdedd�Zedddefd	d
��Zedfdd��Zedgdd��Zedhdd��Zedidd��Zddddd�Zdd�Zdd�Zdd�Zdd �Zdjd!d"�Zdkdd$�d%d&�Zdldd'�d(d)�Z dmd*d+�Z!d,d-�Z"dnddd/�d0d1�Z#doddd/�d3d4�Z$d5d6�Z%d7d8�Z&d9d:�Z'd;d<�Z(d=d>�Z)dpd?d@�Z*dAdB�Z+dCdD�Z,dEdF�Z-dGdH�Z.dIdJ�Z/dKdL�Z0dMdN�Z1dOdP�Z2dQdR�Z3dSdT�Z4dqdUdV�Z5dWdX�Z6drdYdZ�Z7d[d\�Z8d]d^�Z9d_d`�Z:dadb�Z;dcdd�Z<dS)srrFr#Nrwr"c
Cs�ddddd�}||krtd��||_|||_|sh|jdkrTtj�|�sTd|_d|_t||j�}d	|_n@|dkr�t|d
�r�t	|j
ttf�r�|j
}t|d�r�|j|_d|_|r�tj�
|�nd|_
||_|dk	r�||_|dk	r�||_|dk	r�||_|dk	r�||_|dk	�r||_|	|_|
dk	�r0|jtk�r0|
|_ni|_|dk	�rF||_|dk	�rV||_|
|_d	|_g|_d	|_|j��|_i|_z�|jd
k�r�d|_ |�!�|_ |jdk�r2|j�"|j�z|j�#|�}|j�$|�WnXt%k
�r�|j�"|j�Y�q2Yn0t&k
�r,}zt't|���W5d}~XYnX�q�|jdk�r|d|_|j�r||j�(|j�)��}|j�*|�|jt+|�7_Wn&|j�s�|j�,�d|_�YnXdS)N�rbzr+b�wbZxb�rw�arxr�!mode must be 'r', 'a', 'w' or 'x'r�rxFr�r�Trw�r�rxr)-r0r��_moderzr%�exists�	bltn_openr�rr7r�r9rO�abspathr�rSr��dereference�ignore_zerosr6r7rr�debug�
errorlevel�copybufsizer��members�_loadedr�r��inodes�firstmemberrkr�rar�rsrrr?rr^r2r�)r�r�r�r�rSr�r�r�r6r7rr�r�r�Zmodes�erWr8r8r9r�ts�
�





"
zTarFile.__init__c

s�|s|std��|dkr��fdd�}t�j|d�D]j}t��j|�}|dk	rV|��}	z||d|f|�WSttfk
r�|dk	r�|�|	�Yq2Yq2Xq2td���nd|k�r|�dd	�\}
}|
p�d}
|p�d
}|�jkr�t��j|�}ntd|��|||
|f|�Sd|k�r�|�dd	�\}
}|
�p.d}
|�p8d
}|
d
k�rLtd��t	||
|||�}z�||
|f|�}Wn|�
��YnXd|_|S|dk�r��j|||f|�Std��dS)Nznothing to open)rw�r:*cs�j|dkS)N�taropen)�	OPEN_METH)r��r>r8r9�not_compressed
sz$TarFile.open.<locals>.not_compressed)�keyrwz%file could not be opened successfully�:r#r�r��|rvzmode must be 'r' or 'w'Fr�zundiscernible mode)
r0�sortedr�rhr�rrr�r@r�r�r�r�)
r>r�r�r�ra�kwargsr�r��funcZ	saved_pos�filemode�streamr�r8r�r9r�sP%







zTarFile.opencKs |dkrtd��||||f|�S)Nr�r�)r0)r>r�r�r�r�r8r8r9r�>szTarFile.taropenr�cKs�|dkrtd��zddlm}Wntk
r<td��YnXz|||d||�}Wn.tk
r�|dk	r||dkr|td���YnXz|j|||f|�}WnBtk
r�|��|dkr�td���Yn|���YnXd	|_	|S)
N�rwrxr�mode must be 'r', 'w' or 'x'r)�GzipFilezgzip module is not availablerdrwr�F)
r0Zgzipr�r�rr�rr�r�r�)r>r�r�r��
compresslevelr�r�r�r8r8r9�gzopenFs0zTarFile.gzopenc	Ks�|dkrtd��zddlm}Wntk
r<td��YnX||pF|||d�}z|j|||f|�}WnFttfk
r�|��|dkr�t	d���Yn|���YnXd	|_
|S)
Nr�r�r)�BZ2Filer�)r�rwznot a bzip2 fileF)r0r�r�r�rr�r��EOFErrorr�rr�)r>r�r�r�r�r�r�r�r8r8r9�bz2opengs&zTarFile.bz2openc		Ks�|dkrtd��zddlm}m}Wntk
r@td��YnX||pJ|||d�}z|j|||f|�}WnF|tfk
r�|��|dkr�t	d���Yn|���YnXd	|_
|S)
Nr�r�r)�LZMAFiler�r�)�presetrwznot an lzma fileF)r0r�r�r�r�rr�r�r�rr�)	r>r�r�r�r�r�r�r�r�r8r8r9�xzopen�s&zTarFile.xzopenr�r�r�r�)r�r�r�r�cCs�|jr
dSd|_z`|jdkrn|j�ttd�|jtd7_t	|jt
�\}}|dkrn|j�tt
|�W5|js�|j��XdS)NTr�r$r)r�r�r�r�r�r^r3r�r�r\�
RECORDSIZE)r�rbrcr8r8r9r��s
z
TarFile.closecCs"|�|�}|dkrtd|��|S)Nzfilename %r not found)�
_getmember�KeyError)r�r�r�r8r8r9�	getmember�s
zTarFile.getmembercCs|��|js|��|jSr�)�_checkr��_loadr�r�r8r8r9�
getmembers�szTarFile.getmemberscCsdd�|��D�S)NcSsg|]
}|j�qSr8r)r~r�r8r8r9r��sz$TarFile.getnames.<locals>.<listcomp>)r�r�r8r8r9�getnames�szTarFile.getnamescCs^|�d�|dk	r|j}|dkr$|}tj�|�\}}|�tjd�}|�d�}|��}||_	|dkr�|j
stt�|�}q�t�|�}nt�
|���}d}|j}t�|�r�|j|jf}	|j
s�|jdkr�|	|jkr�||j|	kr�t}
|j|	}nt}
|	dr�||j|	<nht�|��rt}
nVt�|��r"t}
nDt�|��r>t}
t�|�}n(t�|��rPt}
nt� |��rbt!}
ndS||_||_"|j#|_$|j%|_&|
tk�r�|j'|_(nd|_(|j)|_*|
|_+||_,t-�r�zt-�.|j$�d|_/Wnt0k
�r�YnXt1�rzt1�2|j&�d|_3Wnt0k
�rYnX|
tt!fk�rZt4td��rZt4td��rZt�5|j6�|_7t�8|j6�|_9|S)N�awxr�r�r#r�major�minor):r�r�rzr%�
splitdriver�r�r�r�r�r��lstat�stat�fstat�fileno�st_mode�S_ISREG�st_ino�st_dev�st_nlinkr�r�r�S_ISDIRr�S_ISFIFOr��S_ISLNKr��readlink�S_ISCHRrC�S_ISBLKrDr��st_uidr)�st_gidr*�st_sizer'�st_mtimer(rr�pwd�getpwuidr+r��grpZgetgrgidr,rr��st_rdevrr�r)r�r��arcnamer�Zdrvr�ZstatresrZstmd�inoderr8r8r9�
gettarinfo�s�	


��

zTarFile.gettarinfoT)r�cCs*|��|dkr|}|D�]
}|r�|jdkr6td�ntt�|j��td|jpT|j|jp^|jf�|�	�sv|�
�r�tdd|j|jf�ntd|j
�|jdkr�td�ntdt�|j�dd��t|j|��r�d	nd
�|�r|���rtd|j�|���rtd|j�t�qdS)
Nz
??????????z%s/%sz%10sz%d,%dz%10dz????-??-?? ??:??:??z%d-%02d-%02d %02d:%02d:%02dr�r�r�z-> zlink to )r�r�rlr�r�r+r)r,r*r�r�rrr'r(r��	localtimer�rrrr�rk)r��verboser�r�r8r8r9r{=s8



��

�

zTarFile.list��filterc	Cs6|�d�|dkr|}|jdk	rFtj�|�|jkrF|�dd|�dS|�d|�|�||�}|dkrz|�dd|�dS|dk	r�||�}|dkr�|�dd|�dS|��r�t|d��}|�	||�W5QRXn`|�
��r(|�	|�|�r2tt�|��D]*}|j
tj�||�tj�||�||d�q�n
|�	|�dS)	Nr�r$ztarfile: Skipped %rr#ztarfile: Unsupported type %r�tarfile: Excluded %rr�r�)r�r�rzr%r��_dbgr�r�r��addfilerr��listdir�addr�)r�r�r��	recursiver�r��fr8r8r9r�cs8



�
zTarFile.addcCs�|�d�t�|�}|�|j|j|j�}|j�|�|jt	|�7_|j
}|dk	r�t||j|j|d�t
|jt�\}}|dkr�|j�tt|�|d7}|j|t7_|j�|�dS)Nr�)rarr#)r�rr(rSr6r7r�r^r�r2r�r[r'r\r�r3r�r�)r�r�r�rWrarbrcr8r8r9r��s

zTarFile.addfilecCsr|dkr0|j}|dkrtSt|t�r,td��|St|�r<|Sz
t|WStk
rltd|�d��d�YnXdS)NzrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.zfilter z
 not found)	�extraction_filterrr7r9�	TypeError�callable�_NAMED_FILTERSr�r0)r�r�r8r8r9�_get_filter_function�s
�
zTarFile._get_filter_function�.)�
numeric_ownerr�cCs�g}|�|�}|dkr|}|D]F}|�|||�}|dkr:q|��rL|�|�|j|||��|d�q|jdd�dd�|D]n}tj�||j	�}	z,|j
||	|d�|�||	�|�||	�Wq|t
k
r�}
z|�|
�W5d}
~
XYq|Xq|dS)N��	set_attrsr�cSs|jSr�r)r�r8r8r9�<lambda>�r�z$TarFile.extractall.<locals>.<lambda>T)r��reverse)r�)r��_get_extract_tarinforr��_extract_one�sortrzr%r�r��chown�utime�chmodr
�_handle_nonfatal_error)r�r%r�r�r�Zdirectories�filter_functionrr��dirpathr�r8r8r9�
extractall�s,

�zTarFile.extractallr�cCs4|�|�}|�|||�}|dk	r0|�||||�dSr�)r�r�r�)r�rr%r�r�r�rr�r8r8r9�extract�s
zTarFile.extractc
Cs�t|t�r|�|�}n|}|}z|||�}WnZttfk
r\}z|�|�W5d}~XYn,tk
r�}z|�|�W5d}~XYnX|dkr�|�dd|j	�dS|�
�r�t�|�}tj
�||j�|_|S)Nr$r�)r7r9r�r�r��_handle_fatal_errorr
rr�r�r�rrzr%r�rr)r�rrr%r�Z
unfilteredr�r8r8r9r�	s"

zTarFile._get_extract_tarinfoc
Cs�|�d�z"|j|tj�||j�||d�WnVtk
rX}z|�|�W5d}~XYn,tk
r�}z|�	|�W5d}~XYnXdS)Nrwr�)
r��_extract_memberrzr%r�r�r�r	r
r)r�r�r%r�r�r�r8r8r9r�	s
�
zTarFile._extract_onecCs"|jdkr�n|�dd|�dS)Nr#�tarfile: %s)r�r��r�r�r8r8r9r%	s
zTarFile._handle_nonfatal_errorcCsn|jdkr�n\t|t�rP|jdkr6|�dd|j�qj|�dd|j|jf�n|�ddt|�j|f�dS)Nrr#rztarfile: %s %rztarfile: %s %s)r�r7r��filenamer��strerrorrrnrr8r8r9r	,	s


zTarFile._handle_fatal_errorcCs�|�d�t|t�r |�|�}n|}|��s6|jtkrB|�||�S|��sR|�	�rzt|j
t�rhtd��q~|�
|�|��SndSdS)Nrwz'cannot extract (sym)link as file object)r�r7r9r�r�rrg�
fileobjectr�rr�r�r	�extractfile�_find_link_target)r�rr�r8r8r9r8	s


zTarFile.extractfilecCsT|�d�}|�dtj�}tj�|�}|r>tj�|�s>t�|�|��sN|�	�rh|�
dd|j|jf�n|�
d|j�|�
�r�|�||�n�|��r�|�||�nx|��r�|�||�nb|��s�|��r�|�||�nD|��s�|�	�r�|�||�n&|jtk�r|�||�n|�||�|�rP|�|||�|�	��sP|�||�|�||�dS)Nr�r#z%s -> %s)rXr�rzr�r%rr��makedirsr�rr�r�rr��makefiler�makedirr��makefifor�r��makedev�makelinkrrg�makeunknownrrr)r�r��
targetpathr�r�Z	upperdirsr8r8r9r
W	s4


zTarFile._extract_membercCs@z&|jdkrt�|�nt�|d�Wntk
r:YnXdS)Ni�)r�rz�mkdir�FileExistsError�r�r�rr8r8r9r�	s
zTarFile.makedirc	Cs�|j}|�|j�|j}t|d��b}|jdk	rn|jD]"\}}|�|�t|||t|�q4|�|j�|�	�nt|||jt|�W5QRXdS)Nr�)
r�r�r�r�r�r�r[rr'�truncate)r�r�r�sourcera�targetr�r'r8r8r9r�	s


zTarFile.makefilecCs"|�||�|�dd|j�dS)Nr#z9tarfile: Unknown file type %r, extracted as regular file.)rr�rrr8r8r9r�	s�zTarFile.makeunknowncCs"ttd�rt�|�ntd��dS)N�mkfifozfifo not supported by system)rrzr r
rr8r8r9r�	s
zTarFile.makefifocCsjttd�rttd�std��|j}|dkr.d}|��rB|tjO}n
|tjO}t�||t�	|j
|j��dS)N�mknodrz'special devices not supported by systemr�)rrzr
r�r�r��S_IFBLK�S_IFCHRr!rrr)r�r�rr�r8r8r9r�	s
�zTarFile.makedevcCs�zb|��r0tj�|�r t�|�t�|j|�n0tj�|j�rNt�	|j|�n|�
|�|�|�WnHtk
r�z|�
|�|�|�Wnt
k
r�td��YnXYnXdS)Nz%unable to resolve link inside archive)rrzr%�lexists�unlink�symlinkrr�r�linkr
r�symlink_exceptionr�r
rr8r8r9r�	s"
��zTarFile.makelinkcCs�ttd�r�t��dkr�|j}|j}|s�ztrB|jrBt�|j�d}Wntk
rXYnXzt	rv|j
rvt	�|j
�d}Wntk
r�YnX|dkr�d}|dkr�d}z4|��r�ttd�r�t�
|||�nt�|||�Wntk
r�td��YnXdS)N�geteuidrr$r;�lchownzcould not change owner)rrzr)r*r)r�r,Zgetgrnamr�r�r+�getpwnamrr*rr�r
)r�r�rr��g�ur8r8r9r�	s0

z
TarFile.chowncCsB|jdkrdSzt�||j�Wntk
r<td��YnXdS)Nzcould not change mode)r�rzrr�r
rr8r8r9r
s
z
TarFile.chmodcCsV|j}|dkrdSttd�s dSzt�|||f�Wntk
rPtd��YnXdS)Nrz"could not change modification time)r(rrzrr�r
)r�r�rr(r8r8r9r
s
z
TarFile.utimec
Cs�|�d�|jdk	r$|j}d|_|S|j|j��krZ|j�|jd�|j�d�sZtd��d}z|j�	|�}W�q�t
k
r�}z6|jr�|�dd|j|f�|jt
7_WY�q^W5d}~XY�q�tk
�r6}zR|j�r|�dd|j|f�|jt
7_WY� q^n|jdk�r&tt|���W5d}~XYn�tk
�r^|jdk�rZtd��Ynjtk
�r�}z|jdk�r�tt|���W5d}~XYn0tk
�r�}ztt|���W5d}~XYnX�q�q^|dk	�r�|j�|�nd|_|S)	NZrar#rYr$z0x%X: %srz
empty fileT)r�r�r�r�r�r�r]rr�rarsr�r�r�rKr9rqrrrtr�r�r�)r��mr�r�r8r8r9rk
sJ



zTarFile.nextc	Cs�|��}d}|dk	rHz|�|�}Wntk
r:d}YnX|d|�}|rXtj�|�}t|�D]D}|rz|j|jkr`d}q`|r�tj�|j�}n|j}||kr`|Sq`|r�t|��dS)NFT)	r��indexr0rzr%�normpath�reversedr�r�)	r�r�r��	normalizer�Zskippingr/r�member_namer8r8r9r�P
s,

zTarFile._getmembercCs|��}|dkrqqd|_dSr�)rkr�r�r8r8r9r�x
sz
TarFile._loadcCs:|jrtd|jj��|dk	r6|j|kr6td|j��dS)Nz%s is closedzbad operation for mode %r)r�r�r�rnr�)r�r�r8r8r9r��
szTarFile._checkcCs`|��r.d�tdtj�|j�|jf��}d}n
|j}|}|j||dd�}|dkr\t	d|��|S)Nr�T)r�r2zlinkname %r not found)
rr�r�rzr%rr�rr�r�)r�r�r�limitrr8r8r9r�
s zTarFile._find_link_targetccs�|jr|jEdHdSd}|jdk	r:|��}|d7}|V|t|j�krT|j|}n"|jsr|��}|svd|_dSndS|d7}|Vq:dS)Nrr#T)r�r�r�rkr2)r�r/r�r8r8r9�__iter__�
s$
zTarFile.__iter__cCs||jkrt|tjd�dS)N��file)r�rkri�stderr)r��level�msgr8r8r9r��
s
zTarFile._dbgcCs|��|Sr�)r�r�r8r8r9�	__enter__�
szTarFile.__enter__cCs,|dkr|��n|js"|j��d|_dSr�)r�r�r�r�)r�rr'�	tracebackr8r8r9�__exit__�
s


zTarFile.__exit__)
NrwNNNNNNr"NNNN)rwN)rwNr�)rwNr�)rwNN)NNN)T)NT)N)r�N)r�T)TF)NF)N)=rnrorpr�r�r�r�rrSrr6r7rr�r�rr�r�r�r�rr�r�r�r�r�r�r�r�r�r�r{r�r�r�rrr�r�rr	rr
rrrrrrrrrrkr�r�r�rr5r�r;r=r8r8r8r9rXs��
oZ �


c&3
�-�
�
1!
6
(

	cCs2zt|�}|��WdStk
r,YdSXdS)NTF)rr�r)r�r�r8r8r9r�
sc	Csddl}d}|j|d�}|jdddddd	�|jd
dtdd
�|jdd�}|jddddd�|jdddddd�|jdddddd�|jdd dd!d�|��}|jr�|jdkr�|�d"d#�|j	dk	�r4|j	}t
|��rt|d$�� }|��t
|��tjd%�W5QRX|j�r0t
d&�|��n|�d"d'�|���n�|jdk	�r�|j}t
|��rxt�|d(��}|j|jd)�W5QRXn|�d"d'�|���nv|jdk	�rbt|j�d"k�r�|jd}tj}n,t|j�d*k�r�|j\}}n|�d"|���t
|��rNt�|d(��}|j||jd+�W5QRX|j�r`|d,k�r8d-�|�}	nd.�||�}	t
|	�n|�d"d'�|��n�|jdk	�r|j�d�}
tj�|
�\}}d/d/d0d0d1d1d1d1d2�}
||
k�r�d3|
|nd4}|j}t�|
|��}|D]}|�|��q�W5QRX|j�rt
d5�|
��dS)6Nrz3A simple command-line interface for tarfile module.)�descriptionz-vz	--verbose�
store_trueFzVerbose output)�action�default�helpz--filterz<filtername>zFilter for extraction)�metavar�choicesrBT)Zrequiredz-lz--list�	<tarfile>zShow listing of a tarfile)rCrBz-ez	--extract�+)rEz<output_dir>zExtract tarfile into target dir)�nargsrCrBz-cz--create)z<name>z<file>zCreate tarfile from sourcesz-tz--testzTest if a tarfile is validr#z&--filter is only valid for extraction
rwr6z{!r} is a tar archive.z{!r} is not a tar archive.
r�)r�r$)r%r�r�z{!r} file is extracted.z+{!r} file is extracted into {!r} directory.r�r�r�)r�z.tgzz.xzz.txzz.bz2z.tbzz.tbz2z.tb2zw:rxz{!r} file created.)�argparse�ArgumentParser�add_argumentr�Zadd_mutually_exclusive_group�
parse_argsr�r�exitZtestrrr�rkrir8r�rSr{rr2rz�curdirZformat_helprZcreate�popr%�splitextr�)rHr>�parserrs�argsr_r�ZtfrMr:Ztar_namer}ZextZcompressionsZtar_modeZ	tar_files�	file_namer8r8r9�main�
s���
�
�
�
�




�
�
rS�__main__)T)l�version�
__author__�__credits__�builtinsrr�rirzr�rZr�r�rVr�re�warningsr�r�r��AttributeError�NotImplementedErrorr(r��	NameError�__all__r3r�r�r0r+r-r,rArrUr�r�rCrDrr�ZCONTTYPEr3r2rVr;r=rdr
rrrrgr�rYr�rvr8rIr�r�r�getfilesystemencodingr:r?rNrTrXr[rl�	Exceptionrr
rrr	rrqrrrsrKrtrur��objectr�r��BufferedReaderr�r�r�r�r�r�r�rrrr
r�r�compilerqrrrrSrnr8r8r8r9�<module> s:


�	����
sh

?�
_


Hacked By AnonymousFox1.0, Coded By AnonymousFox