Your IP : 52.15.70.0


Current Path : /opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/__pycache__/tarfile.cpython-311.pyc

�

c��fd���f�dZdZdZdZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZ	ddlZn
#e$rdZYnwxYw	ddlZn
#e$rdZYnwxYweefZ	eefz
Zn#e$rYnwxYwgd�ZdZd	Zed
zZdZdZd
Zd
Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3e3Z4e"e#e$e%e(e)e*e&e'e+e,e-fZ5e"e#e*e-fZ6e+e,e-fZ7dZ8hd �Z9e:e:e:e;e;e;d!�Z<ej=d"krd#Z>nej?��Z>d$�Z@d%�ZAd&�ZBd'e4fd(�ZCd)�ZDdedfd*�ZEd+�ZFGd,�d-eG��ZHGd.�d/eH��ZIGd0�d1eH��ZJGd2�d3eH��ZKGd4�d5eH��ZLGd6�d7eH��ZMGd8�d9eM��ZNGd:�d;eM��ZOGd<�d=eM��ZPGd>�d?eM��ZQGd@�dAeM��ZRGdB�dC��ZSGdD�dE��ZTGdF�dGeU��ZVGdH�dIeU��ZWGdJ�dKe	jX��ZYGdL�dMeH��ZZGdN�dOeZ��Z[GdP�dQeZ��Z\GdR�dSeZ��Z]GdT�dUeZ��Z^GdV�dWeZ��Z_dfdY�Z`dZ�Zad[�Zbd\�Zceaebecd]�ZdeU��Zeejfd^��ZgGd_�d`eU��ZhGda�dbeU��Zidc�ZjeijZdd�Zkeldekrek��dSdS)gz,Read from and write to tar format archives.
z0.9.0u"Lars Gustäbel (lars@gustaebel.de)u4Gustavo Niemeyer, Niels Gustäbel, Richard Townsend.�)�openN)�TarFile�TarInfo�
is_tarfile�TarError�	ReadError�CompressionError�StreamError�ExtractError�HeaderError�ENCODING�USTAR_FORMAT�
GNU_FORMAT�
PAX_FORMAT�DEFAULT_FORMATr�i�sustar  sustar00�d��0�1�2�3�4�5�6�7�L�K�S�x�g�X��)�path�linkpath�size�mtime�uid�gid�uname�gname>r&r-r,r')�atime�ctimer)r*r+r(�nt�utf-8c��|�td���|�||��}|d|�|t|��z
tzzS)z8Convert a string to a null-terminated bytes object.
    Nzmetadata cannot contain None)�
ValueError�encode�len�NUL)�s�length�encoding�errorss    �./opt/alt/python311/lib64/python3.11/tarfile.py�stnr<�sM��	�y��7�8�8�8�	����6�"�"�A��W�f�W�:��#�a�&�&��C�/�/�/�c�x�|�d��}|dkr
|d|�}|�||��S)z8Convert a null-terminated bytes object to a string.
    r���N)�find�decode)r7r9r:�ps    r;�ntsrC�s=��	
���u�
�
�A��B�w�w�
�b�q�b�E���8�8�H�f�%�%�%r=c�|�|ddvr]d}tt|��dz
��D]}|dz}|||dzz
}�|ddkrdt|��dz
z|z
}nT	t|dd��}t|���pd	d��}n#t
$rt
d
���wxYw|S)z/Convert a number field to a python number.
    r)��r$�rF��ascii�strict�0�invalid header)�ranger5rC�int�stripr3�InvalidHeaderError)r7�n�is   r;�ntirS�s���
	��t�~���
���s�1�v�v��z�"�"�	�	�A�
�!�G�A�
��1�q�5��M�A�A��Q�4�5�=�=��#�a�&�&�1�*�%��)�*�A��	7��A�w��)�)�A��A�G�G�I�I�$��a�(�(�A�A���	7�	7�	7�$�%5�6�6�6�	7�����Hs�)5B�B9rGc���|}t|��}d|cxkrd|dz
zkr$nn!td|dz
|fzd��tz}n�|tkr�d|dz
z|cxkrd|dz
zkrfnnc|dkrt	dg��}nt	dg��}d|z|z}t|dz
��D] }|�d|dz��|dz}�!ntd	���|S)
z/Convert a python number to a number field.
    rrGr$z%0*orIrHrErFzoverflow in number field)rN�bytesr6r�	bytearrayrM�insertr3)rQ�digits�format�
original_nr7rRs      r;�itnr[�s3���J��A���A��A�!�!�!�!��f�q�j�!�!�!�!�!�!��&�F�Q�J��?�*�G�4�4�s�:���	�:�	�	�3�6�A�:�#6�"6�!�"Q�"Q�"Q�"Q�c�f�q�j�>Q�"Q�"Q�"Q�"Q�"Q���6�6��5�'�"�"�A�A��5�'�"�"�A��v�
��!�A��v��z�"�"�	�	�A�
�H�H�Q��E�	�"�"�"�
�!�G�A�A�	��3�4�4�4��Hr=c��dttjd|����z}dttjd|����z}||fS)a�Calculate 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.
    rH�
148B8x356B�
148b8x356b)�sum�struct�unpack_from)�buf�unsigned_chksum�
signed_chksums   r;�calc_chksumsre�sM���C�� 2�<�� E� E�F�F�F�O��#�f�0��s�C�C�D�D�D�M��M�)�)r=c���|pd}|dkrdS|�tj|||��dSt||��\}}t|��D]J}|�|��}t|��|kr|d���|�|���K|dkrH|�|��}t|��|kr|d���|�|��dS)zjCopy length bytes from fileobj src to fileobj dst.
       If length is None, copy the entire content.
    i@rN�unexpected end of data)�shutil�copyfileobj�divmodrM�readr5�write)	�src�dstr8�	exception�bufsize�blocks�	remainder�brbs	         r;riri�s����"��G�
��{�{���
�~���3��W�-�-�-����v�w�/�/��F�I�
�6�]�]�����h�h�w�����s�8�8�g����)�4�5�5�5��	�	�#������A�~�~��h�h�y�!�!���s�8�8�i����)�4�5�5�5��	�	�#����
�Fr=c��ttjdd��}|�)|�|d���|��}t|d���dS)Nr9�backslashreplace� )�end)�getattr�sys�stdoutr4rA�print)r7r9s  r;�_safe_printr|sV���s�z�:�t�4�4�H���
�H�H�X�1�2�2�9�9�(�C�C��	�!�������r=c��eZdZdZdS)rzBase exception.N��__name__�
__module__�__qualname__�__doc__�r=r;rrs���������Dr=rc��eZdZdZdS)rz%General exception for extract errors.Nr~r�r=r;rrs������/�/��Dr=rc��eZdZdZdS)rz&Exception for unreadable tar archives.Nr~r�r=r;rrs������0�0��Dr=rc��eZdZdZdS)r	z.Exception for unavailable compression methods.Nr~r�r=r;r	r	s������8�8��Dr=r	c��eZdZdZdS)r
z=Exception for unsupported operations on stream-like TarFiles.Nr~r�r=r;r
r
s������G�G��Dr=r
c��eZdZdZdS)rz!Base exception for header errors.Nr~r�r=r;rrs������+�+��Dr=rc��eZdZdZdS)�EmptyHeaderErrorzException for empty headers.Nr~r�r=r;r�r�!s������&�&��Dr=r�c��eZdZdZdS)�TruncatedHeaderErrorz Exception for truncated headers.Nr~r�r=r;r�r�$s������*�*��Dr=r�c��eZdZdZdS)�EOFHeaderErrorz"Exception for end of file headers.Nr~r�r=r;r�r�'s������,�,��Dr=r�c��eZdZdZdS)rPzException for invalid headers.Nr~r�r=r;rPrP*s������(�(��Dr=rPc��eZdZdZdS)�SubsequentHeaderErrorz3Exception for missing and invalid extended headers.Nr~r�r=r;r�r�-s������=�=��Dr=r�c�*�eZdZdZd�Zd�Zd�Zd�ZdS)�
_LowLevelFilez�Low-level file object. Supports reading and writing.
       It is used instead of a regular file object for streaming
       access.
    c��tjtjtjztjzd�|}ttd��r|tjz}tj||d��|_dS)N��r�w�O_BINARYi�)	�os�O_RDONLY�O_WRONLY�O_CREAT�O_TRUNC�hasattrr�r�fd)�self�name�modes   r;�__init__z_LowLevelFile.__init__:si������r�z�)�B�J�6�
�
�����2�z�"�"�	 ��B�K��D��'�$��e�,�,����r=c�8�tj|j��dS�N)r��closer��r�s r;r�z_LowLevelFile.closeCs��
��������r=c�6�tj|j|��Sr�)r�rkr��r�r(s  r;rkz_LowLevelFile.readFs���w�t�w��%�%�%r=c�:�tj|j|��dSr�)r�rlr��r�r7s  r;rlz_LowLevelFile.writeIs��
����!�����r=N)rr�r�r�r�r�rkrlr�r=r;r�r�4sZ��������
-�-�-����&�&�&�����r=r�c�\�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd�Zd�Z
d
�Zd�ZdS)�_Streama�Class that serves as an adapter between TarFile and
       a stream-like object.  The stream-like object only
       needs to have a read() or write() method that works with bytes,
       and the method is accessed blockwise.
       Use of gzip or bzip2 compression is possible.
       A stream-like object could be for example: sys.stdin.buffer,
       sys.stdout.buffer, a socket, a tape device etc.

       _Stream is intended to be used only internally.
    c��d|_|�t||��}d|_|dkr#t|��}|���}|pd|_||_||_||_||_d|_	d|_
d|_	|dkr�	ddl}n#t$rtd	��d�wxYw||_|�d��|_|d
kr"|j|_|���dS|���dS|dkrs	ddl}n#t$rtd��d�wxYw|d
kr.d|_|���|_t2|_dS|���|_dS|d
krs	ddl}n#t$rtd��d�wxYw|d
kr.d|_|���|_|j|_dS|���|_dS|dkrtd|z���dS#|js|j���d|_�xYw)z$Construct a _Stream object.
        TNF�*�r=r�gzzzlib module is not availabler��bz2�bz2 module is not available�xz�lzma module is not available�tar�unknown compression type %r) �_extfileobjr��_StreamProxy�getcomptyper�r��comptype�fileobjrprb�pos�closed�zlib�ImportErrorr	�crc32�crc�errorro�
_init_read_gz�_init_write_gzr��dbuf�BZ2Decompressor�cmp�OSError�
BZ2Compressor�lzma�LZMADecompressor�	LZMAError�LZMACompressorr�)	r�r�r�r�r�rpr�r�r�s	         r;r�z_Stream.__init__Xs��� ����?�#�D�$�/�/�G�$�D���s�?�?�#�7�+�+�G��*�*�,�,�H��
���	���	� ��
����������������-	��4���U��K�K�K�K��"�U�U�U�*�+I�J�J�PT�T�U���� ��	��:�:�c�?�?����3�;�;�%)�Z�D�N��&�&�(�(�(�(�(��'�'�)�)�)�)�)��U�"�"�T��J�J�J�J��"�T�T�T�*�+H�I�I�t�S�T�����3�;�;� #�D�I�"�2�2�4�4�D�H�%,�D�N�N�N�"�0�0�2�2�D�H�H�H��T�!�!�U��K�K�K�K��"�U�U�U�*�+I�J�J�PT�T�U�����3�;�;� #�D�I�#�4�4�6�6�D�H�%)�^�D�N�N�N�#�2�2�4�4�D�H�H�H��U�"�"�&�'D�x�'O�P�P�P�#�"��	��#�
%���"�"�$�$�$��D�K����sy�H�B�H�B,�,A
H�8H�H�D�H�D5�55H�,H�H�F�H�F.�.5H�%H�H�*Ic�d�t|d��r|js|���dSdSdS)Nr�)r�r�r�r�s r;�__del__z_Stream.__del__�sB���4��"�"�	�4�;�	��J�J�L�L�L�L�L�	�	�	�	r=c�@�|j�d|jj|jj|jjd��|_t
jdttj	������}|�
d|zdz��|j�d��r|jdd�|_tj�|j��|_|�
|j�d	d
��t"z��dS)z6Initialize for writing with gzip compression.
        �	r�<Ls�s��.gzN���z
iso-8859-1�replace)r��compressobj�DEFLATED�	MAX_WBITS�
DEF_MEM_LEVELr�r`�packrN�time�_Stream__writer��endswithr�r&�basenamer4r6)r��	timestamps  r;r�z_Stream._init_write_gz�s����9�(�(��D�I�,>�-1�Y�-@�,@�,0�I�,C�,-�/�/����K��c�$�)�+�+�&6�&6�7�7�	����(�9�4�{�B�C�C�C��9���e�$�$�	'��	�#�2�#��D�I��G�$�$�T�Y�/�/��	����T�Y�%�%�l�I�>�>��D�E�E�E�E�Er=c��|jdkr%|j�||j��|_|xjt|��z
c_|jdkr|j�|��}|�|��dS)z&Write string s to the stream.
        r�r�N)	r�r�r�r�r�r5r��compressr�r�s  r;rlz
_Stream.write�su���=�D� � ��y���q�$�(�3�3�D�H����C��F�F�����=�E�!�!���!�!�!�$�$�A����Q�����r=c�(�|xj|z
c_t|j��|jkrd|j�|jd|j���|j|jd�|_t|j��|jk�bdSdS)z]Write string s to the stream if a whole new block
           is ready to be written.
        N)rbr5rpr�rlr�s  r;�__writez_Stream.__write�s���	
���A�
����$�(�m�m�d�l�*�*��L���t�x�
���
�6�7�7�7��x���
�
�.�D�H��$�(�m�m�d�l�*�*�*�*�*�*r=c��|jrdSd|_	|jdkr2|jdkr'|xj|j���z
c_|jdkr�|jr�|j�|j��d|_|jdkrg|j�tj	d|j
����|j�tj	d|jdz����|js|j�
��dSdS#|js|j�
��wwxYw)	z[Close the _Stream object. No operation should be
           done on it afterwards.
        NTr�r�r=r�r�l��)r�r�r�rbr��flushr�rlr`r�r�r�r�r�r�s r;r�z
_Stream.close�s:���;�	��F����	%��y�C���D�M�U�$:�$:����D�H�N�N�,�,�,����y�C���D�H����"�"�4�8�,�,�,�����=�D�(�(��L�&�&�v�{�4���'B�'B�C�C�C��L�&�&�v�{�4���J�9N�'O�'O�P�P�P��#�
%���"�"�$�$�$�$�$�
%�
%��4�#�
%���"�"�$�$�$�$�
%���s�C'D�#Ec��|j�|jj��|_d|_|�d��dkrt
d���|�d��dkrtd���t|�d����}|�d��|d	zr]t|�d����d
t|�d����zz}|�	|��|dzr%	|�d��}|r|tkrn�$|d
zr%	|�d��}|r|tkrn�$|dzr|�d��dSdS)z:Initialize for reading a gzip compressed fileobj.
        r=r%s��not a gzip filer$�zunsupported compression method��rHrGT�N)r��
decompressobjr�r�r��
_Stream__readrr	�ordrkr6)r��flag�xlenr7s    r;r�z_Stream._init_read_gz�s����9�*�*�D�I�,?�+?�@�@�����	��;�;�q�>�>�[�(�(��-�.�.�.��;�;�q�>�>�W�$�$�"�#C�D�D�D��4�;�;�q�>�>�"�"�����A�����!�8�	��t�{�{�1�~�~�&�&��s�4�;�;�q�>�>�/B�/B�)B�B�D��I�I�d�O�O�O��!�8�	�
��K�K��N�N����A��H�H��
��"�9�	�
��K�K��N�N����A��H�H��
��!�8�	��K�K��N�N�N�N�N�	�	r=c��|jS)z3Return the stream's file pointer position.
        )r�r�s r;�tellz_Stream.tell�s���x�r=rc��||jz
dkrbt||jz
|j��\}}t|��D]}|�|j���|�|��ntd���|jS)zXSet the stream's file pointer to pos. Negative seeking
           is forbidden.
        rz seeking backwards is not allowed)r�rjrprMrkr
)r�r�rqrrrRs     r;�seekz_Stream.seek�s������>�Q��� &�s�T�X�~�t�|� D� D��F�I��6�]�]�
(�
(���	�	�$�,�'�'�'�'��I�I�i� � � � ��@�A�A�A��x�r=c�r�|�J�|�|��}|xjt|��z
c_|S)z5Return the next size number of bytes from the stream.)�_readr�r5)r�r(rbs   r;rkz_Stream.reads:�������j�j��������C��H�H�����
r=c�(�|jdkr|�|��St|j��}|jg}||kr�|jr|j}d|_n"|j�|j��}|snk	|j�	|��}n"#|j
$r}td��|�d}~wwxYw|�|��|t|��z
}||k��d�
|��}||d�|_|d|�S)z+Return size bytes from the stream.
        r�r=zinvalid compressed dataN)r�r�r5r�rbr�rkrpr��
decompressror�append�join)r�r(�c�trb�es      r;r�z
_Stream._reads'���=�E�!�!��;�;�t�$�$�$���	�N�N��
�Y�K���$�h�h��x�
��h�������l�'�'���5�5�����
B��h�)�)�#�.�.�����>�
B�
B�
B�� 9�:�:��A�����
B����
�H�H�S�M�M�M�
��S���M�A��$�h�h�
�H�H�Q�K�K���d�e�e�H��	���$��x�s�<B�
B6�!B1�1B6c�@�t|j��}|jg}||krO|j�|j��}|sn-|�|��|t|��z
}||k�Od�|��}||d�|_|d|�S)zsReturn size bytes from stream. If internal buffer is empty,
           read another block from the stream.
        r=N)r5rbr�rkrpr�r�)r�r(r�r�rbs     r;�__readz_Stream.__read.s���
���M�M��
�X�J���$�h�h��,�#�#�D�L�1�1�C��
��
�H�H�S�M�M�M�
��S���M�A��$�h�h�
�H�H�Q�K�K���T�U�U�8�����$��x�r=N)r)rr�r�r�r�r�r�rlr�r�r�r�r�rkr�r�r�r=r;r�r�Ls�������	�	�D�D�D�L���F�F�F� ���/�/�/�%�%�%�,���>���
����������6����r=r�c�*�eZdZdZd�Zd�Zd�Zd�ZdS)r�zsSmall proxy class that enables transparent compression
       detection for the Stream interface (mode 'r|*').
    c�\�||_|j�t��|_dSr�)r�rk�	BLOCKSIZErb)r�r�s  r;r�z_StreamProxy.__init__Ds$������<�$�$�Y�/�/����r=c�2�|jj|_|jSr�)r�rkrbr�s  r;rkz_StreamProxy.readHs���L�%��	��x�r=c���|j�d��rdS|jdd�dkr|jdd�dkrd	S|j�d
��rdSdS)
Ns�r�r�sBZhr��
s1AY&SYr�)s]�s�7zXZr�r�)rb�
startswithr�s r;r�z_StreamProxy.getcomptypeLsp���8����/�/�	��4�
�X�a��c�]�f�
$�
$���!�B�$��9�)D�)D��5�
�X�
 �
 �!C�
D�
D�	��4��5r=c�8�|j���dSr�)r�r�r�s r;r�z_StreamProxy.closeVs����������r=N)rr�r�r�r�rkr�r�r�r=r;r�r�?sZ��������0�0�0�����������r=r�c�`�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	e
jfd	�Zd
d
�Z
d�Zd�ZdS)�_FileInFilezA thin wrapper around an existing file object that
       provides a part of its data as an individual file
       object.
    Nc���||_||_||_d|_t	|dd��|_d|_|�d|fg}d|_g|_d}|j}|D]T\}}||kr|j�	d||df��|j�	d|||z|f��||z
}||z}�U||jkr%|j�	d||jdf��dSdS)Nrr�FT)
r��offsetr(�positionrxr�r��	map_index�mapr�)r�r�r
r(�	blockinfo�lastpos�realposs       r;r�z_FileInFile.__init__cs����������	���
��G�V�T�2�2��	�������T���I����������+��%�	$�	$�L�F�D������������� >�?�?�?��H�O�O�T�6�6�D�=�'�B�C�C�C��t�O�G��t�m�G�G��T�Y����H�O�O�U�G�T�Y��=�>�>�>�>�>��r=c��dSr�r�r�s r;r�z_FileInFile.flush|s���r=c��dS�NTr�r�s r;�readablez_FileInFile.readables���tr=c��dS�NFr�r�s r;�writablez_FileInFile.writable�s���ur=c�4�|j���Sr�)r��seekabler�s r;rz_FileInFile.seekable�s���|�$�$�&�&�&r=c��|jS)z*Return the current file position.
        )rr�s r;r�z_FileInFile.tell�����}�r=c���|tjkr)tt|d��|j��|_n�|tjkrG|dkrt|j|zd��|_nst|j|z|j��|_nP|tjkr1tt|j|z|j��d��|_ntd���|jS)z(Seek to a position in the file.
        rzInvalid argument)	�io�SEEK_SET�min�maxr(r�SEEK_CUR�SEEK_ENDr3)r�r�whences   r;r�z_FileInFile.seek�s����R�[� � ���H�a� 0� 0�$�)�<�<�D�M�M�
�r�{�
"�
"��!�|�|� #�D�M�H�$<�a� @� @��
�
� #�D�M�H�$<�d�i� H� H��
�
�
�r�{�
"�
"���D�I��$8�$�)� D� D�a�H�H�D�M�M��/�0�0�0��}�r=c��|�|j|jz
}nt||j|jz
��}d}|dk�r
	|j|j\}}}}||jcxkr|krnnn5|xjdz
c_|jt|j��krd|_�bt|||jz
��}|rg|j�||j|z
z��|j�|��}t|��|krtd���||z
}n
|t|zz
}||z}|xj|z
c_|dk��
|S)z!Read data from the file.
        Nr=rTr$rg)r(rr"rrr5r�r�rkrr6)	r�r(rb�data�start�stopr
r8rss	         r;rkz_FileInFile.read�sn���<��9�t�}�,�D�D��t�T�Y���6�7�7�D����Q�h�h�
+�,0�H�T�^�,D�)��e�T�6��D�M�0�0�0�0�D�0�0�0�0�0���N�N�a�'�N�N��~��T�X���6�6�)*���
+���t�d�m�3�4�4�F��
$���!�!�&�D�M�E�,A�"B�C�C�C��L�%�%�f�-�-���q�6�6�V�#�#�#�$<�=�=�=��q�����s�V�|�#���F�N�D��M�M�V�#�M�M�'�Q�h�h�(�
r=c��|�t|����}||dt|���<t|��Sr�)rkr5)r�rsrbs   r;�readintoz_FileInFile.readinto�s7���i�i��A��������)�3�s�8�8�)���3�x�x�r=c��d|_dSr)r�r�s r;r�z_FileInFile.close�s
������r=r�)rr�r�r�r�r�rrrr�r r!r�rkr,r�r�r=r;rr]s���������
?�?�?�?�2
�
�
�������'�'�'����
%'�K����� ����>���
����r=rc���eZdZ�fd�Z�xZS)�ExFileObjectc���t|j|j|j|j��}t���|��dSr�)rr��offset_datar(�sparse�superr�)r��tarfile�tarinfor��	__class__s    �r;r�zExFileObject.__init__�sB����g�o�w�/B���g�n�.�.��
������!�!�!�!�!r=�rr�r�r��
__classcell__�r6s@r;r/r/�s8�������"�"�"�"�"�"�"�"�"r=r/c��eZdZdS)�FilterErrorN)rr�r�r�r=r;r;r;�s�������Dr=r;c���eZdZ�fd�Z�xZS)�AbsolutePathErrorc�j��||_t���d|j�d���dS)Nzmember z has an absolute path�r5r3r�r��r�r5r6s  �r;r�zAbsolutePathError.__init__�s6������
�����H�7�<�H�H�H�I�I�I�I�Ir=r7r9s@r;r=r=�sA�������J�J�J�J�J�J�J�J�Jr=r=c���eZdZ�fd�Z�xZS)�OutsideDestinationErrorc���||_||_t���|j�d|�d�dz��dS)Nz would be extracted to �, � which is outside the destination�r5�_pathr3r�r��r�r5r&r6s   �r;r�z OutsideDestinationError.__init__�sT��������
�
�����G�L�M�M�4�M�M�M�=�>�	?�	?�	?�	?�	?r=r7r9s@r;rBrB��8�������?�?�?�?�?�?�?�?�?r=rBc���eZdZ�fd�Z�xZS)�SpecialFileErrorc�h��||_t���|j�d���dS)Nz is a special filer?r@s  �r;r�zSpecialFileError.__init__�s3������
�����G�L�>�>�>�?�?�?�?�?r=r7r9s@r;rKrK�sA�������@�@�@�@�@�@�@�@�@r=rKc���eZdZ�fd�Z�xZS)�AbsoluteLinkErrorc�h��||_t���|j�d���dS)Nz is a link to an absolute pathr?r@s  �r;r�zAbsoluteLinkError.__init__�s3������
�����G�L�J�J�J�K�K�K�K�Kr=r7r9s@r;rNrN�sA�������L�L�L�L�L�L�L�L�Lr=rNc���eZdZ�fd�Z�xZS)�LinkOutsideDestinationErrorc���||_||_t���|j�d|�d�dz��dS)Nz would link to rDrErFrHs   �r;r�z$LinkOutsideDestinationError.__init__�sT��������
�
�����G�L�E�E�4�E�E�E�=�>�	?�	?�	?�	?�	?r=r7r9s@r;rQrQ�rIr=rQTc��i}|j}tj�|��}|�dtjf��r,|j�dtjz��x}|d<tj�|��rt|���tj�tj�	||����}tj�
||g��|krt||���|j}|��|dz}|rr|�
��s|���r|dzs|dz}|dz}n:|���s|���rd}nt#|���||jkr||d<|�r]|j�d|d<|j�d|d	<|j�d|d
<|j�d|d<|���s|����rtj�|j��rt/|���|���rDtj�	|tj�|��|j��}n%tj�	||j��}tj�|��}tj�
||g��|krt3||���|S)N�/r�i��@i�����r�r*r+r,r-)r�r�r&�realpathr�sep�lstrip�isabsr=r��
commonpathrBr��isreg�islnk�isdir�issymrKr*r+r,r-�linknamerN�dirnamerQ)�member�	dest_path�for_data�	new_attrsr��target_pathr�s       r;�_get_filtered_attrsrg�s����I��;�D��� � ��+�+�I�����R�V�}�%�%�D�#)�;�#5�#5�c�B�F�l�#C�#C�C��y�� �	�w�}�}�T���(� ��'�'�'��'�"�"�2�7�<�<�	�4�#@�#@�A�A�K�	�w���;�	�2�3�3�y�@�@�%�f�k�:�:�:��;�D����e�|���
	/��|�|�~�~�
/������
/��e�|�#��F�N�D���
��������
/�6�<�<�>�>�
/����'�v�.�.�.��6�;��� $�I�f���G��:�!�#�I�e���:�!�#�I�e���<�#�!%�I�g���<�#�!%�I�g���<�<�>�>�	G�V�\�\�^�^�	G��w�}�}�V�_�-�-�
0�'��/�/�/��|�|�~�~�
<� �g�l�l�9�+-�7�?�?�4�+@�+@�+1�?�<�<���!�g�l�l�9�+1�?�<�<���'�*�*�;�7�7�K��w�!�!�;�	�":�;�;�y�H�H�1�&�+�F�F�F��r=c��|Sr�r�)rbrcs  r;�fully_trusted_filterri1s���Mr=c�N�t||d��}|r|jdi|�ddi��S|S)NF�deepr��rgr��rbrcres   r;�
tar_filterrn4sC��#�F�I�u�=�=�I��7��v�~�6�6�	�6�6��6�6�6�6��Mr=c�N�t||d��}|r|jdi|�ddi��S|S)NTrkFr�rlrms   r;�data_filterrp:sC��#�F�I�t�<�<�I��7��v�~�6�6�	�6�6��6�6�6�6��Mr=)�
fully_trustedr�r(s([0-9]{1,20}) c�r�eZdZdZedUidd�dd�dd�dd	�d
d�dd
�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#�d$d%�d&d%�d'd%��ZdVd)�Zed*���Zej	d+���Zed,���Z
e
j	d-���Z
d.�Zeeeeeeeed/ed0�
d1�Z
d2�Zeed3fd4�Zd5�Zd6�Zd7�Zed8���Zd9�Zed:���Zed;���Zed<���Zed=���Zed>���Zed?���Zd@�ZdA�Z dB�Z!dC�Z"dD�Z#dE�Z$dF�Z%dG�Z&dH�Z'dI�Z(dJ�Z)dK�Z*dL�Z+dM�Z,dN�Z-dO�Z.dP�Z/dQ�Z0dR�Z1dS�Z2dT�Z3d%S)WraInformational class which holds the details about an
       archive member given by a tar header block.
       TarInfo objects are returned by TarFile.getmember(),
       TarFile.getmembers() and TarFile.gettarinfo() and are
       usually created internally.
    r�zName of the archive member.r�zPermission bits.r*z6User ID of the user who originally stored this member.r+z7Group ID of the user who originally stored this member.r(zSize in bytes.r)zTime of last modification.�chksumzHeader checksum.�typez�File type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.r`zcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.r,z
User name.r-zGroup name.�devmajorzDevice major number.�devminorzDevice minor number.r
zThe tar header starts here.r1zThe file's data starts here.�pax_headerszMA dictionary containing key-value pairs of an associated pax extended header.r2zSparse member information.r4N�_sparse_structs�_link_targetr�c��||_d|_d|_d|_d|_d|_d|_t|_d|_	d|_
d|_d|_d|_
d|_d|_d|_i|_dS)zXConstruct a TarInfo object. name is the optional name
           of the member.
        i�rr�N)r�r�r*r+r(r)rs�REGTYPErtr`r,r-rurvr
r1r2rw�r�r�s  r;r�zTarInfo.__init__ss�����	���	���������	���
������	���
���
���
���
���
��������������r=c��|jS)z(In pax headers, "name" is called "path".�r�r�s r;r&zTarInfo.path�s���y�r=c��||_dSr�r~r|s  r;r&zTarInfo.path�s
����	�	�	r=c��|jS)z0In pax headers, "linkname" is called "linkpath".�r`r�s r;r'zTarInfo.linkpath�rr=c��||_dSr�r�)r�r`s  r;r'zTarInfo.linkpath�s
�� ��
�
�
r=c�J�d|jj|jt|��fzS)Nz<%s %r at %#x>)r6rr��idr�s r;�__repr__zTarInfo.__repr__�s!���4�>�#:�4�9�R��X�X�"N�N�Nr=T)
r�r)r�r`r*r+r,r-rk�_KEEPc
��|	rtj|��}ntj|��}||
ur||_||
ur||_||
ur||_||
ur||_||
ur||_||
ur||_||
ur||_||
ur||_	|S)zGReturn a deep copy of self with the given attributes replaced.
        )
�copy�deepcopyr�r)r�r`r*r+r,r-)r�r�r)r�r`r*r+r,r-rkr��results            r;r�zTarInfo.replace�s����	%��]�4�(�(�F�F��Y�t�_�_�F��u����F�K����� �F�L��u����F�K��5� � �&�F�O��e����F�J��e����F�J����� �F�L����� �F�L��
r=c�>�|j�d}n
|jdz}|j||j|j|j|j|j|j|j|j	|j
|j|jd�
}|dtkr+|d�d��s|dxxdz
cc<|S)z9Return the TarInfo's attributes as a dictionary.
        N�)
r�r�r*r+r(r)rsrtr`r,r-rurvrtr�rT)r�r�r*r+r(r)rsrtr`r,r-rurv�DIRTYPEr�)r�r��infos   r;�get_infozTarInfo.get_info�s����9���D�D��9�v�%�D��	�������	��
����	��
��
��
��
��
�
�
�� ��<�7�"�"�4��<�+@�+@��+E�+E�"���L�L�L�C��L�L�L��r=�surrogateescapec�n�|���}|���D]\}}|�td|z����|tkr|�|||��S|t
kr|�|||��S|tkr|�||��Std���)z<Return a tar header as a string of 512 byte blocks.
        Nz%s may not be Nonezinvalid format)	r��itemsr3r�create_ustar_headerr�create_gnu_headerr�create_pax_header)r�rYr9r:r�r��values       r;�tobufz
TarInfo.tobuf�s����}�}�����:�:�<�<�	>�	>�K�D�%��}� �!5��!<�=�=�=���\�!�!��+�+�D�(�F�C�C�C�
�z�
!�
!��)�)�$��&�A�A�A�
�z�
!�
!��)�)�$��9�9�9��-�.�.�.r=c��t|d<t|d�||����tkrt	d���t|d�||����t
kr&|�|d||��\|d<|d<|�|t||��S)z3Return the object as a ustar header block.
        �magicr`zlinkname is too longr��prefix)	�POSIX_MAGICr5r4�LENGTH_LINKr3�LENGTH_NAME�_posix_split_name�_create_headerr)r�r�r9r:s    r;r�zTarInfo.create_ustar_header�s���$��W�
��t�J��&�&�x��8�8�9�9�K�G�G��3�4�4�4��t�F�|�"�"�8�V�4�4�5�5��C�C�+/�+A�+A�$�v�,�PX�Z`�+a�+a�(�D��N�D��L��"�"�4��x��H�H�Hr=c��t|d<d}t|d�||����tkr&||�|dt
||��z
}t|d�||����tkr&||�|dt||��z
}||�|t||��zS)z:Return the object as a GNU header block sequence.
        r�r=r`r�)
�	GNU_MAGICr5r4r��_create_gnu_long_header�GNUTYPE_LONGLINKr��GNUTYPE_LONGNAMEr�r)r�r�r9r:rbs     r;r�zTarInfo.create_gnu_header�s���"��W�
����t�J��&�&�x��8�8�9�9�K�G�G��4�/�/��Z�0@�BR�T\�^d�e�e�e�C��t�F�|�"�"�8�V�4�4�5�5��C�C��4�/�/��V��>N�PX�Z`�a�a�a�C��T�(�(��z�8�V�L�L�L�Lr=c��t|d<|j���}ddtfddtfddfD]h\}}}||vr�	||�dd	��n#t$r||||<Y�@wxYwt||��|kr||||<�id
D]u\}}d}||}	t|	t��}
|
rt|	��n|	}d|cxkrd
|dz
zks
nd||<d}n	|
r|||<d}|r||vrt|	��||<�v|r|�|t|��}nd}||�|tdd��zS)z�Return the object as a ustar header block. If it cannot be
           represented this way, prepend a pax extended header sequence
           with supplement information.
        r�r�r&r`r')r,r,� )r-r-r�rIrJ))r*rG)r+rG)r(�)r)r�FrrGr$Tr=r�)r�rwr�r�r�r4�UnicodeEncodeErrorr5�
isinstance�float�round�str�_create_pax_generic_header�XHDTYPEr�r)
r�r�r9rwr��hnamer8rX�	needs_pax�val�val_is_float�val_intrbs
             r;r�zTarInfo.create_pax_headers���
$��W�
��&�+�+�-�-��
���-�
�J��/T�&�(>�$@�	0�	0��D�%����#�#��
��T�
�!�!�'�8�4�4�4�4��%�
�
�
�%)�$�Z��E�"���
�����4��:����'�'�%)�$�Z��E�"��R�	-�	-�L�D�&��I��t�*�C�%�c�5�1�1�L�$0�9�e�C�j�j�j�c�G���3�3�3�3�!���
�"3�3�3�3�3���T�
� �	�	��
!�%��T�
� �	��
-�T��4�4�$'��H�H��D�!���	��1�1�+�w��Q�Q�C�C��C��T�(�(��|�W�i�P�P�P�Ps�A#�#A;�:A;c�:�|�|td��S)zAReturn the object as a pax global header block sequence.
        r1)r��XGLTYPE)�clsrws  r;�create_pax_global_headerz TarInfo.create_pax_global_header>s���-�-�k�7�G�L�L�Lr=c��|�d��}tdt|����D]�}d�|d|���}d�||d���}t|�||����t
kr.t|�||����tkrn��td���||fS)zUSplit a name longer than 100 chars into a prefix
           and a name part.
        rTr$Nzname is too long)�splitrMr5r�r4�
LENGTH_PREFIXr�r3)r�r�r9r:�
componentsrRr�s       r;r�zTarInfo._posix_split_nameDs����Z�Z��_�_�
��q�#�j�/�/�*�*�	1�	1�A��X�X�j��!��n�-�-�F��8�8�J�q�r�r�N�+�+�D��6�=�=��6�2�2�3�3�}�D�D�����H�f�5�5�6�6�+�E�E�����/�0�0�0��t�|�r=c��|�d��ttfv}|rKt|�dd��d|��}t|�dd��d|��}n$t	dd||��}t	dd||��}|�dt
��}|�t
d���t	|�d	d��d
||��t|�dd��dzd|��t|�d
d��d|��t|�dd��d|��t|�dd��d|��t|�dd��d|��d|t	|�dd��d
||��|�dt��t	|�dd��d||��t	|�dd��d||��||t	|�dd��d||��g}tj	dtzd�|����}	t|	td���d}
|	dd�td|
zd��z|	dd�z}	|	S) z�Return a header block. info is a dictionary with file
           information, format must be one of the *_FORMAT constants.
        rtrurrGrvr�NzTarInfo.type must not be Noner�rr�r�r*r+r(r�r)s        r`r�r,r�r-r�rz%dsr=i����z%06orIi����)�get�CHRTYPE�BLKTYPEr[r<r{r3r�r`r�rr�rerU)r�rYr9r:�has_device_fieldsrurv�filetype�partsrbrss           r;r�zTarInfo._create_headerTs���
!�H�H�V�,�,��'�0B�B���	4��4�8�8�J��2�2�A�v�>�>�H��4�8�8�J��2�2�A�v�>�>�H�H��2�q�(�F�3�3�H��2�q�(�F�3�3�H��8�8�F�G�,�,�����<�=�=�=�
������$�$�c�8�V�<�<�������#�#�f�,�a��8�8�������"�"�A�v�.�.�������"�"�A�v�.�.�������#�#�R��0�0������!�$�$�b�&�1�1��������R�(�(�#�x��@�@��H�H�W�k�*�*������"�%�%�r�8�V�<�<������"�%�%�r�8�V�<�<��������2�&�&��X�v�>�>�
��$�k�%�)�+�S�X�X�e�_�_�=�=���c�9�*�+�+�.�/�/��2���%�4�%�j�5��F�!2�G�<�<�<�s�4�5�5�z�I���
r=c��tt|��t��\}}|dkr|t|z
tzz
}|S)zdReturn the string payload filled with zero bytes
           up to the next 512 byte border.
        r)rjr5rr6)�payloadrqrrs   r;�_create_payloadzTarInfo._create_payload~s@��
#�3�w�<�<��;�;���	��q�=�=��	�I�-��4�4�G��r=c���|�||��tz}i}d|d<||d<t|��|d<t|d<|�|t
||��|�|��zS)zTReturn a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
           for name.
        z
././@LongLinkr�rtr(r�)r4r6r5r�r�rr�)r�r�rtr9r:r�s      r;r�zTarInfo._create_gnu_long_header�s��
�{�{�8�V�,�,�s�2����&��V����V���4�y�y��V��!��W�
��!�!�$��h��G�G��#�#�D�)�)�*�	*r=c��d}|���D]/\}}	|�dd���#t$rd}YnwxYwd}|r|dz
}|���D]�\}}|�d��}|r|�|d��}n|�d��}t|��t|��zdz}d	x}	}
	|tt	|
����z}	|	|
krn|	}
�)|tt	|
��d
��dz|zdz|zd
zz
}��i}d|d<||d<t|��|d<t|d<|�|td
d��|�	|��zS)z�Return a POSIX.1-2008 extended or global header sequence
           that contains a list of keyword, value pairs. The values
           must be strings.
        Fr1rJTr=s21 hdrcharset=BINARY
r�rrrI� �=�
z././@PaxHeaderr�rtr(r�r�)
r�r4r�r5r�rUr�r�rr�)r�rwrtr9�binary�keywordr��records�lrQrBr�s            r;r�z"TarInfo._create_pax_generic_header�s�����)�/�/�1�1�	�	�N�G�U�
����W�h�/�/�/�/��%�
�
�
������
�������	1��0�0�G�)�/�/�1�1�	V�	V�N�G�U��n�n�W�-�-�G��
.����X�/@�A�A������W�-�-���G���s�5�z�z�)�A�-�A��I�A��
���C��F�F���O����6�6����	
�

�u�S��V�V�W�-�-��4�w�>��E��M�PU�U�U�G�G���'��V����V���7�|�|��V��#��W�
��!�!�$��g�y�I�I��#�#�G�,�,�-�	-s�4�A�Ac���t|��dkrtd���t|��tkrtd���|�t
��tkrt
d���t|dd���}|t|��vrtd���|��}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�||��}|jt0kr&|j�d��rt4|_|jt6kr�d}g}t9d��D]h}		t|||dz���}
t||dz|dz���}n#t:$rYn!wxYw|�|
|f��|dz
}�it?|d��}t|dd���}
|||
f|_ |�!��r|j�"d��|_|r |jtFvr|dz|jz|_|S)zAConstruct a TarInfo object from a 512 byte bytes object.
        rzempty headerztruncated headerzend of file header��zbad checksumr�l�t�|��ii	i)iIiQiYi�rTi�r�r��i�i�i�)$r5r�rr��countr6r�rSrerPrCr�r�r*r+r(r)rsrtr`r,r-rurv�AREGTYPEr�r��GNUTYPE_SPARSErMr3r��boolrxr^�rstrip�	GNU_TYPES)r�rbr9r:rs�objr�r��structsrRr
�numbytes�
isextended�origsizes              r;�frombufzTarInfo.frombuf�sF���s�8�8�q�=�=�"�>�2�2�2��s�8�8�y� � �&�'9�:�:�:��9�9�S�>�>�Y�&�&� �!5�6�6�6��S��S��\�"�"����c�*�*�*�*�$�^�4�4�4��c�e�e���s�1�S�5�z�8�V�4�4����s�3�s�7�|�$�$����c�#�c�'�l�#�#����c�#�c�'�l�#�#����s�3�s�7�|�$�$�����C��G��%�%��	���
��s�3�w�<����3�s�3�w�<��6�:�:�����C��G��h��7�7��	���C��G��h��7�7��	��3�s�3�w�<�(�(����3�s�3�w�<�(�(����S��S��\�8�V�4�4���8�x���C�H�$5�$5�c�$:�$:���C�H�
�8�~�%�%��C��G��1�X�X�
�
��� ��S��r��\�!2�3�3�F�"�3�s�R�x��b��'8�#9�:�:�H�H��!�����E�E����������1�2�2�2��r�	����c�#�h���J��3�s�3�w�<�(�(�H�#*�J��"A�C���9�9�;�;�	,��x���s�+�+�C�H��	/�c�h�i�/�/���|�c�h�.�C�H��
s�7J<�<
K
�	K
c��|j�t��}|�||j|j��}|j���tz
|_|�|��S)zOReturn the next TarInfo object from TarFile object
           tarfile.
        )	r�rkrr�r9r:r�r
�_proc_member)r�r4rbr�s    r;�fromtarfilezTarInfo.fromtarfilesa��
�o�"�"�9�-�-���k�k�#�w�/���@�@���_�)�)�+�+�i�7��
�����(�(�(r=c�*�|jttfvr|�|��S|jtkr|�|��S|jtttfvr|�	|��S|�
|��S)zYChoose the right processing method depending on
           the type and call it.
        )rtr�r��
_proc_gnulongr��_proc_sparser�r��SOLARIS_XHDTYPE�	_proc_pax�
_proc_builtin)r�r4s  r;r�zTarInfo._proc_member s����9�)�+;�<�<�<��%�%�g�.�.�.�
�Y�.�
(�
(��$�$�W�-�-�-�
�Y�7�G�_�=�
=�
=��>�>�'�*�*�*��%�%�g�.�.�.r=c��|j���|_|j}|���s|jt
vr||�|j��z
}||_|�	|j
|j|j��|�
��r|j�d��|_|S)zfProcess a builtin type or an unknown type which
           will be treated as a regular file.
        rT)r�r�r1r\rt�SUPPORTED_TYPES�_blockr(r
�_apply_pax_inforwr9r:r^r�r�)r�r4r
s   r;r�zTarInfo._proc_builtin-s���#�?�/�/�1�1����!���:�:�<�<�	-�4�9�O�;�;��d�k�k�$�)�,�,�,�F����	
���W�0�'�2B�G�N�S�S�S��:�:�<�<�	.��	�(�(��-�-�D�I��r=c�6�|j�|�|j����}	|�|��}n/#t
$r"}t
t|����d�d}~wwxYw|j|_|j	tkr!t||j|j
��|_n0|j	tkr t||j|j
��|_|���r|j�d��|_|S)zSProcess the blocks that hold a GNU longname
           or longlink member.
        NrT)r�rkr�r(r�rr�r�r
rtr�rCr9r:r�r�r`r^�removesuffix)r�r4rb�nextr�s     r;r�zTarInfo._proc_gnulongCs����o�"�"�4�;�;�t�y�#9�#9�:�:��	:��#�#�G�,�,�D�D���	:�	:�	:�'��A���/�/�T�9�����	:����
�k����9�(�(�(��C��!1�7�>�B�B�D�I�I�
�Y�*�
*�
*���W�%5�w�~�F�F�D�M��:�:�<�<�	4��	�.�.�s�3�3�D�I��s�A
�

A6�A1�1A6c�2�|j\}}}|`|r�|j�t��}d}t	d��D]l}	t|||dz���}t||dz|dz���}	n#t$rYn%wxYw|r|	r|�||	f��|dz
}�mt|d��}|��||_	|j�
��|_|j|�|j
��z|_||_
|S)z8Process a GNU sparse header plus extra headers.
        r�r�r�i�)rxr�rkrrMrSr3r�r�r2r�r1r�r(r
)
r�r4r�r�r�rbr�rRr
r�s
          r;r�zTarInfo._proc_sparse^sF��)-�(<�%���X�� ��	(��/�&�&�y�1�1�C��C��2�Y�Y�
�
��� ��S��r��\�!2�3�3�F�"�3�s�R�x��b��'8�#9�:�:�H�H��!�����E�E������7�h�7��N�N�F�H�#5�6�6�6��r�	����c�#�h���J��	(����"�?�/�/�1�1����)�D�K�K��	�,B�,B�B�����	��s�7A;�;
B	�B	c��|j�|�|j����}|jt
kr|j}n|j���}d}d}g}t|��|k�r�||dk�rst�
||��x}std���	t|�
d����}n#t$rtd���wxYw|dkrtd���||zt|��krtd���|�d��|zdz
}	||�d��dz|	�}
|
�d��\}}}
|r|dks||	dkrtd���|�|||
f��|dkr|�|
d	kr|j}nd
}||z
}t|��|kr
||dk��s|�d
}|D]q\}}}
|�|d
d
|j��}|t,vr#|�|
||j|j��}n|�|
d
d
|j��}|||<�r	|�|��}n/#t0$r"}t3t5|����d�d}~wwxYwd|vr|�||��ndd|vr|�||��nI|�d
��dkr0|�d��dkr|�|||��|jt>t@fvr~|�!||j|j��|j"|_"d|vrM|j#}|�$��s|jtJvr||�|j��z
}||_"|S)zVProcess an extended or global header as described in
           POSIX.1-2008.
        rNrLr$�r�rs
hdrcharsetsBINARYr1�GNU.sparse.map�GNU.sparse.sizezGNU.sparse.major�1zGNU.sparse.minorrKr()&r�rkr�r(rtr�rwr�r5�_header_length_prefix_re�matchrPrN�groupr3r)rw�	partitionr�r9�_decode_pax_fieldr:�PAX_NAME_FIELDSr�rr�r��_proc_gnusparse_01�_proc_gnusparse_00r��_proc_gnusparse_10r�r�r�r
r1r\r�)r�r4rbrwr�r9�raw_headersr�r8�header_value_end_offset�keyword_and_value�raw_keyword�equals�	raw_valuer�r�r�r�r
s                   r;r�zTarInfo._proc_paxzsA��
�o�"�"�4�;�;�t�y�#9�#9�:�:��
�9����!�-�K�K�!�-�2�2�4�4�K��������#�h�h��n�n��S��T�!1�!1�5�;�;�C��E�E�E�E�
;�(�)9�:�:�:�
;��U�[�[��^�^�,�,�����
;�
;�
;�(�)9�:�:�:�
;������z�z�(�)9�:�:�:��V�|�c�#�h�h�&�&�(�)9�:�:�:�&+�k�k�!�n�n�v�&=��&A�#� #�E�I�I�a�L�L�1�$4�5L�$L� M��->�-H�-H��-N�-N�*�K����
;�&�D�.�.�C�8O�4P�TX�4X�4X�(�)9�:�:�:������Y�?�@�@�@��m�+�+��0@��	�)�)�&�/�H�H�&�H��6�M�C�M�#�h�h��n�n��S��T�!1�!1�R���H�/:�	)�	)�*�F�K���,�,�[�'�7��N�$�$�G��/�)�)��.�.�y�(�G�DT���(�(����.�.�y�'�7���(�(��$)�K�� � �	:��#�#�G�,�,�D�D���	:�	:�	:�'��A���/�/�T�9�����	:�����{�*�*��#�#�D�+�6�6�6�6�
�+�
-�
-��#�#�D�+�6�6�6�6�
�_�_�/�
0�
0�C�
7�
7�K�O�O�L^�<_�<_�cf�<f�<f��#�#�D�+�w�?�?�?��9��/�2�2�2�� � ��g�.>���O�O�O��+�D�K���$�$��)���:�:�<�<�5�4�9�O�#C�#C��d�k�k�$�)�4�4�4�F�!'����s$�8"C�C5�7J
�
J9�J4�4J9c���g}g}|D]�\}}}|dkrS	|�t|��������B#t$rt	d���wxYw|dkrS	|�t|���������#t$rt	d���wxYw��tt
||����|_dS)z?Process a GNU tar extended sparse header, version 0.0.
        sGNU.sparse.offsetrLsGNU.sparse.numbytesN)r�rNrAr3rP�list�zipr2)r�r�r�offsetsr��_r�r�s        r;rzTarInfo._proc_gnusparse_00�s
������!,�	?�	?��A�w���.�.�.�?��N�N�3�u�|�|�~�~�#6�#6�7�7�7�7��!�?�?�?�,�-=�>�>�>�?�����2�2�2�?��O�O�C������$7�$7�8�8�8�8��!�?�?�?�,�-=�>�>�>�?����3��3�w��1�1�2�2����s�4A	�	A#�-4B"�"B<c	��d�|d�d��D��}tt|ddd�|ddd�����|_dS)z?Process a GNU tar extended sparse header, version 0.1.
        c�,�g|]}t|����Sr�)rN)�.0�xs  r;�
<listcomp>z.TarInfo._proc_gnusparse_01.<locals>.<listcomp>
s��K�K�K�Q�#�a�&�&�K�K�Kr=r��,Nr%r$)r�rrr2)r�r�rwr2s    r;rzTarInfo._proc_gnusparse_01s]��L�K�+�.>�"?�"E�"E�c�"J�"J�K�K�K���3�v�c�c��c�{�F�1�4�a�4�L�9�9�:�:����r=c	�Z�d}g}|j�t��}|�dd��\}}t	|��}t|��|dzkrwd|vr"||j�t��z
}|�dd��\}}|�t	|����t|��|dzk�w|j���|_tt|ddd�|ddd�����|_dS)z?Process a GNU tar extended sparse header, version 1.0.
        Nr�r$r%)r�rkrr�rNr5r�r�r1rrr2)r�r�rwr4�fieldsr2rb�numbers        r;rzTarInfo._proc_gnusparse_10
s�������o�"�"�9�-�-���i�i��q�)�)�����V�����&�k�k�F�Q�J�&�&��C����w��+�+�I�6�6�6���)�)�E�1�-�-�K�F�C��M�M�#�f�+�+�&�&�&�	�&�k�k�F�Q�J�&�&�
#�?�/�/�1�1����3�v�c�c��c�{�F�1�4�a�4�L�9�9�:�:����r=c��|���D]�\}}|dkrt|d|���|dkrt|dt|�����B|dkrt|dt|�����g|tvr^|tvr)	t	||��}n#t
$rd}YnwxYw|dkr|�d��}t|||����|���|_dS)	zoReplace fields with supplemental information from a previous
           pax extended or global header.
        zGNU.sparse.namer&r�r(zGNU.sparse.realsizerrTN)	r��setattrrN�
PAX_FIELDS�PAX_NUMBER_FIELDSr3r�r�rw)r�rwr9r:r�r�s      r;r�zTarInfo._apply_pax_infos/��*�/�/�1�1�	.�	.�N�G�U��+�+�+���f�e�,�,�,�,��-�-�-���f�c�%�j�j�1�1�1�1��1�1�1���f�c�%�j�j�1�1�1�1��J�&�&��/�/�/�"� 1�'� :�5� A� A����%�"�"�"� !����"�����f�$�$�!�L�L��-�-�E���g�u�-�-�-��&�+�+�-�-����s�B%�%B4�3B4c�|�	|�|d��S#t$r|�||��cYSwxYw)z1Decode a single field from a pax record.
        rJ)rA�UnicodeDecodeError)r�r�r9�fallback_encoding�fallback_errorss     r;r�zTarInfo._decode_pax_field4sV��	D��<�<��(�3�3�3��!�	D�	D�	D��<�<� 1�?�C�C�C�C�C�	D���s�� ;�;c�T�t|t��\}}|r|dz
}|tzS)z_Round up a byte count by BLOCKSIZE and return it,
           e.g. _block(834) => 1024.
        r$)rjr)r�r�rqrrs    r;r�zTarInfo._block<s4��#�5�)�4�4���	��	��a�K�F��	�!�!r=c��|jtvS�z4Return True if the Tarinfo object is a regular file.)rt�
REGULAR_TYPESr�s r;r\z
TarInfo.isregEs���y�M�)�)r=c�*�|���Sr")r\r�s r;�isfilezTarInfo.isfileIs���z�z�|�|�r=c�"�|jtkS)z!Return True if it is a directory.)rtr�r�s r;r^z
TarInfo.isdirM����y�G�#�#r=c�"�|jtkS)z%Return True if it is a symbolic link.)rt�SYMTYPEr�s r;r_z
TarInfo.issymQr'r=c�"�|jtkS)z!Return True if it is a hard link.)rt�LNKTYPEr�s r;r]z
TarInfo.islnkUr'r=c�"�|jtkS)z(Return True if it is a character device.)rtr�r�s r;�ischrz
TarInfo.ischrYr'r=c�"�|jtkS)z$Return True if it is a block device.)rtr�r�s r;�isblkz
TarInfo.isblk]r'r=c�"�|jtkS)zReturn True if it is a FIFO.)rt�FIFOTYPEr�s r;�isfifozTarInfo.isfifoas���y�H�$�$r=c��|jduSr�)r2r�s r;�issparsezTarInfo.issparsees���{�$�&�&r=c�8�|jtttfvS)zCReturn True if it is one of character device, block device or FIFO.)rtr�r�r1r�s r;�isdevz
TarInfo.isdevhs���y�W�g�x�8�8�8r=r�)r�)4rr�r�r��dict�	__slots__r��propertyr&�setterr'r�r�r�r�rr
r�r�r�r��classmethodr�r��staticmethodr�r�r�r�r�r�r�r�r�r�r�rrrr�r�r�r\r%r^r_r]r-r/r2r4r6r�r=r;rrPs{����������
�
�
�,�,�
�!�!�
�G�F�
�H�G�	
�
 ��
�-�,�

�$�#�
�>�>�
�F�F�
���
��
�
�*�)�
� *�)�!
�"/�.�#
�$5�4�%
�&9�9�'
�*.�-�+
�,�$�-
�.�$�/
�0�t�1
�I�6����0����X��
�[����[������X���_�!�!��_�!�O�O�O��%�e�e��u�E���������8���8*�H�EV�/�/�/�/�"I�I�I�M�M�M�8Q�8Q�8Q�t�M�M��[�M�
��� �'�'��\�'�R����\���*�*��[�*� �0-�0-��[�0-�d�<�<��[�<�|�)�)��[�)�(/�/�/����,���6���8w�w�w�r3�3�3�(;�;�;�;�;�;� .�.�.�.D�D�D�"�"�"�*�*�*����$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�%�%�%�'�'�'�9�9�9�9�9r=rc���eZdZdZdZdZdZdZeZ	e
ZdZe
ZeZdZ				d=d�Zedddefd	���Zed>d
���Zed?d���Zed?d
���Zed@d���Zddddd�Zd�Zd�Zd�Zd�ZdAd�ZdBdd�d�Z dCdd�d�Z!dDd�Z"d�Z#dEddd!�d"�Z$dFddd!�d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*		dGd*�Z+d+�Z,d,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5dHd5�Z6d6�Z7dDd7�Z8d8�Z9d9�Z:d:�Z;d;�Z<d<�Z=dS)Irz=The TarFile Class provides an interface to tar archives.
    rFr$Nr�r�c��ddddd�}||vrtd���||_|||_|sU|jdkr-tj�|��sd|_d|_t
||j��}d	|_n]|�8t|d��r(t|j
ttf��r|j
}t|d��r|j|_d
|_|rtj�
|��nd
|_
||_|�||_|�||_|�||_|�||_|�||_|	|_|
�|jt*kr|
|_ni|_|�||_|�||_|
|_d	|_g|_d	|_|j���|_i|_	|jdkr d
|_ |�!��|_ |jdkr�	|j�"|j��	|j�#|��}|j�$|��nY#tJ$r"|j�"|j��Yn/tL$r"}tOt|����d
�d
}~wwxYw��|jdvrxd
|_|jrl|j�(|j�)����}|j�*|��|xjtW|��z
c_d
Sd
Sd
S#|js|j�,��d
|_�xYw)a�Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
           read from an existing archive, 'a' to append data to an existing
           file or 'w' to create a new file overwriting an existing one. `mode'
           defaults to 'r'.
           If `fileobj' is given, it is used for reading or writing data. If it
           can be determined, `mode' is overridden by `fileobj's mode.
           `fileobj' is not closed, when TarFile is closed.
        �rbzr+b�wb�xb�r��ar�r�!mode must be 'r', 'a', 'w' or 'x'rCr�FNr�r�Tr��rCr�r)-r3r��_moder�r&�exists�	bltn_openr�r�r�r�r�rU�abspathr�rYr5�dereference�ignore_zerosr9r:rrw�debug�
errorlevel�copybufsizer��members�_loadedr�r
�inodes�firstmemberr�r�r�r�r�rrr�r�rlr5r�)r�r�r�r�rYr5rJrKr9r:rwrLrMrN�modesr�rbs                 r;r�zTarFile.__init__�s}����T��=�=���u����@�A�A�A���	��4�[��
��
	$��y�C�������t�(<�(<����	�!��
���d�j�1�1�G�$�D�������&�!9�!9���7�<�#�u��6�6���|���w��'�'�
*�$�\��
�#�D��-1�;�B�G�O�O�D�)�)�)�t��	������ �D�K���"�D�L��"�*�D���#� ,�D����$�D�M�����"�t�{�j�'@�'@�*�D���!�D�����D�J��!�(�D�O�'�������������l�'�'�)�)������	��y�C���#'�� �#'�9�9�;�;�� ��y�C���	:��L�%�%�d�k�2�2�2�:�"&�,�":�":�4�"@�"@����+�+�G�4�4�4�4��)������)�)�$�+�6�6�6���&�:�:�:�'��A���/�/�T�9�����:����	:��y�O�+�+�#����#�,��,�?�?��@P�@U�@U�@W�@W�X�X�C��L�&�&�s�+�+�+��K�K�3�s�8�8�+�K�K�K�K�
,�+�,�,��	��#�
%���"�"�$�$�$��D�K����s>�;AL&�4I�L&�)J�0L&�2	J�;J�J�BL&�&*Mc����|s|std���|dvrՈfd�}g}t�j|���D]�}t��j|��}	|�|���}
	|	|d|fi|��cS#t
tf$r<}|�d|�d|����|�|�|
��Yd}~��d}~wwxYwd	�	|��}td
|�����d|vrc|�
dd��\}
}|
pd}
|pd
}|�jvrt��j|��}	nt
d|z���|	||
|fi|��Sd|vrw|�
dd��\}
}|
pd}
|pd
}|
dvrtd���t||
|||��}	�||
|fi|��}n#|����xYwd|_
|S|dvr�j|||fi|��Std���)a�Open a tar archive for reading, writing or appending. Return
           an appropriate TarFile class.

           mode:
           'r' or 'r:*' open for reading with transparent compression
           'r:'         open for reading exclusively uncompressed
           'r:gz'       open for reading with gzip compression
           'r:bz2'      open for reading with bzip2 compression
           'r:xz'       open for reading with lzma compression
           'a' or 'a:'  open for appending, creating the file if necessary
           'w' or 'w:'  open for writing without compression
           'w:gz'       open for writing with gzip compression
           'w:bz2'      open for writing with bzip2 compression
           'w:xz'       open for writing with lzma compression

           'x' or 'x:'  create a tarfile exclusively without compression, raise
                        an exception if the file is already created
           'x:gz'       create a gzip compressed tarfile, raise an exception
                        if the file is already created
           'x:bz2'      create a bzip2 compressed tarfile, raise an exception
                        if the file is already created
           'x:xz'       create an lzma compressed tarfile, raise an exception
                        if the file is already created

           'r|*'        open a stream of tar blocks with transparent compression
           'r|'         open an uncompressed stream of tar blocks for reading
           'r|gz'       open a gzip compressed stream of tar blocks
           'r|bz2'      open a bzip2 compressed stream of tar blocks
           'r|xz'       open an lzma compressed stream of tar blocks
           'w|'         open an uncompressed stream for writing
           'w|gz'       open a gzip compressed stream for writing
           'w|bz2'      open a bzip2 compressed stream for writing
           'w|xz'       open an lzma compressed stream for writing
        znothing to open)r��r:*c�&���j|dkS)N�taropen)�	OPEN_METH)r�r�s �r;�not_compressedz$TarFile.open.<locals>.not_compressed"s����}�X�.�)�;�;r=)�keyNr�z	- method z: �
z'file could not be opened successfully:
�:r$r�r��|r�zmode must be 'r' or 'w'FrEzundiscernible mode)r3�sortedrXrxr�rr	r�r�r�r�r�r�r�rW)r�r�r�r�rp�kwargsrY�
error_msgsr��func�	saved_posr��error_msgs_summary�filemode�streamr�s`               r;rzTarFile.open�s����J�	0�G�	0��.�/�/�/��<���
<�
<�
<�
<�
<��J�"�3�=�n�E�E�E�

�

���s�C�M�(�$;�<�<���&� '�����I���4��c�7�=�=�f�=�=�=�=�=��!�#3�4�����%�%�&C�(�&C�&C�a�&C�&C�D�D�D��*����Y�/�/�/��H�H�H�H�����	����
"&���:�!6�!6���[�GY�[�[�\�\�\�
�D�[�[�!%���C��!3�!3��H�h���3�H��(�5�H��3�=�(�(��s�C�M�(�$;�<�<���&�'D�x�'O�P�P�P��4��h��:�:�6�:�:�:�
�D�[�[�!%���C��!3�!3��H�h���3�H��(�5�H��z�)�)� �!:�;�;�;��T�8�X�w��H�H�F�
��C��h��9�9�&�9�9����
�����������!�A�M��H�
�_�
$�
$��3�;�t�T�7�=�=�f�=�=�=��-�.�.�.s$�*
A7�7C�2B?�?C�!F-�-Gc�>�|dvrtd���||||fi|��S)zCOpen uncompressed tar archive name for reading or writing.
        rBrD)r3)r�r�r�r�r_s     r;rWzTarFile.taropenVs;���+�+�+��@�A�A�A��s�4��w�1�1�&�1�1�1r=r�c���|dvrtd���	ddlm}n#t$rt	d��d�wxYw	|||dz||��}n+#t
$r}|�|dkrt
d	��|��d}~wwxYw	|j|||fi|��}nR#t
$r0}|���|dkrt
d	��|��d}~w|����xYwd
|_	|S)zkOpen gzip compressed tar archive name for reading or writing.
           Appending is not allowed.
        �r�r�r�mode must be 'r', 'w' or 'x'r)�GzipFilezgzip module is not availableNrsr�r�F)
r3�gziprjr�r	r�rrWr�r�)	r�r�r�r��
compresslevelr_rjr�r�s	         r;�gzopenzTarFile.gzopen^sS��
��&�&��;�<�<�<�	M�%�%�%�%�%�%�%���	M�	M�	M�"�#A�B�B��L�	M����	��h�t�T�C�Z���H�H�G�G���	�	�	��"�t�s�{�{�� 1�2�2��9������	����
		����D�$��:�:�6�:�:�A�A���	�	�	��M�M�O�O�O��s�{�{�� 1�2�2��9������	��M�M�O�O�O�������
��s7��7�A
�
A5�A0�0A5�9B
�

C�+B?�?Cc�|�|dvrtd���	ddlm}n#t$rt	d��d�wxYw||p|||���}	|j|||fi|��}nY#ttf$r0}|���|dkrtd	��|��d}~w|����xYwd
|_
|S)zlOpen bzip2 compressed tar archive name for reading or writing.
           Appending is not allowed.
        rhrir)�BZ2Filer�N)rlr�znot a bzip2 fileF)r3r�ror�r	rWr��EOFErrorr�rr�)	r�r�r�r�rlr_ror�r�s	         r;�bz2openzTarFile.bz2opens��
��&�&��;�<�<�<�	L�#�#�#�#�#�#�#���	L�	L�	L�"�#@�A�A�t�K�	L�����'�'�/�T�4�}�M�M�M��		����D�$��:�:�6�:�:�A�A����"�	�	�	��M�M�O�O�O��s�{�{�� 2�3�3��:������	��M�M�O�O�O�������
��s ��7�A�B2�-+B�B2c�v�|dvrtd���	ddlm}m}n#t$rtd��d�wxYw||p|||���}	|j|||fi|��}nT#|tf$r0}	|���|dkrtd	��|	��d}	~	w|����xYwd
|_
|S)zkOpen lzma compressed tar archive name for reading or writing.
           Appending is not allowed.
        rhrir)�LZMAFiler�r�N)�presetr�znot an lzma fileF)r3r�rsr�r�r	rWrpr�rr�)
r�r�r�r�rtr_rsr�r�r�s
          r;�xzopenzTarFile.xzopen�s��
��&�&��;�<�<�<�	M�0�0�0�0�0�0�0�0�0���	M�	M�	M�"�#A�B�B��L�	M�����(�7�?�d�D��@�@�@��		����D�$��:�:�6�:�:�A�A���8�$�	�	�	��M�M�O�O�O��s�{�{�� 2�3�3��:������	��M�M�O�O�O�������
��s ��9�
A�B/�*+B�B/rWrmrqru)r�r�r�r�c���|jrdSd|_	|jdvr�|j�tt
dzz��|xjt
dzz
c_t|jt��\}}|dkr*|j�tt|z
z��|j	s|j�
��dSdS#|j	s|j�
��wwxYw)zlClose the TarFile. In write-mode, two finishing zero blocks are
           appended to the archive.
        NTrEr%r)r�r�r�rlr6rr
rj�
RECORDSIZEr�r�)r�rqrrs   r;r�z
TarFile.close�s����;�	��F����	%��y�O�+�+���"�"�3�)�a�-�#8�9�9�9����	�A�
�.���%+�4�;�
�$C�$C�!��	��q�=�=��L�&�&�s�j�9�.D�'E�F�F�F��#�
%���"�"�$�$�$�$�$�
%�
%��4�#�
%���"�"�$�$�$�$�
%���s�BC�#C1c�~�|�|�d����}|�td|z���|S)aReturn a TarInfo object for member `name'. If `name' can not be
           found in the archive, KeyError is raised. If a member occurs more
           than once in the archive, its last occurrence is assumed to be the
           most up-to-date version.
        rTNzfilename %r not found)�
_getmemberr��KeyError)r�r�r5s   r;�	getmemberzTarFile.getmember�s?���/�/�$�+�+�c�"2�"2�3�3���?��2�T�9�:�:�:��r=c�n�|���|js|���|jS)z�Return the members of the archive as a list of TarInfo objects. The
           list has the same order as the members in the archive.
        )�_checkrP�_loadrOr�s r;�
getmemberszTarFile.getmembers�s0��	
���
�
�
��|�	��J�J�L�L�L��|�r=c�>�d�|���D��S)z�Return the members of the archive as a list of their names. It has
           the same order as the list returned by getmembers().
        c��g|]	}|j��
Sr�r~)rr5s  r;rz$TarFile.getnames.<locals>.<listcomp>�s��>�>�>����>�>�>r=)rr�s r;�getnameszTarFile.getnames�s"��?�>�D�O�O�,=�,=�>�>�>�>r=c���|�d��|�|j}|�|}tj�|��\}}|�tjd��}|�d��}|���}||_	|�1|j
stj|��}n;tj|��}n&tj
|�����}d}|j}tj|��ri|j|jf}	|j
s:|jdkr/|	|jvr&||j|	krt*}
|j|	}n�t,}
|	dr
||j|	<n�tj|��rt0}
n�tj|��rt4}
njtj|��rt8}
tj|��}n:tj|��rt>}
ntj |��rtB}
ndS||_||_"|j#|_$|j%|_&|
t,kr
|j'|_(nd|_(|j)|_*|
|_+||_,tZr6	t[j.|j$��d|_/n#t`$rYnwxYwtbr6	tcj2|j&��d|_3n#t`$rYnwxYw|
t>tBfvrftitd��rQtitd��r<tj5|j6��|_7tj8|j6��|_9|S)	a�Create a TarInfo object from the result of os.stat or equivalent
           on an existing file. The file is either named by `name', or
           specified as a file object `fileobj' with a file descriptor. If
           given, `arcname' specifies an alternative name for the file in the
           archive, otherwise, the name is taken from the 'name' attribute of
           'fileobj', or the 'name' argument. The name should be a text
           string.
        �awxNrTr�r$r�major�minor):r}r�r�r&�
splitdriver�rXrYr5r4rJ�lstat�stat�fstat�fileno�st_mode�S_ISREG�st_ino�st_dev�st_nlinkrQr+r{�S_ISDIRr��S_ISFIFOr1�S_ISLNKr)�readlink�S_ISCHRr��S_ISBLKr�r��st_uidr*�st_gidr+�st_sizer(�st_mtimer)rtr`�pwd�getpwuidr,rz�grp�getgrgidr-r�r��st_rdevrur�rv)r�r��arcnamer��drvr5�statresr`�stmd�inoderts           r;�
gettarinfozTarFile.gettarinfo�s=��	
���E�������<�D�
�?��G��w�)�)�'�2�2���W��/�/�"�&�#�.�.���.�.��%�%���,�,�.�.������?��#�
(��(�4�.�.����'�$�-�-����h�w�~�~�/�/�0�0�G�������<����	��^�W�^�4�E��#�
1��(8�1�(<�(<��T�[�(�(�W���E�8J�-J�-J����;�u�-�������8�1�)0�D�K��&��
�\�$�
�
�	��D�D�
�]�4�
 �
 �
	��D�D�
�\�$�
�
�	��D��{�4�(�(�H�H�
�\�$�
�
�	��D�D�
�\�$�
�
�	��D�D��4��������n����n����7�?�?�"�?�G�L�L��G�L��(��
����#����	�
� #��W�[� 9� 9�!� <��
�
���
�
�
���
�����	�
� #��W�[� 9� 9�!� <��
�
���
�
�
���
�����G�W�%�%�%��r�7�#�#�
=���G�(<�(<�
=�#%�8�G�O�#<�#<�� �#%�8�G�O�#<�#<�� ��s$�=$J"�"
J/�.J/�:$K�
K,�+K,T)rOc��|���|�|}|D�]�}|�r|j�td��n&ttj|j����t|jp|j�d|jp|j����|�	��s|�
��r"tdd|j|jfzz��ntd|j
z��|j�td��n1tdtj|j��dd	�z��t|j|���rdnd
z��|rV|���rtd|jz��|���rtd|jz��t-�����dS)
aPrint a table of contents to sys.stdout. If `verbose' is False, only
           the names of the members are printed. If it is True, an `ls -l'-like
           output is produced. `members' is optional and must be a subset of the
           list returned by getmembers().
        Nz
??????????rTz%10sz%d,%dz%10dz????-??-?? ??:??:??z%d-%02d-%02d %02d:%02d:%02dr�r�z-> zlink to )r}r�r|r�rdr,r*r-r+r-r/rurvr(r)r��	localtimer�r^r_r`r]r{)r��verboserOr5s    r;rzTarFile.listUs���	
���
�
�
��?��G��	�	�G��
E��<�'���-�-�-�-���
�g�l� ;� ;�<�<�<��w�}�'C���'C�'C�'.�}�'C���'C�E�F�F�F��=�=�?�?�7�g�m�m�o�o�7���$��(8�'�:J�'K�K�!M�N�N�N�N� ���� 5�6�6�6��=�(�� 5�6�6�6�6�� =�"&�.���"?�"?����"C�!D�E�E�E�
���w�}�}���(F���B�G�H�H�H��
?��=�=�?�?�:����(8� 8�9�9�9��=�=�?�?�?��
�W�-=� =�>�>�>��G�G�G�G�5	�	r=��filterc���|�d��|�|}|j�Ctj�|��|jkr|�dd|z��dS|�d|��|�||��}|�|�dd|z��dS|�(||��}|�|�dd|z��dS|���rAt|d��5}|�	||��ddd��dS#1swxYwYdS|�
��r�|�	|��|ryttj|����D]Y}|�
tj�||��tj�||��||�	���XdSdS|�	|��dS)
a!Add the file `name' to the archive. `name' may be any type of file
           (directory, fifo, symbolic link, etc.). If given, `arcname'
           specifies an alternative name for the file in the archive.
           Directories are added recursively by default. This can be avoided by
           setting `recursive' to False. `filter' is a function
           that expects a TarInfo object argument and returns the changed
           TarInfo object, if it returns None the TarInfo object will be
           excluded from the archive.
        r�Nr%ztarfile: Skipped %rr$ztarfile: Unsupported type %r�tarfile: Excluded %rr?r�)r}r�r�r&rI�_dbgr�r\rH�addfiler^r^�listdir�addr�)r�r�r��	recursiver�r5�fs       r;r�zTarFile.add{sD��	
���E�����?��G��9� �R�W�_�_�T�%:�%:�d�i�%G�%G��I�I�a�.��5�6�6�6��F��	�	�!�T�����/�/�$��0�0���?��I�I�a�7�$�>�?�?�?��F����f�W�o�o�G����	�	�!�3�d�:�;�;�;����=�=�?�?�	"��4��&�&�
)�!����W�a�(�(�(�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)�
)�
)��]�]�_�_�	"��L�L��!�!�!��
6���
�4� 0� 0�1�1�6�6�A��H�H�R�W�\�\�$��2�2�B�G�L�L��!�4L�4L�%�f��6�6�6�6�
6�
6�6�6�

�L�L��!�!�!�!�!s�;D�D#�&D#c�f�|�d��tj|��}|�|j|j|j��}|j�|��|xjt|��z
c_|j
}|��t||j|j|���t|jt��\}}|dkr/|j�tt|z
z��|dz
}|xj|tzz
c_|j�|��dS)aAdd the TarInfo object `tarinfo' to the archive. If `fileobj' is
           given, it should be a binary file, and tarinfo.size bytes are read
           from it and added to the archive. You can create TarInfo objects
           directly, or by using gettarinfo().
        r�N)rprr$)r}r�r�rYr9r:r�rlr
r5rNrir(rjrr6rOr�)r�r5r�rbrprqrrs       r;r�zTarFile.addfile�s��	
���E�����)�G�$�$���m�m�D�K�����D�D������3�������s�3�x�x����� ��������w�|�W�M�M�M�M� &�w�|�Y� ?� ?��F�I��1�}�}���"�"�3�)�i�*?�#@�A�A�A��!����K�K�6�I�-�-�K�K�����G�$�$�$�$�$r=c���|�6|j}|�tSt|t��rt	d���|St|��r|S	t|S#t$rtd|�d���d�wxYw)NzrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.zfilter z
 not found)	�extraction_filterrir�r��	TypeError�callable�_NAMED_FILTERSrzr3)r�r�s  r;�_get_filter_functionzTarFile._get_filter_function�s����>��+�F��~�+�+��&�#�&�&�
7��6�7�7�7��M��F���	��M�	G�!�&�)�)���	G�	G�	G��;�v�;�;�;�<�<�$�F�	G���s�A�A7�.)�
numeric_ownerr�c��g}|�|��}|�|}|D]q}|�|||��}|��|���r|�|��|�|||���|����r|�d�d���|D]�}tj�||j	��}		|�
||	|���|�||	��|�||	���m#t$r}
|�|
��Yd}
~
��d}
~
wwxYwdS)a�Extract all members from the archive to the current working
           directory and set owner, modification time and permissions on
           directories afterwards. `path' specifies a different directory
           to extract to. `members' is optional and must be a subset of the
           list returned by getmembers(). If `numeric_owner` is True, only
           the numbers for user/group names are used and not the names.

           The `filter` function will be called on each member just
           before extraction.
           It can return a changed TarInfo or None to skip the member.
           String names of common filters are accepted.
        N��	set_attrsr�c��|jSr�r~)rCs r;�<lambda>z$TarFile.extractall.<locals>.<lambda>�s��q�v�r=T)rZ�reverse)r�)r��_get_extract_tarinfor^r��_extract_one�sortr�r&r�r��chown�utime�chmodr�_handle_nonfatal_error)r�r&rOr�r��directories�filter_functionrbr5�dirpathr�s           r;�
extractallzTarFile.extractall�s������3�3�F�;�;���?��G��
	;�
	;�F��/�/����N�N�G�����}�}���
,��"�"�7�+�+�+����g�t�7�=�=�?�?�7J�,9�
�
;�
;�
;�
;�	���-�-�t��<�<�<�#�	/�	/�G��g�l�l�4���6�6�G�
/��
�
�7�G�=�
�I�I�I��
�
�7�G�,�,�,��
�
�7�G�,�,�,�,���
/�
/�
/��+�+�A�.�.�.�.�.�.�.�.�����
/����
	/�	/s�AD�
E�!D;�;Er�c��|�|��}|�|||��}|�|�||||��dSdS)a�Extract a member from the archive to the current working directory,
           using its full name. Its file information is extracted as accurately
           as possible. `member' may be a filename or a TarInfo object. You can
           specify a different directory using `path'. File attributes (owner,
           mtime, mode) are set unless `set_attrs' is False. If `numeric_owner`
           is True, only the numbers for user/group names are used and not
           the names.

           The `filter` function will be called before extraction.
           It can return a changed TarInfo or None to skip the member.
           String names of common filters are accepted.
        N)r�r�r�)r�rbr&r�r�r�r�r5s        r;�extractzTarFile.extract	s\���3�3�F�;�;���+�+�F�O�T�J�J�������g�t�Y�
�F�F�F�F�F��r=c��t|t��r|�|��}n|}|}	|||��}nZ#ttf$r}|�|��Yd}~n/d}~wt$r}|�|��Yd}~nd}~wwxYw|� |�dd|j	z��dS|�
��r>tj|��}tj
�||j��|_|S)z@Get filtered TarInfo (or None) from member, which might be a strNr%r�)r�r�r{r�r;�_handle_fatal_errorrr�r�r�r]r�r�r&r�r`ry)r�rbr�r&r5�
unfilteredr�s       r;r�zTarFile._get_extract_tarinfo	s/���f�c�"�"�	��n�n�V�,�,�G�G��G��
�	+�%�o�g�t�4�4�G�G����%�	(�	(�	(��$�$�Q�'�'�'�'�'�'�'�'������	+�	+�	+��'�'��*�*�*�*�*�*�*�*�����	+�����?��I�I�a�/�*�/�A�B�B�B��4��=�=�?�?�	H��i��(�(�G�#%�7�<�<��g�6F�#G�#G�G� ��s!�>�B�A)�)
B�6B�Bc�T�|�d��	|�|tj�||j��||���dS#t$r }|�|��Yd}~dSd}~wt$r }|�	|��Yd}~dSd}~wwxYw)z%Extract from filtered tarinfo to diskr�r�N)
r}�_extract_memberr�r&r�r�r�r�rr�)r�r5r&r�r�r�s      r;r�zTarFile._extract_one0	s������C����	+�� � ��"�'�,�,�t�W�\�*J�*J�+4�/<�
!�
>�
>�
>�
>�
>���	(�	(�	(��$�$�Q�'�'�'�'�'�'�'�'�'������	+�	+�	+��'�'��*�*�*�*�*�*�*�*�*�����	+���s#�<A�
B'�A:�:
B'�B"�"B'c�P�|jdkr�|�dd|z��dS)z=Handle non-fatal error (ExtractError) according to errorlevelr$�tarfile: %sN)rMr��r�r�s  r;r�zTarFile._handle_nonfatal_error=	s1���?�Q�����I�I�a���*�+�+�+�+�+r=c�B�|jdkr�t|t��rO|j� |�dd|jz��dS|�dd|j�d|j����dS|�ddt
|��j�d|����dS)z1Handle "fatal" error according to self.errorlevelrNr$r�z	tarfile: rv)rMr�r��filenamer��strerrorrtrr�s  r;r�zTarFile._handle_fatal_errorD	s����?�Q����
��7�
#�
#�	C��z�!��	�	�!�]�Q�Z�7�8�8�8�8�8��	�	�!�!�����Q�Z�Z�H�I�I�I�I�I��I�I�a�a�T�!�W�W�-=�-=�-=�q�q�A�B�B�B�B�Br=c���|�d��t|t��r|�|��}n|}|���s|jtvr|�||��S|���s|�	��rQt|j
t��rtd���|�
|�|����SdS)a\Extract a member from the archive as a file object. `member' may be
           a filename or a TarInfo object. If `member' is a regular file or
           a link, an io.BufferedReader object is returned. For all other
           existing members, None is returned. If `member' does not appear
           in the archive, KeyError is raised.
        r�z'cannot extract (sym)link as file objectN)r}r�r�r{r\rtr��
fileobjectr]r_r�r�r
�extractfile�_find_link_target)r�rbr5s   r;r�zTarFile.extractfileP	s���	
���C�����f�c�"�"�	��n�n�V�,�,�G�G��G��=�=�?�?�	�g�l�/�A�A��?�?�4��1�1�1�
�]�]�_�_�	��
�
���	��$�,��0�0�
I�"�"K�L�L�L��'�'��(>�(>�w�(G�(G�H�H�H��4r=c��|�d��}|�dtj��}tj�|��}|r3tj�|��stj|��|���s|�	��r&|�
d|j�d|j����n|�
d|j��|�
��r|�||���n|���r|�||��n�|���r|�||��n�|���s|���r|�||��nz|���s|�	��r|�||��n;|jt0vr|�||��n|�||��|rY|�|||��|�	��s0|�||��|�||��dSdSdS)z\Extract the TarInfo object tarinfo to a physical
           file called targetpath.
        rTr$z -> N)r�r�r�rXr&rarG�makedirsr]r_r�r�r`r\�makefiler^�makedirr2�makefifor-r/�makedev�makelinkrtr��makeunknownr�r�r�)r�r5�
targetpathr�r��	upperdirss      r;r�zTarFile._extract_memberp	s\�� �&�&�s�+�+�
��'�'��R�V�4�4�
��G�O�O�J�/�/�	��	#�R�W�^�^�I�6�6�	#�
�K�	�"�"�"��=�=�?�?�	'�g�m�m�o�o�	'��I�I�a�w�|�|�|�W�5E�5E�F�G�G�G�G��I�I�a���&�&�&��=�=�?�?�
	/��M�M�'�:�.�.�.�.�
�]�]�_�_�	/��L�L��*�-�-�-�-�
�^�^�
�
�		/��M�M�'�:�.�.�.�.�
�]�]�_�_�	/��
�
���	/��L�L��*�-�-�-�-�
�]�]�_�_�	/��
�
���	/��M�M�'�:�.�.�.�.�
�\��
0�
0����W�j�1�1�1�1��M�M�'�:�.�.�.��	0��J�J�w�
�M�:�:�:��=�=�?�?�
0��
�
�7�J�/�/�/��
�
�7�J�/�/�/�/�/�		0�	0�
0�
0r=c���	|j�tj|��dStj|d��dS#t$r$tj�|��s�YdSwxYw)z,Make a directory called targetpath.
        Ni�)r�r��mkdir�FileExistsErrorr&r^�r�r5r�s   r;r�zTarFile.makedir�	s���
	��|�#����$�$�$�$�$����U�+�+�+�+�+���	�	�	��7�=�=��,�,�
��
�
�
�	���s�6�6�*A$�#A$c	���|j}|�|j��|j}t	|d��5}|j�i|jD]2\}}|�|��t
|||t|���3|�|j��|�	��nt
|||jt|��ddd��dS#1swxYwYdS)z'Make a file called targetpath.
        r@N)
r�r�r1rNrHr2rirr(�truncate)r�r5r��sourcerp�targetr
r(s        r;r�zTarFile.makefile�	s5��������G�'�(�(�(��"��
�z�4�
(�
(�	N�F��~�)�$+�N�J�J�L�F�D��K�K��'�'�'�����i��I�I�I�I����G�L�)�)�)����!�!�!�!��F�F�G�L�)�W�M�M�M�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N����	N�	N�	N�	N�	N�	Ns�BC�C�Cc�n�|�||��|�dd|jz��dS)zYMake a file from a TarInfo object with an unknown type
           at targetpath.
        r$z9tarfile: Unknown file type %r, extracted as regular file.N)r�r�rtr�s   r;r�zTarFile.makeunknown�	sO��	
�
�
�g�z�*�*�*��	�	�!�2�4;�L�A�	B�	B�	B�	B�	Br=c�v�ttd��rtj|��dStd���)z'Make a fifo called targetpath.
        �mkfifozfifo not supported by systemN)r�r�r�rr�s   r;r�zTarFile.makefifo�	s;���2�x� � �	?��I�j�!�!�!�!�!��=�>�>�>r=c�Z�ttd��rttd��std���|j}|�d}|���r|t
jz}n|t
jz}tj||tj	|j
|j����dS)z<Make a character or block device called targetpath.
        �mknodr�z'special devices not supported by systemNrV)r�r�rr�r/r��S_IFBLK�S_IFCHRr�r�rurv)r�r5r�r�s    r;r�zTarFile.makedev�	s����r�7�#�#�	J�7�2�y�+A�+A�	J��H�I�I�I��|���<��D��=�=�?�?�	!��D�L� �D�D��D�L� �D�
���T���G�,�g�.>�?�?�	A�	A�	A�	A�	Ar=c�R�	|���rOtj�|��rtj|��tj|j|��dStj�|j��rtj	|j|��dS|�
|�|��|��dS#t$rL	|�
|�|��|��YdS#t$rtd��d�wxYwwxYw)z�Make 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)r_r�r&�lexists�unlink�symlinkr`rGry�linkr�r��symlink_exceptionrzrr�s   r;r�zTarFile.makelink�	sR��
	V��}�}���

5��7�?�?�:�.�.�*��I�j�)�)�)��
�7�+�Z�8�8�8�8�8��7�>�>�'�"6�7�7�5��G�G�0�*�=�=�=�=�=��(�(��)?�)?��)H�)H�)3�5�5�5�5�5�� �	V�	V�	V�
V��$�$�T�%;�%;�G�%D�%D�%/�1�1�1�1�1�1���
V�
V�
V�"�#J�K�K�QU�U�
V����		V���s*�A!C�%>C�%)C�
D&�)D�D"�"D&c��ttd���r*tj��dk�r|j}|j}|s~	t
r&|jrtj|j��d}n#t$rYnwxYw	tr&|j
rtj|j
��d}n#t$rYnwxYw|�d}|�d}	|���r-ttd��rtj
|||��dStj|||��dS#t$r}t!d��|�d}~wwxYwdSdS)z�Set 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%Nr?�lchownzcould not change owner)r�r�r�r+r*r�r-�getgrnamrzr�r,�getpwnamr_r�r�r�r)r�r5r�r��g�ur�s       r;r�z
TarFile.chown�	s����2�y�!�!�	D�b�j�l�l�a�&7�&7���A���A� �

���;�w�}�;��L���7�7��:���������D�������;�w�}�;��L���7�7��:���������D������y����y���
D��=�=�?�?�/�w�r�8�'<�'<�/��I�j�!�Q�/�/�/�/�/��H�Z��A�.�.�.�.�.���
D�
D�
D�"�#;�<�<�!�C�����
D����1	D�	D�&7�&7sB�-A.�.
A;�:A;�?-B-�-
B:�9B:�?D�D�
D>�)D9�9D>c��|j�dS	tj||j��dS#t$r}t	d��|�d}~wwxYw)zASet file permissions of targetpath according to tarinfo.
        Nzcould not change mode)r�r�r�r�r)r�r5r�r�s    r;r�z
TarFile.chmod
s`���<���F�	?��H�Z���.�.�.�.�.���	?�	?�	?��6�7�7�Q�>�����	?���s�'�
A�A�Ac��|j}|�dSttd��sdS	tj|||f��dS#t$r}td��|�d}~wwxYw)zBSet modification time of targetpath according to tarinfo.
        Nr�z"could not change modification time)r)r�r�r�r�r)r�r5r�r)r�s     r;r�z
TarFile.utime&
s����
���=��F��r�7�#�#�	��F�	L��H�Z�%���0�0�0�0�0���	L�	L�	L��C�D�D�!�K�����	L���s�=�
A�A�Ac�0�|�d��|j�|j}d|_|S|j|j���krX|jdkrdS|j�|jdz
��|j�d��std���d}		|j�	|��}�n�#t$rL}|jr:|�dd|j|fz��|xjtz
c_Yd}~�iYd}~�nYd}~wt$rs}|jr:|�dd|j|fz��|xjtz
c_Yd}~��|jdkrtt|����d�Yd}~n�d}~wt $r|jdkrtd	��d�Yn�t"$r2}|jdkrtt|����d�Yd}~n~d}~wt$$r"}tt|����d�d}~wt&$rD}	ddl}t+||j��rtd
|����d�|�#t.$r|�wxYwd}~wwxYw	|�|j�|��nd|_|S)z�Return the next member of the archive as a TarInfo object, when
           TarFile is opened for reading. Return None if there is no more
           available.
        �raNrr$rgTr%z0x%X: %sz
empty filezzlib error: )r}rRr
r�r�r�rkrr5r�r�rKr�rrPr�r�r�r��	Exceptionr�r�r�r�rOr�rP)r��mr5r�r�s     r;r�zTarFile.next4
s1��
	
���D������'�� �A�#�D���H��;�$�,�+�+�-�-�-�-��{�a����t��L���d�k�A�o�.�.�.��<�$�$�Q�'�'�
:�� 8�9�9�9��� 	�
��,�2�2�4�8�8����!�
�
�
��$���I�I�a��t�{�A�.>�!>�?�?�?��K�K�9�,�K�K��H�H�H�H����������&�
6�
6�
6��$�6��I�I�a��t�{�A�.>�!>�?�?�?��K�K�9�,�K�K��H�H�H�H��[�A�%�%�#�C��F�F�+�+��5�&�%�%�%�%�����#�
<�
<�
<��;�!�#�#�#�L�1�1�t�;�$�#�'�
6�
6�
6��;�!�#�#�#�C��F�F�+�+��5�$�#�#�#�#�����(�
2�
2�
2���A���'�'�T�1������
�
�
���K�K�K�!�!�T�Z�0�0� �'�(:�q�(:�(:�;�;��E����"�����G���������
����
����L����(�(�(�(��D�L��s`�+C�
I.�<D�
I.�%<F�&(F�(I.�=	I.�(G3�3
I.�H�
I.�+.I�
I&�&I)�)I.c��|���}d}|�3	|�|��}|d|�}n#t$rd}YnwxYw|rtj�|��}t
|��D]O}|r|j|jkrd}�|r%tj�|j��}n|j}||kr|cS�P|rt|���dS)z}Find an archive member by name from bottom to top.
           If tarinfo is given, it is used as the starting point.
        FNT)	r�indexr3r�r&�normpath�reversedr
r�)	r�r�r5�	normalizerO�skippingrrb�member_names	         r;ryzTarFile._getmemberu
s'��
�/�/�#�#������
*��
�
�g�.�.��"�&�5�&�/����
�
 �
 �
 � ����
 �����	*��7�#�#�D�)�)�D��w�'�'�	�	�F��
��>�V�]�2�2�$�H���
*� �g�.�.�v�{�;�;���$�k���{�"�"��
�
�
�#��	&��W�%�%�%�	&�	&s�:�A	�A	c�F�	|���}|�n�d|_dS)zWRead through the entire archive file and look for readable
           members.
        TN)r�rP)r�r5s  r;r~z
TarFile._load�
s.��	��i�i�k�k�G����	�����r=c��|jrtd|jjz���|� |j|vrtd|jz���dSdS)znCheck if TarFile is still open, and if the operation's mode
           corresponds to TarFile's mode.
        z%s is closedNzbad operation for mode %r)r�r�r6rr�)r�r�s  r;r}zTarFile._check�
s]���;�	D��.�4�>�+B�B�C�C�C����	�� 5� 5��5��	�A�B�B�B��� 5� 5r=c�6�|���rOd�tdtj�|j��|jf����}d}n	|j}|}|�||d���}|�td|z���|S)zZFind the target member of a symlink or hardlink member in the
           archive.
        rTNT)r5rzlinkname %r not found)
r_r�r�r�r&rar�r`ryrz)r�r5r`�limitrbs     r;r�zTarFile._find_link_target�
s����=�=�?�?�	��x�x��t�b�g�o�o�g�l�.K�.K�W�M]�-^� _� _�`�`�H��E�E��'�H��E�����5�D��I�I���>��2�X�=�>�>�>��
r=c#�2K�|jr|jEd{V��dSd}|j�|���}|dz
}|V�	|t	|j��kr|j|}n)|js |���}|s	d|_dSndS|dz
}|V��Y)z$Provide an iterator object.
        Nrr$T)rPrOrRr�r5)r�rr5s   r;�__iter__zTarFile.__iter__�
s������<�	��|�#�#�#�#�#�#�#��F�����'��i�i�k�k�G��Q�J�E��M�M�M�	��s�4�<�(�(�(�(��,�u�-����\�
��)�)�+�+����#'�D�L��F�����Q�J�E��M�M�M�	r=c�V�||jkrt|tj���dSdS)z.Write debugging output to sys.stderr.
        ��fileN)rLr{ry�stderr)r��level�msgs   r;r�zTarFile._dbg�
s4���D�J����#�C�J�'�'�'�'�'�'��r=c�.�|���|Sr�)r}r�s r;�	__enter__zTarFile.__enter__�
s�����
�
�
��r=c��|�|���dS|js|j���d|_dSr)r�r�r�r�)r�rtr��	tracebacks    r;�__exit__zTarFile.__exit__�
sD���<��J�J�L�L�L�L�L��#�
%���"�"�$�$�$��D�K�K�Kr=)
Nr�NNNNNNr�NNNN)r�N)r�Nr�)r�NN)NNN�Trr�)r�N)r�T)TFr)>rr�r�r�rLrJrKrMrrYr
r9r:rr5r/r�r�r�r;rwrrWrmrqrurXr�r{rr�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ryr~r}r�rr�rr!r�r=r;rrms���������
�E��K��L��J��F��H�
�F��G��J���AE�HL�>B�)-�b�b�b�b�^��#�t�Z�[/�[/�[/��[�[/�z�2�2�2��[�2������[��@�����[��6�����[��:����	��I�%�%�%�*	�	�	����?�?�?�a�a�a�a�F$�D�$�$�$�$�$�L1"��1"�1"�1"�1"�1"�f%�%�%�%�2G�G�G�$+/�%��+/�+/�+/�+/�+/�ZG���G�G�G�G�G�&���.+�+�+�,�,�,�
C�
C�
C����@>B�&+�*0�*0�*0�*0�b
�
�
�N�N�N� B�B�B�?�?�?�A�A�A�$V�V�V�2D�D�D�B?�?�?�L�L�L�<�<�<�B&&�&&�&&�&&�P���C�C�C�C����&���>(�(�(��������r=rc��	t|d��r:|���}t|���}|�|��nt|��}|���dS#t
$rYdSwxYw)z�Return True if name points to a tar archive that we
       are able to handle, else return False.

       'name' should be a string, file, or file-like object.
    rk)r�TF)r�r�rr�r�r)r�r�r�s   r;rr�
s���
��4�� � �	��)�)�+�+�C��T�"�"�"�A��I�I�c�N�N�N�N��T�
�
�A�	���	�	�	��t�������u�u����s�A-A1�1
A?�>A?c	�z	�ddl}d}|�|���}|�ddddd�	��|�d
dtd�
��|�d���}|�dddd���|�ddddd���|�ddddd���|�dd dd!���|���}|jr|j�|�d"d#��|j	��|j	}t|��r�t|d$��5}|���t|���tj�%��ddd��n#1swxYwY|jr$td&�|����dSdS|�d"d'�|����dS|j��|j}t|��rQt&�|d(��5}|�|j�)��ddd��dS#1swxYwYdS|�d"d'�|����dS|j��Rt)|j��d"kr|jd}t*j}nKt)|j��d*kr|j\}}n(|�d"|�����t|��r�t&�|d(��5}|�||j�+��ddd��n#1swxYwY|jrC|d,krd-�|��}	nd.�||��}	t|	��dSdS|�d"d'�|����dS|j��|j�d��}
t*j�|
��\}}d/d/d0d0d1d1d1d1d2�}
||
vrd3|
|znd4}|j}t&�|
|��5}|D]}|�|���	ddd��n#1swxYwY|jr&td5�|
����dSdSdS)6Nrz3A simple command-line interface for tarfile module.)�descriptionz-vz	--verbose�
store_trueFzVerbose output)�action�default�helpz--filterz<filtername>zFilter for extraction)�metavar�choicesr)T)�requiredz-lz--list�	<tarfile>zShow listing of a tarfile)r*r)z-ez	--extract�+)r-z<output_dir>zExtract tarfile into target dir)�nargsr*r)z-cz--create)z<name>z<file>zCreate tarfile from sourcesz-tz--testzTest if a tarfile is validr$z&--filter is only valid for extraction
r�rz{!r} is a tar archive.z{!r} is not a tar archive.
rU)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:r�z{!r} file created.)�argparse�ArgumentParser�add_argumentr��add_mutually_exclusive_group�
parse_argsr�r��exit�testrrrr{ryrr�rYrrr5r��curdir�format_helpr��create�popr&�splitextr�)r0r%�parserr��argsrmr��tfr7r�tar_namer�ext�compressions�tar_mode�	tar_files�	file_names                 r;�mainrEs$���O�O�O�G�K�
�
$�
$��
$�
=�
=�F�
����k�,��-��/�/�/�
���
�N� .�4��6�6�6�
�/�/��/�>�>�E�	���t�X�{�7��9�9�9�	���t�[��<�=��?�?�?�
���t�Z�s�3�9��;�;�;�
���t�X�{�8��:�:�:������D��{�B�t�|�+����A�@�A�A�A��y���i���c�?�?�	G��c�3���
9�3���� � � ��c�n�n�&�&�S�Z�8�8�8�8�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9��|�
<��.�5�5�c�:�:�;�;�;�;�;�
<�
<�
�K�K��9�@�@��E�E�F�F�F�F�F�	
��	��i���c�?�?�	G����c�5�)�)�
.�R�������-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.�
.�
.�
�K�K��9�@�@��E�E�F�F�F�F�F�	
��	!��t�|����!�!��,�q�/�C��Y�F�F�
���
�
�!�
#�
#��,�K�C����K�K��6�-�-�/�/�0�0�0��c�?�?�	G����c�5�)�)�
?�R��
�
�6�$�+�
�>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��|�
��S�=�=�3�:�:�3�?�?�C�C�2�39�6�#�v�3F�3F���c�
�
�
�
�
�

�
�
�K�K��9�@�@��E�E�F�F�F�F�F�	
��	 ��;�?�?�1�%�%����!�!�(�+�+���3���������
�
��03�l�/B�/B�4�,�s�+�+�+����K�	�
�\�\�(�H�
-�
-�	"��&�
"�
"�	����y�!�!�!�!�
"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��<�	9��&�-�-�h�7�7�8�8�8�8�8�1
!�	 �.	9�	9sI�6AF�F�F�I�I�I�/M�M�M�R�R�
R�__main__r")mr��version�
__author__�__credits__�builtinsrrHryr�r rhr�r�r`r��re�warningsr�r�r��AttributeError�NotImplementedErrorr�r��	NameError�__all__r6rrwr�r�r�r�r�r{r�r+r)r�r�r�r1�CONTTYPEr�r�r�r�r�r�rrrrr�r#r�rrr�rNrr�r
�getfilesystemencodingr<rCrSr[rerir|rrrrr	r
rr�r�r�rPr�r�r��objectr�r�BufferedReaderr/r;r=rBrKrNrQrgrirnrpr�r��compiler�rrrrErr�r=r;�<module>rVs���:����6�
�H��
'�&�&�&�&�&�
�
�
�
�	�	�	�	�	�	�	�	�
�
�
�
���������
�
�
�
�����	�	�	�	�������J�J�J�J������
�C�C�C�������J�J�J�J������
�C�C�C�����$�%8�9��	��'��#�����	�	�	��D�	����%�%�%�����	�
��^�
��	��������
�
����
��
��
��
��
������������
��
������
�
�
�
����H�g��G�X��W�g�#�%5�!�	#���(��>�+�
��/�
�
�	�.�
�9�8�8��
�
�
����
����7�d�?�?��H�H�(�s�(�*�*�H�0�0�0�&�&�&�
�
�
�(�N�
�
�
�
�<*�*�*�"&��$�����2���	�	�	�	�	�y�	�	�	�	�	�	�	�	�8�	�	�	�	�	�	�	�	��	�	�	�	�	�	�	�	�x�	�	�	�	�	�	�	�	�(�	�	�	�	�	�	�	�	�(�	�	�	�	�	�	�	�	�{�	�	�	�	�	�	�	�	�;�	�	�	�	�	�	�	�	�[�	�	�	�	�	�	�	�	��	�	�	�	�	�	�	�	�K�	�	�	���������0p�p�p�p�p�p�p�p�f�����6����<e�e�e�e�e�&�e�e�e�P"�"�"�"�"�2�$�"�"�"�	�	�	�	�	�(�	�	�	�J�J�J�J�J��J�J�J�
?�?�?�?�?�k�?�?�?�@�@�@�@�@�{�@�@�@�
L�L�L�L�L��L�L�L�
?�?�?�?�?�+�?�?�?�=�=�=�=�~���������*������	�����&�2�:�&8�9�9��Z9�Z9�Z9�Z9�Z9�f�Z9�Z9�Z9�zG�G�G�G�G�f�G�G�G�Z$���$�|��]9�]9�]9�~�z����D�F�F�F�F�F��s3�=�A�A�A�A�A�"A)�)A1�0A1

?>