Hacked By AnonymousFox

Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/tarfile.cpython-312.pyc

�

�Q�f֧����dZdZdZdZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZ	ddlZ	ddlZeeefZgd�ZdZd	Zed
zZdZdZd
Zd
ZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2e2Z3e!e"e#e$e'e(e)e%e&e*e+e,fZ4e!e"e)e,fZ5e*e+e,fZ6dZ7hd �Z8e9e9e9e:e:e:d!�Z;ejxd"k(rd#Z=nej|�Z=d$�Z?d%�Z@d&�ZAd'e3fd(�ZBd)�ZCdedfd*�ZDd+�ZEGd,�d-eF�ZGGd.�d/eG�ZHGd0�d1eG�ZIGd2�d3eG�ZJGd4�d5eG�ZKGd6�d7eG�ZLGd8�d9eL�ZMGd:�d;eL�ZNGd<�d=eL�ZOGd>�d?eL�ZPGd@�dAeL�ZQGdB�dC�ZRGdD�dE�ZSGdF�dGeT�ZUGdH�dIeT�ZVGdJ�dKe	j��ZXGdL�dMeG�ZYGdN�dOeY�ZZGdP�dQeY�Z[GdR�dSeY�Z\GdT�dUeY�Z]GdV�dWeY�Z^dedX�Z_dY�Z`dZ�Zad[�Zbe`eaebd\�ZceT�Zdej�d]�ZfGd^�d_eT�ZgGd`�daeT�Zhdb�Ziehj
Zdc�Zjekddk(rej�yy#e$rdZY��wxYw#e$rdZY��wxYw)fz,Read from and write to tar format archives.
z0.9.0u"Lars Gustäbel (lars@gustaebel.de)u4Gustavo Niemeyer, Niels Gustäbel, Richard Townsend.�)�openN)�TarFile�TarInfo�
is_tarfile�TarError�	ReadError�CompressionError�StreamError�ExtractError�HeaderError�ENCODING�USTAR_FORMAT�
GNU_FORMAT�
PAX_FORMAT�DEFAULT_FORMATr�fully_trusted_filter�data_filter�
tar_filter�FilterError�AbsoluteLinkError�OutsideDestinationError�SpecialFileError�AbsolutePathError�LinkOutsideDestinationError�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/r6r5r0)�atime�ctimer2r3r4r1�nt�utf-8c�v�|�td��|j||�}|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/python312/lib64/python3.12/tarfile.py�stnrE�sC��	�y��7�8�8�	����6�"�A��W�f�:��#�a�&��C�/�/�/�c�\�|jd�}|dk7r|d|}|j||�S)z8Convert a null-terminated bytes object to a string.
    r���N)�find�decode)r@rBrC�ps    rD�ntsrL�s4��	
���u�
�A��B�w�
�b�q�E���8�8�H�f�%�%rFc�6�|ddvrMd}tt|�dz
�D]}|dz}|||dzz
}�|ddk(rdt|�dz
z|z
}|S	t|dd�}t|j	�xsd	d�}|S#t
$rt
d
��wxYw)z/Convert a number field to a python number.
    r)��r-�rO��ascii�strict�0�invalid header)�ranger>rL�int�stripr<�InvalidHeaderError)r@�n�is   rD�ntir\�s���
	��t�~��
���s�1�v��z�"�A�
�!�G�A�
��1�q�5��M�A�#�
�Q�4�5�=��#�a�&�1�*�%��)�*�A�
�H�	7��A�w��)�A��A�G�G�I�$��a�(�A�
�H���	7�$�%5�6�6�	7�s�+B�BrPc��|}t|�}d|cxkrd|dz
zkr nntd|dz
|fzd�tz}|S|tk(rzd|dz
z|cxkrd|dz
zkrbntd	��|dk\r
t	dg�}nt	dg�}d|z|z}t|dz
�D]}|j
d|dz�|dz}�|Std	��)
z/Convert a python number to a number field.
    rrPr-z%0*orRrQrNrOzoverflow in number field)rW�bytesr?r�	bytearrayrV�insertr<)rZ�digits�format�
original_nr@r[s      rD�itnrd�s����J��A��A��A�!��f�q�j�!�!��&�F�Q�J��?�*�G�4�s�:��
�H�
�:�	�3�6�A�:�#6�"6�!�"Q�c�f�q�j�>Q�"Q��3�4�4�
��6��5�'�"�A��5�'�"�A��v�
��!�A��v��z�"�A�
�H�H�Q��E�	�"�
�!�G�A�#�
�H��3�4�4rFc��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.
    rQ�
148B8x356B�
148b8x356b)�sum�struct�unpack_from)�buf�unsigned_chksum�
signed_chksums   rD�calc_chksumsrn�sG���C�� 2� 2�<�� E�F�F�O��#�f�0�0��s�C�D�D�M��M�)�)rFc�x�|xsd}|dk(ry|�tj|||�yt||�\}}t|�D]:}|j	|�}t|�|kr|d��|j
|��<|dk7r8|j	|�}t|�|kr|d��|j
|�y)zjCopy length bytes from fileobj src to fileobj dst.
       If length is None, copy the entire content.
    i@rN�unexpected end of data)�shutil�copyfileobj�divmodrV�readr>�write)	�src�dstrA�	exception�bufsize�blocks�	remainder�brks	         rDrrrr�s����"��G�
��{��
�~����3��W�-���v�w�/��F�I�
�6�]���h�h�w����s�8�g���4�5�5��	�	�#��	��A�~��h�h�y�!���s�8�i���4�5�5��	�	�#��
rFc��ttjdd�}|�!|j|d�j	|�}t|d��y)NrB�backslashreplace� )�end)�getattr�sys�stdoutr=rJ�print)r@rBs  rD�_safe_printr�s@���s�z�z�:�t�4�H���
�H�H�X�1�2�9�9�(�C��	�!��rFc��eZdZdZy)rzBase exception.N��__name__�
__module__�__qualname__�__doc__�rFrDrrs���rFrc��eZdZdZy)rz%General exception for extract errors.Nr�r�rFrDrrs��/�rFrc��eZdZdZy)rz&Exception for unreadable tar archives.Nr�r�rFrDrrs��0�rFrc��eZdZdZy)r	z.Exception for unavailable compression methods.Nr�r�rFrDr	r	s��8�rFr	c��eZdZdZy)r
z=Exception for unsupported operations on stream-like TarFiles.Nr�r�rFrDr
r
s��G�rFr
c��eZdZdZy)rz!Base exception for header errors.Nr�r�rFrDrrs��+�rFrc��eZdZdZy)�EmptyHeaderErrorzException for empty headers.Nr�r�rFrDr�r� s��&�rFr�c��eZdZdZy)�TruncatedHeaderErrorz Exception for truncated headers.Nr�r�rFrDr�r�#s��*�rFr�c��eZdZdZy)�EOFHeaderErrorz"Exception for end of file headers.Nr�r�rFrDr�r�&s��,�rFr�c��eZdZdZy)rYzException for invalid headers.Nr�r�rFrDrYrY)s��(�rFrYc��eZdZdZy)�SubsequentHeaderErrorz3Exception for missing and invalid extended headers.Nr�r�rFrDr�r�,s��=�rFr�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�
_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|tjz}tj||d�|_y)N��r�w�O_BINARYi�)	�os�O_RDONLY�O_WRONLY�O_CREAT�O_TRUNC�hasattrr�r�fd)�self�name�modes   rD�__init__z_LowLevelFile.__init__9sa��������r�z�z�)�B�J�J�6�
�����2�z�"��B�K�K��D��'�'�$��e�,��rFc�B�tj|j�y�N)r��closer��r�s rDr�z_LowLevelFile.closeBs��
������rFc�B�tj|j|�Sr�)r�rtr��r�r1s  rDrtz_LowLevelFile.readEs���w�w�t�w�w��%�%rFc�D�tj|j|�yr�)r�rur��r�r@s  rDruz_LowLevelFile.writeHs��
������!�rFN)r�r�r�r�r�r�rtrur�rFrDr�r�3s���
-��&�rFr�c�Z�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd
�Zd�Z
d�Zd
�Zy)�_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|_|dk(rt|�}|j�}|xsd|_||_||_||_||_d|_	d|_
d|_	|dk(r[	ddl}||_|jd�|_|d
k(r"|j"|_|j'�y|j)|�y|dk(rI	ddl}|d
k(r(d|_|j/�|_t2|_y|j5|�|_y|d
k(rN	ddl}	|d
k(r.d|_|	j9�|_|	j:|_y|	j=�|_y|dk7rtd|z��y#t$r
td	�d�wxYw#t$r
td�d�wxYw#t$r
td�d�wxYw#|js|jj?�d|_�xYw)z$Construct a _Stream object.
        TNF�*�rFr�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�fileobjryrk�pos�closed�zlib�ImportErrorr	�crc32�crc�errorrx�
_init_read_gz�_init_write_gzr��dbuf�BZ2Decompressor�cmp�OSError�
BZ2Compressor�lzma�LZMADecompressor�	LZMAError�LZMACompressorr�)
r�r�r�r�r�ry�
compresslevelr�r�r�s
          rDr�z_Stream.__init__Ws�� ����?�#�D�$�/�G�$�D���s�?�#�7�+�G��*�*�,�H��
���	���	� ��
����������������-	��4��U��!��	��:�:�c�?����3�;�%)�Z�Z�D�N��&�&�(��'�'�
�6��U�"�T���3�;� #�D�I�"�2�2�4�D�H�%,�D�N�"�0�0��?�D�H��T�!�U���3�;� #�D�I�#�4�4�6�D�H�%)�^�^�D�N�#�2�2�4�D�H��U�"�&�'D�x�'O�P�P�#��E#�U�*�+I�J�PT�T�U��#�T�*�+H�I�t�S�T��#�U�*�+I�J�PT�T�U��	��#�#����"�"�$��D�K��sy�:G�F�AG�G�G� F(�$,G�G�(G�.G�22G�%G�;G�F%�%G�(F>�>G�G�G�0H
c�X�t|d�r|js|j�yyy)Nr�)r�r�r�r�s rD�__del__z_Stream.__del__�s#���4��"�4�;�;��J�J�L�,7�"rFc�t�|jj||jj|jj|jjd�|_t
jdttj���}|jd|zdz�|jjd�r|jdd|_tjj|j�|_|j|jj!dd	�t"z�y)
z6Initialize for writing with gzip compression.
        r�<Ls�s��.gzN���z
iso-8859-1�replace)r��compressobj�DEFLATED�	MAX_WBITS�
DEF_MEM_LEVELr�ri�packrW�time�_Stream__writer��endswithr�r/�basenamer=r?)r�r��	timestamps   rDr�z_Stream._init_write_gz�s����9�9�(�(��)-���);�);�*.�)�)�*=�*=�)=�)-���)@�)@�)*�	,���
�K�K��c�$�)�)�+�&6�7�	����(�9�4�{�B�C��9�9���e�$��	�	�#�2��D�I��G�G�$�$�T�Y�Y�/��	����T�Y�Y�%�%�l�I�>��D�ErFc�*�|jdk(r+|jj||j�|_|xjt|�z
c_|jdk7r|jj|�}|j|�y)z&Write string s to the stream.
        r�r�N)	r�r�r�r�r�r>r��compressr�r�s  rDruz
_Stream.write�sg���=�=�D� ��y�y���q�$�(�(�3�D�H����C��F����=�=�E�!����!�!�!�$�A����Q�rFc�Z�|xj|z
c_t|j�|jkDrt|jj	|jd|j�|j|jd|_t|j�|jkDr�syy)z]Write string s to the stream if a whole new block
           is ready to be written.
        N)rkr>ryr�rur�s  rD�__writez_Stream.__write�sr��	
���A�
���$�(�(�m�d�l�l�*��L�L���t�x�x�
����6�7��x�x����
�.�D�H��$�(�(�m�d�l�l�*rFc��|jryd|_	|jdk(r<|jdk7r-|xj|jj�z
c_|jdk(r�|jr�|jj|j�d|_|jdk(ru|jjtjd|j��|jjtjd|jdz��|js|jj�yy#|js|jj�wwxYw)	z[Close the _Stream object. No operation should be
           done on it afterwards.
        NTr�r�rFr�r�l��)r�r�r�rkr��flushr�rurir�r�r�r�r�r�s rDr�z
_Stream.close�s	���;�;�����	%��y�y�C��D�M�M�U�$:����D�H�H�N�N�,�,���y�y�C��D�H�H����"�"�4�8�8�,�����=�=�D�(��L�L�&�&�v�{�{�4����'B�C��L�L�&�&�v�{�{�4����J�9N�'O�P��#�#����"�"�$�$��4�#�#����"�"�$�$�s�DE�)E=c��|jj|jj�|_d|_|jd�dk7rt
d��|jd�dk7rtd��t|jd��}|jd�|d	zrIt|jd��d
t|jd��zz}|j|�|dzr	|jd�}|r	|tk(rn�|dzr	|jd�}|r	|tk(rn�|dzr|jd�y
y
)z:Initialize for reading a gzip compressed fileobj.
        rFr.s��not a gzip filer-�zunsupported compression method��rQrP�N)r��
decompressobjr�r�r��
_Stream__readrr	�ordrtr?)r��flag�xlenr@s    rDr�z_Stream._init_read_gz�s+���9�9�*�*�D�I�I�,?�,?�+?�@�����	��;�;�q�>�[�(��-�.�.��;�;�q�>�W�$�"�#C�D�D��4�;�;�q�>�"�����A���!�8��t�{�{�1�~�&��s�4�;�;�q�>�/B�)B�B�D��I�I�d�O��!�8���K�K��N���A��H����"�9���K�K��N���A��H����!�8��K�K��N�rFc��|jS)z3Return the stream's file pointer position.
        )r�r�s rD�tellz_Stream.tell�s
���x�x�rFc��||jz
dk\rnt||jz
|j�\}}t|�D]}|j	|j��|j	|�|jStd��)zXSet the stream's file pointer to pos. Negative seeking
           is forbidden.
        rz seeking backwards is not allowed)r�rsryrVrtr
)r�r�rzr{r[s     rD�seekz_Stream.seekst������>�Q�� &�s�T�X�X�~�t�|�|� D��F�I��6�]���	�	�$�,�,�'�#��I�I�i� ��x�x���@�A�ArFc�l�|�J�|j|�}|xjt|�z
c_|S)z5Return the next size number of bytes from the stream.)�_readr�r>)r�r1rks   rDrtz_Stream.read
s3�������j�j�������C��H����
rFc�(�|jdk(r|j|�St|j�}|jg}||kr�|jr|j}d|_n(|j
j
|j�}|snA	|jj|�}|j|�|t|�z
}||kr��dj|�}||d|_|d|S#|j$r}td�|�d}~wwxYw)z+Return size bytes from the stream.
        r�rFzinvalid compressed dataN)r�r�r>r�rkr�rtryr��
decompressrxr�append�join)r�r1�c�trk�es      rDrz
_Stream._reads����=�=�E�!��;�;�t�$�$���	�	�N��
�Y�Y�K���$�h��x�x��h�h������l�l�'�'����5����
B��h�h�)�)�#�.��
�H�H�S�M�
��S��M�A��$�h�
�H�H�Q�K���d�e�H��	���$�x���
�>�>�
B�� 9�:��A��
B�s�C1�1D�D�Dc�*�t|j�}|jg}||krM|jj|j�}|sn%|j|�|t|�z
}||kr�Mdj
|�}||d|_|d|S)zsReturn size bytes from stream. If internal buffer is empty,
           read another block from the stream.
        rFN)r>rkr�rtryrr)r�r1rrrks     rD�__readz_Stream.__read/s���
����M��
�X�X�J���$�h��,�,�#�#�D�L�L�1�C���
�H�H�S�M�
��S��M�A��$�h�
�H�H�Q�K���T�U�8�����$�x�rFN)r)r�r�r�r�r�r�r�rur�r�r�r�r�rtrr�r�rFrDr�r�KsF��	�E�N�F�"�/�%�,�>�
���6rFr�c�(�eZdZdZd�Zd�Zd�Zd�Zy)r�zsSmall proxy class that enables transparent compression
       detection for the Stream interface (mode 'r|*').
    c�Z�||_|jjt�|_yr�)r�rt�	BLOCKSIZErk)r�r�s  rDr�z_StreamProxy.__init__Es������<�<�$�$�Y�/��rFc�P�|jj|_|jSr�)r�rtrkr�s  rDrtz_StreamProxy.readIs���L�L�%�%��	��x�x�rFc��|jjd�ry|jdddk(r|jdddk(ry	|jjd
�ryy)
Ns�r�r�sBZhr��
s1AY&SYr�)s]�s�7zXZr�r�)rk�
startswithr�s rDr�z_StreamProxy.getcomptypeMsV���8�8����/��
�X�X�a��]�f�
$����!�B��9�)D��
�X�X�
 �
 �!C�
D��rFc�8�|jj�yr�)r�r�r�s rDr�z_StreamProxy.closeWs�������rFN)r�r�r�r�r�rtr�r�r�rFrDr�r�@s���0���rFr�c�h�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	e
jfd	�Zd
d
�Z
d�Zd�Zy)�_FileInFilezA thin wrapper around an existing file object that
       provides a part of its data as an individual file
       object.
    Nc���||_||_||_d|_||_d|_|�d|fg}d|_g|_d}|j}|D]U\}}||kDr|jjd||df�|jjd|||z|f�||z
}||z}�W||jkr*|jjd||jdf�yy)NrFT)	r��offsetr1�positionr�r��	map_index�mapr)r�r�rr1r��	blockinfo�lastpos�realposs        rDr�z_FileInFile.__init__ds�����������	���
���	�������T���I����������+�+��%�L�F�D������������� >�?��H�H�O�O�T�6�6�D�=�'�B�C��t�O�G��t�m�G�&��T�Y�Y���H�H�O�O�U�G�T�Y�Y��=�>�rFc��yr�r�r�s rDr�z_FileInFile.flush}s��rFc��y�NTr�r�s rD�readablez_FileInFile.readable�s��rFc��y�NFr�r�s rD�writablez_FileInFile.writable�s��rFc�6�|jj�Sr�)r��seekabler�s rDr%z_FileInFile.seekable�s���|�|�$�$�&�&rFc��|jS)z*Return the current file position.
        )rr�s rDr�z_FileInFile.tell�����}�}�rFc�.�|tjk(r1tt|d�|j�|_|j
S|tjk(rc|dkr*t|j
|zd�|_|j
St|j
|z|j�|_|j
S|tjk(r>tt|j|z|j�d�|_|j
Std��)z(Seek to a position in the file.
        rzInvalid argument)	�io�SEEK_SET�min�maxr1r�SEEK_CUR�SEEK_ENDr<)r�r�whences   rDr�z_FileInFile.seek�s����R�[�[� ���H�a� 0�$�)�)�<�D�M��}�}���r�{�{�
"��!�|� #�D�M�M�H�$<�a� @��
��}�}��!$�D�M�M�H�$<�d�i�i� H��
�
�}�}��	�r�{�{�
"���D�I�I��$8�$�)�)� D�a�H�D�M��}�}���/�0�0rFc���|�|j|jz
}n#t||j|jz
�}d}|dkD�r$	|j|j\}}}}||jcxkr|krnnn?|xjdz
c_|jt|j�k(rd|_�vt|||jz
�}|re|jj||j|z
z�|jj|�}t|�|k7rtd��||z
}n|t|zz
}||z}|xj|z
c_|dkDr��$|S)z!Read data from the file.
        rFrr-rp)r1rr+rrr>r�r�rtrr?)	r�r1rk�data�start�stoprrAr|s	         rDrtz_FileInFile.read�sD���<��9�9�t�}�}�,�D��t�T�Y�Y����6�7�D����Q�h��,0�H�H�T�^�^�,D�)��e�T�6��D�M�M�0�D�0���N�N�a�'�N��~�~��T�X�X��6�)*������t�d�m�m�3�4�F�����!�!�&�D�M�M�E�,A�"B�C��L�L�%�%�f�-���q�6�V�#�#�$<�=�=��q����s�V�|�#���F�N�D��M�M�V�#�M�'�Q�h�(�
rFc�h�|jt|��}||dt|�t|�Sr�)rtr>)r�r|rks   rD�readintoz_FileInFile.readinto�s,���i�i��A������)�3�s�8���3�x�rFc��d|_yr)r�r�s rDr�z_FileInFile.close�s	����rFr�)r�r�r�r�r�r�r r#r%r�r)r*r�rtr5r�r�rFrDrr^sB���
?�2
���'��
%'�K�K�� �>�
rFrc���eZdZ�fd�Z�xZS)�ExFileObjectc���t|j|j|j|j|j
�}t�|�|�yr�)rr��offset_datar1r��sparse�superr�)r��tarfile�tarinfor��	__class__s    �rDr�zExFileObject.__init__�s;����g�o�o�w�/B�/B����g�l�l�G�N�N�<��
����!rF�r�r�r�r��
__classcell__�r?s@rDr8r8�s
���"�"rFr8c��eZdZy)rN)r�r�r�r�rFrDrr�s��rFrc���eZdZ�fd�Z�xZS)rc�N��||_t�|�	d|j�d��y)Nzmember z has an absolute path�r>r<r�r��r�r>r?s  �rDr�zAbsolutePathError.__init__�s&������
���7�7�<�<�"2�2G�H�IrFr@rBs@rDrr�s���J�JrFrc���eZdZ�fd�Z�xZS)rc�f��||_||_t�|�
|j�d|�d�dz�y)Nz would be extracted to �, � which is outside the destination�r>�_pathr<r�r��r�r>r/r?s   �rDr�z OutsideDestinationError.__init__�s;��������
�
���G�L�L�+�+B�4�(�"�M�=�>�	?rFr@rBs@rDrr��
���?�?rFrc���eZdZ�fd�Z�xZS)rc�L��||_t�|�	|j�d��y)Nz is a special filerFrGs  �rDr�zSpecialFileError.__init__�s$������
���G�L�L�+�+=�>�?rFr@rBs@rDrr�s���@�@rFrc���eZdZ�fd�Z�xZS)rc�L��||_t�|�	|j�d��y)Nz is a link to an absolute pathrFrGs  �rDr�zAbsoluteLinkError.__init__�s$������
���G�L�L�+�+I�J�KrFr@rBs@rDrr�s���L�LrFrc���eZdZ�fd�Z�xZS)rc�f��||_||_t�|�
|j�d|�d�dz�y)Nz would link to rJrKrLrNs   �rDr�z$LinkOutsideDestinationError.__init__�s:��������
�
���G�L�L�+�?�4�(�"�E�=�>�	?rFr@rBs@rDrr�rOrFrc��i}|j}tjj|�}|j	dtj
f�r1|jj
dtj
z�x}|d<tjj|�rt|��tjjtjj||��}tjj||g�|k7rt||��|j}|�y|dz}|r^|j�s|j�r|dzs|dz}|dz}n.|j�s|j!�rd}nt#|��||jk7r||d<|�rk|j$�d|d<|j&�d|d	<|j(�d|d
<|j*�d|d<|j�s|j!��rtjj|j,�rt/|��|j!�rItjj|tjj1|�|j,�}n*tjj||j,�}tjj|�}tjj||g�|k7rt3||��|S)N�/r�i��@i�����r�r3r4r5r6)r�r�r/�realpathr�sep�lstrip�isabsrr�
commonpathrr��isreg�islnk�isdir�issymrr3r4r5r6�linknamer�dirnamer)�member�	dest_path�for_data�	new_attrsr��target_pathr�s       rD�_get_filtered_attrsrj�s^���I��;�;�D���� � ��+�I�����R�V�V�}�%�#)�;�;�#5�#5�c�B�F�F�l�#C�C��y�� �	�w�w�}�}�T�� ��'�'��'�'�"�"�2�7�7�<�<�	�4�#@�A�K�	�w�w���;�	�2�3�y�@�%�f�k�:�:��;�;�D����e�|����|�|�~������e�|��F�N�D���
������6�<�<�>���'�v�.�.��6�;�;�� $�I�f����:�:�!�#�I�e���:�:�!�#�I�e���<�<�#�!%�I�g���<�<�#�!%�I�g���<�<�>�V�\�\�^��w�w�}�}�V�_�_�-�'��/�/��|�|�~� �g�g�l�l�9�+-�7�7�?�?�4�+@�+1�?�?�<��!�g�g�l�l�9�+1�?�?�<���'�'�*�*�;�7�K��w�w�!�!�;�	�":�;�y�H�1�&�+�F�F��rFc��|Sr�r�)rerfs  rDrr2s���MrFc�P�t||d�}|r|jdi|�ddi��S|S)NF�deepr��rjr��rerfrhs   rDrr5s1��#�F�I�u�=�I���v�~�~�6�	�6��6�6��MrFc�P�t||d�}|r|jdi|�ddi��S|S)NTrmFr�rnros   rDrr;s1��#�F�I�t�<�I���v�~�~�6�	�6��6�6��MrF)�
fully_trustedr�r1s([0-9]{1,20}) c�B�eZdZdZedTidd�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%��ZdUd(�Zed)��Zejd*��Zed+��Z
e
jd,��Z
d-�Zeeeeeeeed.ed/�
d0�Z
d1�Zeed2fd3�Zd4�Zd5�Zd6�Zed7��Zd8�Zed9��Zed:��Zed;��Zed<��Zed=��Zed>��Zd?�Zd@�Z dA�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�Z0dQ�Z1dR�Z2dS�Z3y%)VraInformational class which holds the details about an
       archive member given by a tar header block.
       TarInfo objects are returned by TarFile.getmember(),
       TarFile.getmembers() and TarFile.gettarinfo() and are
       usually created internally.
    r�zName of the archive member.r�zPermission bits.r3z6User ID of the user who originally stored this member.r4z7Group ID of the user who originally stored this member.r1zSize in bytes.r2zTime of last modification.�chksumzHeader checksum.�typez�File type. type is usually one of these constants: REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.rczcName of the target file name, which is only present in TarInfo objects of type LNKTYPE and SYMTYPE.r5z
User name.r6zGroup name.�devmajorzDevice major number.�devminorzDevice minor number.rzThe tar header starts here.r:zThe file's data starts here.�pax_headerszMA dictionary containing key-value pairs of an associated pax extended header.r;zSparse member information.r=N�_sparse_structs�_link_targetc��||_d|_d|_d|_d|_d|_d|_t|_d|_	d|_
d|_d|_d|_
d|_d|_d|_i|_y)zXConstruct a TarInfo object. name is the optional name
           of the member.
        i�rr�N)r�r�r3r4r1r2rs�REGTYPErtrcr5r6rurvrr:r;rw�r�r�s  rDr�zTarInfo.__init__ts}����	���	���������	���
������	���
���
���
���
���
������������rFc��|jS)z(In pax headers, "name" is called "path".�r�r�s rDr/zTarInfo.path�s���y�y�rFc��||_yr�r~r|s  rDr/zTarInfo.path�s	����	rFc��|jS)z0In pax headers, "linkname" is called "linkpath".�rcr�s rDr0zTarInfo.linkpath�r'rFc��||_yr�r�)r�rcs  rDr0zTarInfo.linkpath�s	�� ��
rFc�`�d|jj|jt|�fzS)Nz<%s %r at %#x>)r?r�r��idr�s rD�__repr__zTarInfo.__repr__�s&���4�>�>�#:�#:�4�9�9�R��X�"N�N�NrFT)
r�r2r�rcr3r4r5r6rm�_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�r2r�rcr3r4r5r6)r�r�r2r�rcr3r4r5r6rmr��results            rDr�zTarInfo.replace�s�����]�]�4�(�F��Y�Y�t�_�F��u���F�K���� �F�L��u���F�K��5� �&�F�O��e���F�J��e���F�J���� �F�L���� �F�L��
rFc��|j�d}n|jdz}|j||j|j|j|j
|j|j|j|j|j|j|jd�
}|dtk(r!|djd�s
|dxxdz
cc<|S)z9Return the TarInfo's attributes as a dictionary.
        N�)
r�r�r3r4r1r2rsrtrcr5r6rurvrtr�rW)r�r�r3r4r1r2rsrtrcr5r6rurv�DIRTYPEr�)r�r��infos   rD�get_infozTarInfo.get_info�s����9�9���D��9�9�v�%�D��	�	���������	�	��
�
�����	�	��
�
��
�
��
�
��
�
��
�
�
�� ��<�7�"�4��<�+@�+@��+E���L�C��L��rF�surrogateescapec�.�|j�}|j�D]\}}|��	td|z��|tk(r|j	|||�S|t
k(r|j
|||�S|tk(r|j||�Std��)z<Return a tar header as a string of 512 byte blocks.
        z%s may not be Nonezinvalid format)	r��itemsr<r�create_ustar_headerr�create_gnu_headerr�create_pax_header)r�rbrBrCr�r��values       rD�tobufz
TarInfo.tobuf�s����}�}����:�:�<�K�D�%��}� �!5��!<�=�=�(��\�!��+�+�D�(�F�C�C�
�z�
!��)�)�$��&�A�A�
�z�
!��)�)�$��9�9��-�.�.rFc�,�t|d<t|dj||��tkDrt	d��t|dj||��t
kDr|j
|d||�\|d<|d<|j|t||�S)z3Return the object as a ustar header block.
        �magicrczlinkname is too longr��prefix)	�POSIX_MAGICr>r=�LENGTH_LINKr<�LENGTH_NAME�_posix_split_name�_create_headerr)r�r�rBrCs    rDr�zTarInfo.create_ustar_header�s���$��W�
��t�J��&�&�x��8�9�K�G��3�4�4��t�F�|�"�"�8�V�4�5��C�+/�+A�+A�$�v�,�PX�Z`�+a�(�D��N�D��L��"�"�4��x��H�HrFc�Z�t|d<d}t|dj||��tkDr||j	|dt
||�z
}t|dj||��tkDr||j	|dt||�z
}||j|t||�zS)z:Return the object as a GNU header block sequence.
        r�rFrcr�)
�	GNU_MAGICr>r=r��_create_gnu_long_header�GNUTYPE_LONGLINKr��GNUTYPE_LONGNAMEr�r)r�r�rBrCrks     rDr�zTarInfo.create_gnu_header�s���"��W�
����t�J��&�&�x��8�9�K�G��4�/�/��Z�0@�BR�T\�^d�e�e�C��t�F�|�"�"�8�V�4�5��C��4�/�/��V��>N�PX�Z`�a�a�C��T�(�(��z�8�V�L�L�LrFc�\�t|d<|jj�}ddtfddtfddfD];\}}}||vr�	||jdd	�t||�|kDs�4||||<�=d
D]e\}}d}||}	t|	t�}
|
rt|	�n|	}d|cxkrd
|dz
zks
nd||<d}n	|
r|||<d}|s�S||vs�Xt|	�||<�g|r|j|t|�}nd}||j|tdd�zS#t$r||||<Y��wxYw)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/rcr0)r5r5� )r6r6r�rRrS))r3rP)r4rP)r1�)r2r�FrrPr-TrFr�)r�rwr�r�r�r=�UnicodeEncodeErrorr>�
isinstance�float�round�str�_create_pax_generic_header�XHDTYPEr�r)
r�r�rBrwr��hnamerAra�	needs_pax�val�val_is_float�val_intrks
             rDr�zTarInfo.create_pax_headers~��
$��W�
��&�&�+�+�-��
���-�
�J��/T�&�(>�$@��D�%����#��
��T�
�!�!�'�8�4�
�4��:���'�%)�$�Z��E�"�!$@�(R�L�D�&��I��t�*�C�%�c�5�1�L�$0�e�C�j�c�G���3�!���
�"3�3���T�
� �	��%��T�
� �	��T��4�$'��H��D�!�%R�*��1�1�+�w��Q�C��C��T�(�(��|�W�i�P�P�P��G&�
�%)�$�Z��E�"��
�s�D�D+�*D+c�0�|j|td�S)zAReturn the object as a pax global header block sequence.
        r:)r��XGLTYPE)�clsrws  rD�create_pax_global_headerz TarInfo.create_pax_global_header?s���-�-�k�7�G�L�LrFc�R�|jd�}tdt|��D]t}dj|d|�}dj||d�}t|j	||��t
ks�Nt|j	||��tks�q||fStd��)zUSplit a name longer than 100 chars into a prefix
           and a name part.
        rWr-Nzname is too long)�splitrVr>rr=�
LENGTH_PREFIXr�r<)r�r�rBrC�
componentsr[r�s       rDr�zTarInfo._posix_split_nameEs����Z�Z��_�
��q�#�j�/�*�A��X�X�j��!�n�-�F��8�8�J�q�r�N�+�D��6�=�=��6�2�3�}�D�����H�f�5�6�+�E���t�|��+��/�0�0rFc�h�|jd�ttfv}|r;t|jdd�d|�}t|jdd�d|�}nt	dd||�}t	dd||�}|jdt
�}|�t
d��t	|jd	d�d
||�t|jdd�dzd|�t|jd
d�d|�t|jdd�d|�t|jdd�d|�t|jdd�d|�d|t	|jdd�d
||�|jdt�t	|jdd�d||�t	|jdd�d||�||t	|jdd�d||�g}tjdtzdj|��}	t|	td�d}
|	ddtd|
zd�z|	ddz}	|	S) z�Return a header block. info is a dictionary with file
           information, format must be one of the *_FORMAT constants.
        rtrurrPrvr�NzTarInfo.type must not be Noner�rr�r�r3r4r1r�r2s        rcr�r5r�r6r�rz%dsrFi����z%06orRi����)�get�CHRTYPE�BLKTYPErdrEr{r<r�rir�rrrnr^)r�rbrBrC�has_device_fieldsrurv�filetype�partsrkrss           rDr�zTarInfo._create_headerUs��
!�H�H�V�,��'�0B�B����4�8�8�J��2�A�v�>�H��4�8�8�J��2�A�v�>�H��2�q�(�F�3�H��2�q�(�F�3�H��8�8�F�G�,�����<�=�=�
������$�c�8�V�<�������#�f�,�a��8�������"�A�v�.�������"�A�v�.�������#�R��0������!�$�b�&�1��������R�(�#�x��@��H�H�W�k�*������"�%�r�8�V�<������"�%�r�8�V�<��������2�&��X�v�>�
��$�k�k�%�)�+�S�X�X�e�_�=���c�9�*�+�.�/��2���%�4�j�5��F�!2�G�<�<�s�4�5�z�I���
rFc�n�tt|�t�\}}|dkDr|t|z
tzz
}|S)zdReturn the string payload filled with zero bytes
           up to the next 512 byte border.
        r)rsr>rr?)�payloadrzr{s   rD�_create_payloadzTarInfo._create_payloads9��
#�3�w�<��;���	��q�=��	�I�-��4�4�G��rFc���|j||�tz}i}d|d<||d<t|�|d<t|d<|j	|t
||�|j
|�zS)zTReturn a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
           for name.
        z
././@LongLinkr�rtr1r�)r=r?r>r�r�rr�)r�r�rtrBrCr�s      rDr�zTarInfo._create_gnu_long_header�st��
�{�{�8�V�,�s�2����&��V����V���4�y��V��!��W�
��!�!�$��h��G��#�#�D�)�*�	*rFc��d}|j�D]\}}	|jdd��d}|r|dz
}|j�D]�\}}|jd�}|r|j|d�}n|jd�}t|�t|�zdz}d	x}	}
	|tt	|
��z}	|	|
k(rn|	}
� |tt	|
�d
�dz|zdz|zd
zz
}��i}d|d<||d<t|�|d<t|d<|j|td
d�|j|�zS#t$rd}Y��wxYw)z�Return a POSIX.1-2008 extended or global header sequence
           that contains a list of keyword, value pairs. The values
           must be strings.
        Fr:rSTrFs21 hdrcharset=BINARY
r�rrrR� �=�
z././@PaxHeaderr�rtr1r�r�)
r�r=r�r>r�r^r�r�rr�)r�rwrtrB�binary�keywordr��records�lrZrKr�s            rDr�z"TarInfo._create_pax_generic_header�s�����)�/�/�1�N�G�U�
����W�h�/�2�����0�0�G�)�/�/�1�N�G�U��n�n�W�-�G�����X�/@�A�����W�-���G��s�5�z�)�A�-�A��I�A�����C��F��O����6����	�

�u�S��V�W�-��4�w�>��E��M�PU�U�U�G�!2�(��'��V����V���7�|��V��#��W�
��!�!�$��g�y�I��#�#�G�,�-�	-��I&�
����
�s�D9�9E	�E	c�l�t|�dk(rtd��t|�tk7rtd��|j	t
�tk(rt
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||�}|j$t0k(r&|jj3d�rt4|_|j$t6k(rxd}g}t9d�D]@}		t|||dz�}
t||dz|dz�}|j=|
|f�|dz
}�Bt?|d�}t|dd�}
|||
f|_ |jC�r |jjEd�|_|r)|j$tFvr|dz|jz|_|S#t:$rY��wxYw)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�rWi�r�r��i�i�i�)$r>r�rr��countr?r�r\rnrYrLr�r�r3r4r1r2rsrtrcr5r6rurv�AREGTYPEr�r��GNUTYPE_SPARSErVr<r�boolrxra�rstrip�	GNU_TYPES)r�rkrBrCrs�objr�r��structsr[r�numbytes�
isextended�origsizes              rD�frombufzTarInfo.frombuf�s����s�8�q�=�"�>�2�2��s�8�y� �&�'9�:�:��9�9�S�>�Y�&� �!5�6�6��S��S�\�"����c�*�*�$�^�4�4��e���s�1�S�z�8�V�4����s�3�s�|�$����c�#�c�l�#����c�#�c�l�#����s�3�s�|�$�����C���%��	���
��s�3�<����3�s�3�<��6�:�����C���h��7��	���C���h��7��	��3�s�3�<�(����3�s�3�<�(����S��S�\�8�V�4���8�8�x��C�H�H�$5�$5�c�$:��C�H�
�8�8�~�%��C��G��1�X��� ��S��r��!2�3�F�"�3�s�R�x��b��#9�:�H������1�2��r�	����c�#�h��J��3�s�3�<�(�H�#*�J��"A�C���9�9�;��x�x���s�+�C�H��c�h�h�i�/���|�c�h�h�.�C�H��
��"����s�$%J&�&	J3�2J3c��|jjt�}|j||j|j
�}|jj
�tz
|_|j|�S)zOReturn the next TarInfo object from TarFile object
           tarfile.
        )	r�rtrr�rBrCr�r�_proc_member)r�r=rkr�s    rD�fromtarfilezTarInfo.fromtarfiles^��
�o�o�"�"�9�-���k�k�#�w�/�/����@���_�_�)�)�+�i�7��
�����(�(rFc��|jttfvr|j|�S|jtk(r|j|�S|jtttfvr|j|�S|j|�S)zYChoose the right processing method depending on
           the type and call it.
        )rtr�r��
_proc_gnulongr��_proc_sparser�r��SOLARIS_XHDTYPE�	_proc_pax�
_proc_builtin)r�r=s  rDr�zTarInfo._proc_member!sx���9�9�)�+;�<�<��%�%�g�.�.�
�Y�Y�.�
(��$�$�W�-�-�
�Y�Y�7�G�_�=�
=��>�>�'�*�*��%�%�g�.�.rFc��|jj�|_|j}|j�s|jt
vr||j
|j�z
}||_|j|j|j|j�|j�r |jjd�|_|S)zfProcess a builtin type or an unknown type which
           will be treated as a regular file.
        rW)r�r�r:r_rt�SUPPORTED_TYPES�_blockr1r�_apply_pax_inforwrBrCrar�r�)r�r=rs   rDr�zTarInfo._proc_builtin.s���#�?�?�/�/�1����!�!���:�:�<�4�9�9�O�;��d�k�k�$�)�)�,�,�F����	
���W�0�0�'�2B�2B�G�N�N�S��:�:�<��	�	�(�(��-�D�I��rFc�F�|jj|j|j��}	|j	|�}|j|_|jtk(r't||j|j�|_n9|jtk(r&t||j|j�|_|j#�r |jj%d�|_|S#t
$r}t
t|��d�d}~wwxYw)zSProcess the blocks that hold a GNU longname
           or longlink member.
        NrW)r�rtr�r1r�rr�r�rrtr�rLrBrCr�r�rcra�removesuffix)r�r=rk�nextrs     rDr�zTarInfo._proc_gnulongDs����o�o�"�"�4�;�;�t�y�y�#9�:��	:��#�#�G�,�D��k�k����9�9�(�(��C��!1�!1�7�>�>�B�D�I�
�Y�Y�*�
*���W�%5�%5�w�~�~�F�D�M��:�:�<��	�	�.�.�s�3�D�I����!�	:�'��A��/�T�9��	:�s�C=�=	D �D�D c�
�|j\}}}|`|r�|jjt�}d}t	d�D]D}	t|||dz�}t||dz|dz�}	|r|	r|j||	f�|dz
}�Ft|d�}|r��||_	|jj�|_|j|j|j�z|_||_
|S#t$rY�ywxYw)z8Process a GNU sparse header plus extra headers.
        r�r�r�i�)rxr�rtrrVr\r<rr�r;r�r:r�r1r)
r�r=r�r�r�rkr�r[rr�s
          rDr�zTarInfo._proc_sparse_s
��)-�(<�(<�%���X�� ���/�/�&�&�y�1�C��C��2�Y��� ��S��r��!2�3�F�"�3�s�R�x��b��#9�:�H��h��N�N�F�H�#5�6��r�	����c�#�h��J�����"�?�?�/�/�1����)�)�D�K�K��	�	�,B�B�����	����"����s�%C5�5	D�Dc��|jj|j|j��}|jt
k(r
|j}n|jj�}d}d}g}t|�|kD�r||dk7�rtj||�x}std��	t|jd��}|dkrtd��||zt|�kDrtd��|jd�|zdz
}	||j!d�dz|	}
|
j#d�\}}}
|r
|dk7s||	dk7rtd��|j%|||
f�|dk(r|�|
d	k(r
|j&}nd
}||z
}t|�|kDr
||dk7r��|�d
}|D]x\}}}
|j)|d
d
|j*�}|t,vr)|j)|
||j&|j*�}n|j)|
d
d
|j*�}|||<�z	|j/|�}d|vr|j7||�nRd|vr|j9||�n;|j;d
�dk(r'|j;d�dk(r|j=|||�|jt>t@fvr�|jC||j&|j*�|jD|_"d|vrS|jF}|jI�s|jtJvr||j|j�z
}||_"|S#t$rtd��wxYw#t0$r}t3t5|��d�d}~wwxYw)zVProcess an extended or global header as described in
           POSIX.1-2008.
        rNrUr-�r�rs
hdrcharsetsBINARYr:�GNU.sparse.map�GNU.sparse.sizezGNU.sparse.major�1zGNU.sparse.minorrTr1)&r�rtr�r1rtr�rwr�r>�_header_length_prefix_re�matchrYrW�groupr<r2r��	partitionrrB�_decode_pax_fieldrC�PAX_NAME_FIELDSr�rr�r��_proc_gnusparse_01�_proc_gnusparse_00r��_proc_gnusparse_10r�r�r�rr:r_r�)r�r=rkrwr�rB�raw_headersr�rA�header_value_end_offset�keyword_and_value�raw_keyword�equals�	raw_valuer�r�r�rrs                   rDr�zTarInfo._proc_pax{s���
�o�o�"�"�4�;�;�t�y�y�#9�:��
�9�9���!�-�-�K�!�-�-�2�2�4�K��������#�h��n��S��T�!1�5�;�;�C��E�E�E�E�(�)9�:�:�
;��U�[�[��^�,��
��z�(�)9�:�:��V�|�c�#�h�&�(�)9�:�:�&+�k�k�!�n�v�&=��&A�#� #�E�I�I�a�L�1�$4�5L� M��->�-H�-H��-N�*�K����&�D�.�C�8O�4P�TX�4X�(�)9�:�:������Y�?�@��m�+��0@��	�)�&�/�/�H�&�H��6�M�C�M�#�h��n��S��T�!1�R���H�/:�*�F�K���,�,�[�'�7��N�N�$�G��/�)��.�.�y�(�G�DT�DT����(���.�.�y�'�7����(��$)�K�� �#/:�(	:��#�#�G�,�D�
�{�*��#�#�D�+�6�
�+�
-��#�#�D�+�6�
�_�_�/�
0�C�
7�K�O�O�L^�<_�cf�<f��#�#�D�+�w�?��9�9��/�2�2�� � ��g�.>�.>����O��+�+�D�K���$��)�)���:�:�<�4�9�9�O�#C��d�k�k�$�)�)�4�4�F�!'������y�
;�(�)9�:�:�
;��|�	:�'��A��/�T�9��	:�s$�1M�"M�M�	N�&M;�;Nc�r�g}g}|D]d\}}}|dk(r*	|jt|j����6|dk(s�<	|jt|j����ftt
||��|_y#t$rt	d��wxYw#t$rt	d��wxYw)z?Process a GNU tar extended sparse header, version 0.0.
        sGNU.sparse.offsetrUsGNU.sparse.numbytesN)rrWrJr<rY�list�zipr;)r�r�r�offsetsr��_r�r�s        rDrzTarInfo._proc_gnusparse_00�s�������!,��A�w���.�.�?��N�N�3�u�|�|�~�#6�7��2�2�?��O�O�C�����$7�8�"-��3�w��1�2����"�?�,�-=�>�>�?��"�?�,�-=�>�>�?�s�(B	�(B!�	B�!B6c	��|djd�D�cgc]
}t|���}}tt|ddd�|ddd���|_ycc}w)z?Process a GNU tar extended sparse header, version 0.1.
        r��,Nr.r-)r�rWrrr;)r�r�rw�xr;s     rDrzTarInfo._proc_gnusparse_01sZ��#.�.>�"?�"E�"E�c�"J�K�"J�Q�#�a�&�"J��K��3�v�c��c�{�F�1�4�a�4�L�9�:����Ls�Ac	��d}g}|jjt�}|jdd�\}}t	|�}t|�|dzkrgd|vr"||jjt�z
}|jdd�\}}|j
t	|��t|�|dzkr�g|jj�|_tt|ddd�|ddd���|_y)z?Process a GNU tar extended sparse header, version 1.0.
        Nr�r-r.)r�rtrr�rWr>rr�r:rrr;)r�r�rwr=�fieldsr;rk�numbers        rDrzTarInfo._proc_gnusparse_10s��������o�o�"�"�9�-���i�i��q�)�����V����&�k�F�Q�J�&��C���w���+�+�I�6�6���)�)�E�1�-�K�F�C��M�M�#�f�+�&�	�&�k�F�Q�J�&�
#�?�?�/�/�1����3�v�c��c�{�F�1�4�a�4�L�9�:��rFc��|j�D]�\}}|dk(rt|d|��|dk(rt|dt|���5|dk(rt|dt|���Q|tvs�Z|tvr	t	||�}|dk(r|j
d�}t|||���|j�|_y#t
$rd}Y�HwxYw)	zoReplace fields with supplemental information from a previous
           pax extended or global header.
        zGNU.sparse.namer/r�r1zGNU.sparse.realsizerrWN)	r��setattrrW�
PAX_FIELDS�PAX_NUMBER_FIELDSr<r�r�rw)r�rwrBrCr�r�s      rDr�zTarInfo._apply_pax_infos���*�/�/�1�N�G�U��+�+���f�e�,��-�-���f�c�%�j�1��1�1���f�c�%�j�1��J�&��/�/�"� 1�'� :�5� A���f�$�!�L�L��-�E���g�u�-�2�"'�+�+�-����
&�"� !��"�s�4B=�=C�
Cc�j�	|j|d�S#t$r|j||�cYSwxYw)z1Decode a single field from a pax record.
        rS)rJ�UnicodeDecodeError)r�r�rB�fallback_encoding�fallback_errorss     rDr�zTarInfo._decode_pax_field5s<��	D��<�<��(�3�3��!�	D��<�<� 1�?�C�C�	D�s��2�2c�H�t|t�\}}|r|dz
}|tzS)z_Round up a byte count by BLOCKSIZE and return it,
           e.g. _block(834) => 1024.
        r-)rsr)r�r�rzr{s    rDr�zTarInfo._block=s,��#�5�)�4���	���a�K�F��	�!�!rFc�&�|jtvS�z4Return True if the Tarinfo object is a regular file.)rt�
REGULAR_TYPESr�s rDr_z
TarInfo.isregFs���y�y�M�)�)rFc�"�|j�Sr)r_r�s rD�isfilezTarInfo.isfileJs���z�z�|�rFc�(�|jtk(S)z!Return True if it is a directory.)rtr�r�s rDraz
TarInfo.isdirN����y�y�G�#�#rFc�(�|jtk(S)z%Return True if it is a symbolic link.)rt�SYMTYPEr�s rDrbz
TarInfo.issymRr$rFc�(�|jtk(S)z!Return True if it is a hard link.)rt�LNKTYPEr�s rDr`z
TarInfo.islnkVr$rFc�(�|jtk(S)z(Return True if it is a character device.)rtr�r�s rD�ischrz
TarInfo.ischrZr$rFc�(�|jtk(S)z$Return True if it is a block device.)rtr�r�s rD�isblkz
TarInfo.isblk^r$rFc�(�|jtk(S)zReturn True if it is a FIFO.)rt�FIFOTYPEr�s rD�isfifozTarInfo.isfifobs���y�y�H�$�$rFc��|jduSr�)r;r�s rD�issparsezTarInfo.issparsefs���{�{�$�&�&rFc�<�|jtttfvS)zCReturn True if it is one of character device, block device or FIFO.)rtr�r�r.r�s rD�isdevz
TarInfo.isdevis���y�y�W�g�x�8�8�8rFr�)r�)4r�r�r�r��dict�	__slots__r��propertyr/�setterr0r�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"rarbr`r*r,r/r1r3r�rFrDrrQs�����
�,�
�!�
�G�
�H�	
�
 �
�-�

�$�
�>�
�F�
��
��
�*�
� *�!
�"/�#
�$5�%
�&9�'
�*.�+
�,�-
�.�/
�0�1
�I�6�0����
�[�[���������_�_�!��!�O��%�e�e��u�E�����8�8*�H�EV�/�"I�M�8Q�t�M��M�
� �'��'�R�����*��*� �0-��0-�d�<��<�|�)��)�(/��,�6�8w�r3�(;�;� .�.D�"�*��$�$�$�$�$�%�'�9rFrc��eZdZdZdZdZdZdZeZ	e
ZdZe
ZeZdZ				d8d�Zedddefd��Zed9d	��Zed:d
��Zed:d��Zed;d��Zd
dddd�Zd�Zd�Zd�Zd�Zd<d�Zd=dd�d�Z d>dd�d�Z!d?d�Z"d�Z#d@ddd�d�Z$dAddd�d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*		dBd%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2d-�Z3d.�Z4d/�Z5dCd0�Z6d1�Z7d?d2�Z8d3�Z9d4�Z:d5�Z;d6�Z<d7�Z=y)Drz=The TarFile Class provides an interface to tar archives.
    rFr-Nr�c���ddddd�}||vrtd��||_|||_|sZ|jdk(r-tjj|�sd|_d|_t
||j�}d	|_n^|�8t|d�r,t|jttf�r|j}t|d�r|j|_d
|_|rtjj|�nd
|_
||_|�||_|�||_|�||_|�||_|�||_|	|_|
�|jt*k(r|
|_ni|_|�||_|�||_|
|_d	|_g|_d	|_|jj;�|_i|_	|jdk(rd
|_ |jC�|_ |jdk(r^	|jjE|j<�	|j jG|�}|j6jI|��]|jdvr�d
|_|j,rm|j jQ|j,jS��}|jjU|�|xj<tW|�z
c_y
y
y
#tJ$r(|jjE|j<�Y��tL$r}tOt|��d
�d
}~wwxYw#|js|jjY�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'r@r�FNr�r�Tr��r@r�r)-r<r��_moder�r/�exists�	bltn_openr�r�r�r�r�r^�abspathr�rbr>�dereference�ignore_zerosrBrCrrw�debug�
errorlevel�copybufsizer��members�_loadedr�r�inodes�firstmemberr�r�r�rr�rrr�r�rur>r�)r�r�r�r�rbr>rGrHrBrCrwrIrJrK�modesrrks                 rDr�zTarFile.__init__�s�����T��=���u���@�A�A���	��4�[��
���y�y�C�������t�(<���	�!��
���d�j�j�1�G�$�D������&�!9��7�<�<�#�u��6��|�|���w��'�$�\�\��
�#�D��-1�B�G�G�O�O�D�)�t��	������ �D�K���"�D�L��"�*�D���#� ,�D����$�D�M�����"�t�{�{�j�'@�*�D��!�D�����D�J��!�(�D�O�'�������������l�l�'�'�)������	��y�y�C��#'�� �#'�9�9�;�� ��y�y�C����L�L�%�%�d�k�k�2�:�"&�,�,�":�":�4�"@�����+�+�G�4�	��y�y�O�+�#����#�#��,�,�?�?��@P�@P�@U�@U�@W�X�C��L�L�&�&�s�+��K�K�3�s�8�+�K�$�,��
*�����)�)�$�+�+�6��&�:�'��A��/�T�9��:��	��#�#����"�"�$��D�K��s>�>A L;�6K&�BL;�&.L8�L;�L8�L3�3L8�8L;�;0M+c����|s
|std��|dvrz�fd�}g}t�j|��D]:}t��j|�}	|�|j	�}
	|	|d|fi|��cSd	j|�}td
|����d|vrb|jdd�\}
}|
xsd}
|xsd
}|�jvrt��j|�}	nt
d|z��|	||
|fi|��Sd|vrg|jdd�\}
}|
xsd}
|xsd
}|
dvrtd��|jdd�}t||
||||�}	�||
|fi|��}d|_|S|dvr�j|||fi|��Std��#t
tf$r5}|jd|�d|���|�|j
�Yd}~���d}~wwxYw#|j��xYw)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|dk(S)N�taropen)�	OPEN_METH)r�r�s �rD�not_compressedz$TarFile.open.<locals>.not_compressed#s����}�}�X�.�)�;�;rF)�keyNr�z	- method z: �
z'file could not be opened successfully:
�:r-r�r��|r�zmode must be 'r' or 'w'r��	FrBzundiscernible mode)r<�sortedrUr�r�rr	rr�rr��popr�r�r�rT)r�r�r�r�ry�kwargsrV�
error_msgsr��func�	saved_posr�error_msgs_summary�filemoder��streamrs`                rDrzTarFile.open�s5���J�G��.�/�/��<��
<��J�"�3�=�=�n�E���s�C�M�M�(�$;�<���&� '����I����c�7�=�f�=�=�F�"&���:�!6���F�GY�FZ�[�\�\�
�D�[�!%���C��!3��H�h���3�H��(�5�H��3�=�=�(��s�C�M�M�(�$;�<��&�'D�x�'O�P�P���h��:�6�:�:�
�D�[�!%���C��!3��H�h���3�H��(�5�H��z�)� �!:�;�;�"�J�J���:�M��T�8�X�w��*�,�F�
���h��9�&�9��"�A�M��H�
�_�
$��3�;�;�t�T�7�=�f�=�=��-�.�.��W"�#3�4���%�%�	�(��2�a�U�&C�D��*����Y�/���	��D
������s$�"
F�G�G�*G�G�Gc�6�|dvrtd��||||fi|��S)zCOpen uncompressed tar archive name for reading or writing.
        r?rA)r<)r�r�r�r�r^s     rDrTzTarFile.taropenYs-���+�+��@�A�A��4��w�1�&�1�1rFc��|dvrtd��	ddlm}	|||dz||�}	|j|||fi|��}d
|_	|S#t$r
t	d�d�wxYw#t
$r}|�|dk(rt
d	�|��d}~wwxYw#t
$r'}|j�|dk(rt
d	�|��d}~w|j��xYw)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 availableNr|r�r�F)
r<�gziprir�r	r�rrTr�r�)	r�r�r�r�r�r^rirrs	         rD�gzopenzTarFile.gzopenas���
��&��;�<�<�	M�%�	��t�T�C�Z���H�G�		�����D�$��:�6�:�A���
����+�	M�"�#A�B��L�	M��
�	��"�t�s�{�� 1�2��9���	���	��M�M�O��s�{�� 1�2��9���	��M�M�O��s9�A�A�B�A�	B�'A;�;B�	C�"B.�.Cc�P�|dvrtd��	ddlm}||xs|||��}	|j
|||fi|��}d
|_
|S#t$r
t	d�d�wxYw#ttf$r'}|j�|dk(rtd	�|��d}~w|j��xYw)zlOpen bzip2 compressed tar archive name for reading or writing.
           Appending is not allowed.
        rgrhr)�BZ2Filer�N)r�r�znot a bzip2 fileF)r<r�rmr�r	rTr��EOFErrorr�rr�)	r�r�r�r�r�r^rmrrs	         rD�bz2openzTarFile.bz2open�s���
��&��;�<�<�	L�#��'�/�T�4�}�M��		�����D�$��:�6�:�A���
����!�	L�"�#@�A�t�K�	L����"�	��M�M�O��s�{�� 2�3��:���	��M�M�O��s"�A�A�A�B%�-"B�B%c�L�|dvrtd��	ddlm}m}||xs|||��}	|j|||fi|��}d
|_
|S#t$r
td�d�wxYw#|tf$r'}	|j�|dk(rtd	�|	��d}	~	w|j��xYw)zkOpen lzma compressed tar archive name for reading or writing.
           Appending is not allowed.
        rgrhr)�LZMAFiler�r�N)�presetr�znot an lzma fileF)r<r�rqr�r�r	rTrnr�rr�)
r�r�r�r�rrr^rqr�rrs
          rD�xzopenzTarFile.xzopen�s���
��&��;�<�<�	M�0��7�?�d�D��@��		�����D�$��:�6�:�A���
����!�	M�"�#A�B��L�	M���8�$�	��M�M�O��s�{�� 2�3��:���	��M�M�O��s"�A�A �A� B#�+"B
�
B#rTrkrors)r�r�r�r�c��|jryd|_	|jdvr�|jjtt
dzz�|xjt
dzz
c_t|jt�\}}|dkDr)|jjtt|z
z�|js|jj�yy#|js|jj�wwxYw)zlClose the TarFile. In write-mode, two finishing zero blocks are
           appended to the archive.
        NTrBr.r)r�r�r�rur?rrrs�
RECORDSIZEr�r�)r�rzr{s   rDr�z
TarFile.close�s����;�;�����	%��y�y�O�+����"�"�3�)�a�-�#8�9����	�A�
�.��%+�4�;�;�
�$C�!��	��q�=��L�L�&�&�s�j�9�.D�'E�F��#�#����"�"�$�$��4�#�#����"�"�$�$�s�BC�)Dc�f�|j|jd��}|�td|z��|S)aReturn a TarInfo object for member `name'. If `name' can not be
           found in the archive, KeyError is raised. If a member occurs more
           than once in the archive, its last occurrence is assumed to be the
           most up-to-date version.
        rWzfilename %r not found)�
_getmemberr��KeyError)r�r�r>s   rD�	getmemberzTarFile.getmember�s6���/�/�$�+�+�c�"2�3���?��2�T�9�:�:��rFc�r�|j�|js|j�|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.
        )�_checkrM�_loadrLr�s rD�
getmemberszTarFile.getmembers�s'��	
���
��|�|��J�J�L��|�|�rFc�\�|j�D�cgc]}|j��c}Scc}w)z�Return the members of the archive as a list of their names. It has
           the same order as the list returned by getmembers().
        )r}r�)r�r>s  rD�getnameszTarFile.getnames�s)��-1�O�O�,=�>�,=�����,=�>�>��>s�)c�.�|jd�|�|j}|�|}tjj	|�\}}|jtjd�}|jd�}|j�}||_	|�8|jstj|�}n9tj|�}n#tj|j��}d}|j}tj |�r�|j"|j$f}	|jsE|j&dkDr6|	|j(vr(||j(|	k7rt*}
|j(|	}n�t,}
|	dr�||j(|	<n�tj.|�rt0}
n�tj2|�rt4}
njtj6|�rt8}
tj:|�}n9tj<|�rt>}
ntj@|�rtB}
ny||_||_"|jF|_$|jJ|_&|
t,k(r|jN|_(nd|_(|jR|_*|
|_+||_,tZr(	t[j\|jH�d|_/tbr(	tcjd|jL�d|_3|
t>tBfvrhtitd�rXtitd�rHtjj|jl�|_7tjp|jl�|_9|S#t`$rY��wxYw#t`$rY��wxYw)	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.
        �awxNrWr�r-r�major�minor):r{r�r�r/�
splitdriver�r[r\r>r=rG�lstat�stat�fstat�fileno�st_mode�S_ISREG�st_ino�st_dev�st_nlinkrNr(r{�S_ISDIRr��S_ISFIFOr.�S_ISLNKr&�readlink�S_ISCHRr��S_ISBLKr�r��st_uidr3�st_gidr4�st_sizer1�st_mtimer2rtrc�pwd�getpwuidr5rx�grp�getgrgidr6r�r��st_rdevrur�rv)r�r��arcnamer��drvr>�statresrc�stmd�inoderts           rD�
gettarinfozTarFile.gettarinfo�s���	
���E�����<�<�D�
�?��G��w�w�)�)�'�2���W��/�/�"�&�&�#�.���.�.��%���,�,�.������?��#�#��(�(�4�.���'�'�$�-���h�h�w�~�~�/�0�G��������<�<����^�^�W�^�^�4�E��#�#��(8�(8�1�(<��T�[�[�(�W����E�8J�-J����;�;�u�-������8�)0�D�K�K��&�
�\�\�$�
��D�
�]�]�4�
 ��D�
�\�\�$�
��D��{�{�4�(�H�
�\�\�$�
��D�
�\�\�$�
��D���������n�n����n�n����7�?�"�?�?�G�L��G�L��(�(��
����#����
� #���W�[�[� 9�!� <��
��
� #���W�[�[� 9�!� <��
��G�W�%�%��r�7�#���G�(<�#%�8�8�G�O�O�#<�� �#%�8�8�G�O�O�#<�� �����
��
��
�
��
�s$�,'M9�'N�9	N�N�	N�N)rLc��|j�|�|}|D�]�}|�r&|j�td�n(ttj|j��t|j
xs|j�d|jxs|j���|j�s|j�r(tdd|j|jfzz�ntd|jz�|j�td�n.tdtj |j�dd	z�t|j"|j%�rdnd
z�|rP|j'�rtd|j(z�|j+�rtd|j(z�t-����y)
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
??????????rWz%10sz%d,%dz%10dz????-??-?? ??:??:??z%d-%02d-%02d %02d:%02d:%02dr�r�z-> zlink to )r{r�r�r�rcr5r3r6r4r*r,rurvr1r2r��	localtimer�rarbrcr`r�)r��verboserLr>s    rDrzTarFile.listXsf��	
���
��?��G��G���<�<�'���-���
�
�g�l�l� ;�<��w�}�}�'C����'C�'.�}�}�'C����'C�E�F��=�=�?�g�m�m�o���$��(8�(8�'�:J�:J�'K�K�!M�N� ����� 5�6��=�=�(�� 5�6�� =�"&�.�.����"?���"C�!D�E�
����w�}�}���B�G�H���=�=�?����(8�(8� 8�9��=�=�?��
�W�-=�-=� =�>��G�5rF��filterc�b�|jd�|�|}|j�Btjj	|�|jk(r|jdd|z�y|jd|�|j
||�}|�|jdd|z�y|� ||�}|�|jdd|z�y|j�r(t|d�5}|j||�ddd�y|j�r�|j|�|ruttj|��D]S}|jtjj||�tjj||�||�	��Uyy|j|�y#1swYyxYw)
a!Add the file `name' to the archive. `name' may be any type of file
           (directory, fifo, symbolic link, etc.). If given, `arcname'
           specifies an alternative name for the file in the archive.
           Directories are added recursively by default. This can be avoided by
           setting `recursive' to False. `filter' is a function
           that expects a TarInfo object argument and returns the changed
           TarInfo object, if it returns None the TarInfo object will be
           excluded from the archive.
        r�Nr.ztarfile: Skipped %rr-ztarfile: Unsupported type %r�tarfile: Excluded %rr<r�)r{r�r�r/rF�_dbgr�r_rE�addfilerar\�listdir�addr)r�r�r��	recursiver�r>�fs       rDr�zTarFile.add~sq��	
���E���?��G��9�9� �R�W�W�_�_�T�%:�d�i�i�%G��I�I�a�.��5�6���	�	�!�T���/�/�$��0���?��I�I�a�7�$�>�?�����W�o�G����	�	�!�3�d�:�;���=�=�?��4��&�!����W�a�(�'�&��]�]�_��L�L��!����
�
�4� 0�1�A��H�H�R�W�W�\�\�$��2�B�G�G�L�L��!�4L�%�f��6�2��
�L�L��!�'�&�s�F%�%F.c��|jd�tj|�}|j|j|j|j
�}|jj|�|xjt|�z
c_|j}|��t||j|j|��t|jt�\}}|dkDr.|jjtt|z
z�|dz
}|xj|tzz
c_|j j#|�y)aAdd the TarInfo object `tarinfo' to the archive. If `fileobj' is
           given, it should be a binary file, and tarinfo.size bytes are read
           from it and added to the archive. You can create TarInfo objects
           directly, or by using gettarinfo().
        r�N)ryrr-)r{r�r�rbrBrCr�rurr>rKrrr1rsrr?rLr)r�r>r�rkryrzr{s       rDr�zTarFile.addfile�s���	
���E���)�)�G�$���m�m�D�K�K�������D�������3�����s�3�x���� � ���������w�|�|�W�M� &�w�|�|�Y� ?��F�I��1�}����"�"�3�)�i�*?�#@�A��!����K�K�6�I�-�-�K������G�$rFc��|�M|j}|�"tjdtd��tSt|t�rtd��|St|�r|S	t|S#t$rtd|�d��d�wxYw)Nz�Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.r)�
stacklevelzrString names are not supported for TarFile.extraction_filter. Use a function such as tarfile.data_filter directly.zfilter z
 not found)�extraction_filter�warnings�warn�DeprecationWarningrr�r��	TypeError�callable�_NAMED_FILTERSrxr<)r�r�s  rD�_get_filter_functionzTarFile._get_filter_function�s����>��+�+�F��~��
�
�J�'�1�	6�
,�+��&�#�&��6�7�7��M��F���M�	G�!�&�)�)���	G��w�v�j�
�;�<�$�F�	G�s�A'�'B)�
numeric_ownerr�c�@�g}|j|�}|�|}|D]]}|j|||�}|��|j�r|j|�|j	|||j�|���_|jd�d��|D]e}tjj||j�}		|j||	|��|j||	�|j||	��gy#t$r}
|j|
�Yd}
~
��d}
~
wwxYw)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~)r@s rD�<lambda>z$TarFile.extractall.<locals>.<lambda>	s��q�v�vrFT)rW�reverse)r�)r��_get_extract_tarinforar�_extract_one�sortr�r/rr��chown�utime�chmodr�_handle_nonfatal_error)r�r/rLr�r��directories�filter_functionrer>�dirpathrs           rD�
extractallzTarFile.extractall�s�����3�3�F�;���?��G��F��/�/����N�G�����}�}���"�"�7�+����g�t�7�=�=�?�7J�,9�
�
;��	���-�t��<�#�G��g�g�l�l�4����6�G�
/��
�
�7�G�=�
�I��
�
�7�G�,��
�
�7�G�,�#�� �
/��+�+�A�.�.��
/�s�>8C9�9	D�D�Dc�z�|j|�}|j|||�}|�|j||||�yy)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�rer/r�r�r�r�r>s        rD�extractzTarFile.extract	sG���3�3�F�;���+�+�F�O�T�J�������g�t�Y�
�F�rFc���t|t�r|j|�}n|}|}	|||�}|� |jdd|jz�y|j�rDtj|�}tjj||j�|_|S#ttf$r}|j|�Yd}~��d}~wt$r}|j|�Yd}~��d}~wwxYw)z@Get filtered TarInfo (or None) from member, which might be a strNr.r�)r�r�ryr�r�_handle_fatal_errorrr�r�r�r`r�r�r/rrcry)r�rer�r/r>�
unfilteredrs       rDr�zTarFile._get_extract_tarinfo!	s����f�c�"��n�n�V�,�G��G��
�	+�%�g�t�4�G�
�?��I�I�a�/�*�/�/�A�B���=�=�?��i�i��(�G�#%�7�7�<�<��g�6F�6F�#G�G� ������%�	(��$�$�Q�'�'���	+��'�'��*�*��	+�s#�	B)�)C5�8C�C5�C0�0C5c�4�|jd�	|j|tjj	||j
�||��y#t$r}|j|�Yd}~yd}~wt$r}|j|�Yd}~yd}~wwxYw)z%Extract from filtered tarinfo to diskr�r�N)
r{�_extract_memberr�r/rr�r�r�rr�)r�r>r/r�r�rs      rDr�zTarFile._extract_one8	s������C��	+�� � ��"�'�'�,�,�t�W�\�\�*J�+4�/<�
!�
>���	(��$�$�Q�'�'���	+��'�'��*�*��	+�s#�=A�	B�A0�0B�<B�Bc�N�|jdkDr�|jdd|z�y)z=Handle non-fatal error (ExtractError) according to errorlevelr-�tarfile: %sN)rJr��r�rs  rDr�zTarFile._handle_nonfatal_errorE	s$���?�?�Q����I�I�a���*�+rFc�L�|jdkDr�t|t�rY|j� |j	dd|j
z�y|j	dd|j
�d|j���y|j	ddt
|�j�d|���y)z1Handle "fatal" error according to self.errorlevelrNr-r�z	tarfile: r)rJr�r��filenamer��strerrorrtr�r�s  rDr�zTarFile._handle_fatal_errorL	st���?�?�Q���
��7�
#��z�z�!��	�	�!�]�Q�Z�Z�7�8��	�	�!����Q�Z�Z�H�I��I�I�a�T�!�W�-=�-=�q�A�BrFc��|jd�t|t�r|j|�}n|}|j	�s|j
tvr|j||�S|j�s|j�rEt|jt�rtd��|j|j|��Sy)a\Extract a member from the archive as a file object. `member' may be
           a filename or a TarInfo object. If `member' is a regular file or
           a link, an io.BufferedReader object is returned. For all other
           existing members, None is returned. If `member' does not appear
           in the archive, KeyError is raised.
        r�z'cannot extract (sym)link as file objectN)r{r�r�ryr_rtr��
fileobjectr`rbr�r�r
�extractfile�_find_link_target)r�rer>s   rDr�zTarFile.extractfileX	s���	
���C���f�c�"��n�n�V�,�G��G��=�=�?�g�l�l�/�A��?�?�4��1�1�
�]�]�_��
�
���$�,�,��0�"�"K�L�L��'�'��(>�(>�w�(G�H�H�rFc��|jd�}|jdtj�}tjj|�}|r4tjj
|�stj|�|j�s|j�r,|jd|j�d|j���n|jd|j�|j�r|j||�n�|j�r|j!||�n�|j#�r|j%||�n�|j'�s|j)�r|j+||�nj|j�s|j�r|j-||�n7|j.t0vr|j3||�n|j||�|rI|j5|||�|j�s%|j7||�|j9||�yyy)z\Extract the TarInfo object tarinfo to a physical
           file called targetpath.
        rWr-z -> N)r�r�r�r[r/rdrD�makedirsr`rbr�r�rcr_�makefilera�makedirr/�makefifor*r,�makedev�makelinkrtr��makeunknownr�r�r�)r�r>�
targetpathr�r��	upperdirss      rDr�zTarFile._extract_memberx	s��� �&�&�s�+�
��'�'��R�V�V�4�
��G�G�O�O�J�/�	��R�W�W�^�^�I�6�
�K�K�	�"��=�=�?�g�m�m�o��I�I�a�w�|�|�W�5E�5E�F�G��I�I�a����&��=�=�?��M�M�'�:�.�
�]�]�_��L�L��*�-�
�^�^�
��M�M�'�:�.�
�]�]�_��
�
���L�L��*�-�
�]�]�_��
�
���M�M�'�:�.�
�\�\��
0����W�j�1��M�M�'�:�.���J�J�w�
�M�:��=�=�?��
�
�7�J�/��
�
�7�J�/�#�rFc���	|j�tj|�ytj|d�y#t$r#tjj|�s�YywxYw)z,Make a directory called targetpath.
        Ni�)r�r��mkdir�FileExistsErrorr/ra�r�r>r�s   rDr�zTarFile.makedir�	sT��
	��|�|�#�����$�����U�+���	��7�7�=�=��,��-�	�s�!;�;�)A'�&A'c	���|j}|j|j�|j}t	|d�5}|j
�d|j
D])\}}|j|�t
|||t|��+|j|j�|j�nt
|||jt|�ddd�y#1swYyxYw)z'Make a file called targetpath.
        r=N)
r�r�r:rKrEr;rrrr1�truncate)r�r>r��sourcery�targetrr1s        rDr�zTarFile.makefile�	s����������G�'�'�(��"�"��
�z�4�
(�F��~�~�)�$+�N�N�L�F�D��K�K��'�����i��I�%3����G�L�L�)����!��F�F�G�L�L�)�W�M�)�
(�
(�s
�BC�C c�f�|j||�|jdd|jz�y)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   rDr�zTarFile.makeunknown�	s3��	
�
�
�g�z�*��	�	�!�2�4;�L�L�A�	BrFc�d�ttd�rtj|�ytd��)z'Make a fifo called targetpath.
        �mkfifozfifo not supported by systemN)r�r�r�rr�s   rDr�zTarFile.makefifo�	s&���2�x� ��I�I�j�!��=�>�>rFc�f�ttd�rttd�std��|j}|�d}|j	�r|t
jz}n|t
jz}tj||tj|j|j��y)z<Make a character or block device called targetpath.
        �mknodr�z'special devices not supported by systemNrY)r�r�rr�r,r��S_IFBLK�S_IFCHRr�r�rurv)r�r>r�r�s    rDr�zTarFile.makedev�	s����r�7�#�7�2�y�+A��H�I�I��|�|���<��D��=�=�?��D�L�L� �D��D�L�L� �D�
����T����G�,�,�g�.>�.>�?�	ArFc�:�	|j�rUtjj|�rtj|�tj
|j|�ytjj|j�r!tj|j|�y|j|j|�|�y#t$r>	|j|j|�|�Yy#t$r
td�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)rbr�r/�lexists�unlink�symlinkrcrDry�linkr�r��symlink_exceptionrxrr�s   rDr�zTarFile.makelink�	s���
	V��}�}���7�7�?�?�:�.��I�I�j�)��
�
�7�+�+�Z�8��7�7�>�>�'�"6�"6�7��G�G�G�0�0�*�=��(�(��)?�)?��)H�)3�5�� �	V�
V��$�$�T�%;�%;�G�%D�%/�1���
V�"�#J�K�QU�U�
V��		V�s+�A$C�'A	C�1!C�	D�!D�D�Dc��ttd�r�tj�dk(r�|j}|j}|sj	t
r.|jr"tj|j�d}	tr.|jr"tj|j�d}|�d}|�d}	|j�r(ttd�rtj|||�ytj|||�yyy#t$rY��wxYw#t$rY�uwxYw#t$r}t!d�|�d}~wwxYw)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.NrH�lchownzcould not change owner)r�r�r�r4r3r�r6�getgrnamrxr�r5�getpwnamrbr�r�r�r)r�r>r�r��g�urs       rDr�z
TarFile.chown
s���2�y�!�b�j�j�l�a�&7����A����A� ���w�}�}��L�L����7��:����w�}�}��L�L����7��:���y����y���
D��=�=�?�w�r�8�'<��I�I�j�!�Q�/��H�H�Z��A�.�/'8�!�� �����
 ������
D�"�#;�<�!�C��
D�sB�4D�84D�57D%�-D%�	D�D�	D"�!D"�%	D?�.D:�:D?c��|j�y	tj||j�y#t$r}t	d�|�d}~wwxYw)zASet file permissions of targetpath according to tarinfo.
        Nzcould not change mode)r�r�r�r�r)r�r>r�rs    rDr�z
TarFile.chmod$
sF���<�<���	?��H�H�Z����.���	?��6�7�Q�>��	?�s� 0�	A
�A�A
c��|j}|�yttd�sy	tj|||f�y#t$r}td�|�d}~wwxYw)zBSet modification time of targetpath according to tarinfo.
        Nr�z"could not change modification time)r2r�r�r�r�r)r�r>r�r2rs     rDr�z
TarFile.utime.
sZ���
�
���=���r�7�#��	L��H�H�Z�%���0���	L��C�D�!�K��	L�s�;�	A�A�Ac�L�|jd�|j�|j}d|_|S|j|jj	�k7r^|jdk(ry|jj|jdz
�|jj
d�std��d}		|jj|�}	|�|j0j3|�|Sd|_|S#t$rU}|jr?|jdd|j|fz�|xjtz
c_Yd}~��Yd}~��d}~wt$rz}|jr?|jdd|j|fz�|xjtz
c_Yd}~��|jdk(rtt|��d�Yd}~��d}~wt $r|jdk(rtd	�d�Y��-t"$r/}|jdk(rtt|��d�Yd}~��_d}~wt$$r}tt|��d�d}~wt&$r@}	ddl}t+||j,�rtd
|���d�|�#t.$r|�wxYwd}~wwxYw)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-rpTr.z0x%X: %sz
empty filezzlib error: )r{rOrr�r�r�rtrr>r�r�rHr�rrYr�r�r�r��	Exceptionr�r�r�r�rLrrM)r��mr>rr�s     rDr�zTarFile.next<
sR��
	
���D�����'�� � �A�#�D���H��;�;�$�,�,�+�+�-�-��{�{�a����L�L���d�k�k�A�o�.��<�<�$�$�Q�'�� 8�9�9����
��,�,�2�2�4�8��<
����L�L����(��� �D�L����I"�
��$�$��I�I�a��t�{�{�A�.>�!>�?��K�K�9�,�K��%��&�
6��$�$��I�I�a��t�{�{�A�.>�!>�?��K�K�9�,�K���[�[�A�%�#�C��F�+��5�&��#�
<��;�;�!�#�#�L�1�t�;�$�'�
6��;�;�!�#�#�C��F�+��5�$��(�
2���A��'�T�1���
���!�!�T�Z�Z�0�'�,�q�c�(:�;��E����"���G���
�sb�<D�	J#�	AE�J#�%AG�0$G�'J#�J#�$H6�6J#�I�J#�$+J�J�J�J#c��|j�}d}|�	|j|�}|d|}|rtjj|�}t
|�D]a}|r|j|jk(rd}�!|r*tjj|j�}n|j}||k(s�_|cS|rt|��y#t$rd}Y��wxYw)z}Find an archive member by name from bottom to top.
           If tarinfo is given, it is used as the starting point.
        FNT)	r}�indexr<r�r/�normpath�reversedrr�)	r�r�r>�	normalizerL�skippingrre�member_names	         rDrwzTarFile._getmember}
s���
�/�/�#������
*��
�
�g�.��"�&�5�/����7�7�#�#�D�)�D��w�'�F���>�>�V�]�]�2�$�H��� �g�g�.�.�v�{�{�;��$�k�k���{�"��
�(���W�%�%���1�
 � ��
 �s�C
�
C�Cc�V�|j��	|j���d|_y)zWRead through the entire archive file and look for readable
           members.
        NT)r�rMr�s rDr|z
TarFile._load�
s(���i�i�k�%���i�i�k�%���rFc��|jr"td|jjz��|�'|j|vrtd|jz��yy)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�r?r�r�)r�r�s  rDr{zTarFile._check�
sS���;�;��.�4�>�>�+B�+B�B�C�C����	�	�� 5��5��	�	�A�B�B�!6�rFc�,�|j�rQdjtdtjj|j�|jf��}d}n|j}|}|j||d��}|�td|z��|S)zZFind the target member of a symlink or hardlink member in the
           archive.
        rWNT)r>rzlinkname %r not found)
rbrr�r�r/rdr�rcrwrx)r�r>rc�limitres     rDr�zTarFile._find_link_target�
s����=�=�?��x�x��t�b�g�g�o�o�g�l�l�.K�W�M]�M]�-^� _�`�H��E��'�'�H��E�����5�D��I���>��2�X�=�>�>��
rFc#�RK�|jr|jEd{���yd}|j�|j�}|dz
}|��	|t	|j�kr|j|}n'|js|j�}|s	d|_yy|dz
}|���Y7���w)z$Provide an iterator object.
        Nrr-T)rMrLrOr�r>)r�rr>s   rD�__iter__zTarFile.__iter__�
s������<�<��|�|�#�#�������'��i�i�k�G��Q�J�E��M���s�4�<�<�(�(��,�,�u�-���\�\��)�)�+���#'�D�L����Q�J�E��M��
$�s�B'�B%�BB'c�Z�||jkrt|tj��yy)z.Write debugging output to sys.stderr.
        ��fileN)rIr�r��stderr)r��level�msgs   rDr�zTarFile._dbg�
s#���D�J�J���#�C�J�J�'�rFc�&�|j�|Sr�)r{r�s rD�	__enter__zTarFile.__enter__�
s�����
��rFc��|�|j�y|js|jj�d|_yr)r�r�r�r�)r�rtr��	tracebacks    rD�__exit__zTarFile.__exit__�
s2���<��J�J�L��#�#����"�"�$��D�KrF)
Nr�NNNNNNr�NNNN)r�N)r�Nr[)r�NN)NNN�Trr�)�.N)r�T)TFr")>r�r�r�r�rIrGrHrJrrbr
rBrCrr>r8r�r�r�r8rurrTrkrorsrUr�ryr}rr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rwr|r{r�rr�rr!r�rFrDrrns����
�E��K��L��J��F��H�
�F��G��J���AE�HL�>B�)-�b�^��#�t�Z�]/��]/�~�2��2�����@����6����:����	�I�%�*	��?�a�F$�D�$�L1"��1"�f%�2G�.+/�%��+/�ZG���G�&�.+�,�
C��@>B�&+�*0�b
�N� B�?�A�$V�2D�B?�L�<�B&&�P�C��&�>(��rFrc���	t|d�r.|j�}t|��}|j|�nt|�}|j	�y#t
$rYywxYw)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.
    rt)r�TF)r�r�rr�r�r)r�r�rs   rDrrsX��
��4�� ��)�)�+�C��T�"�A��I�I�c�N��T�
�A�	���	�������s�AA�	A$�#A$c	��ddl}d}|j|��}|jddddd�	�|jd
dtd�
�|j	d��}|jdddd��|jddddd��|jddddd��|jdd dd!��|j�}|jr|j�|jd"d#�|j��|j}t|�rut|d$�5}|j�t|j�tj�%�ddd�|j r=td&j#|��y|jd"d'j#|��yy|j$�u|j$}t|�r<t&j|d(�5}|j%|j �)�ddd�y|jd"d'j#|��y|j��+t)|j�d"k(r |jd}t*j,}nHt)|j�d*k(r|j\}}n |jd"|j/��t�r}t&j|d(�5}|j1|j�+�ddd�|j rWd,k(rd-j#|�}	nd.j#||�}	t|	�y|jd"d'j#|��yy|j2��|j2j5d�}
t*j6j9|
�\}}d/d/d0d0d1d1d1d1d2�}
||
vrd3|
|znd4}|j2}t&j|
|�5}|D]}|j;|��	ddd�|j rtd5j#|
��yyy#1swY���xYw#1swYyxYw#1swY��VxYw#1swY�XxYw)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.
rR)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�testrrr}r�r�rr�rbrrr>r��curdir�format_helpr��creater]r/�splitextr�)r1r&�parserr��argsrvr��tfr8r�tar_namer�ext�compressions�tar_mode�	tar_files�	file_names                 rD�mainrEs����G�K�
�
$�
$��
$�
=�F�
����k�,��-��/�
���
�N� .�4��6�
�/�/��/�>�E�	���t�X�{�7��9�	���t�[��<�=��?�
���t�Z�s�3�9��;�
���t�X�{�8��:�����D��{�{�t�|�|�+����A�@�A��y�y���i�i���c�?��c�3��3���� ��c�n�n�&�S�Z�Z�8� ��|�|��.�5�5�c�:�;��K�K��9�@�@��E�F��

���	��i�i���c�?����c�5�)�R��������-�*�)�
�K�K��9�@�@��E�F�	
���	!��t�|�|���!��,�,�q�/�C��Y�Y�F�
����
�!�
#��,�,�K�C���K�K��6�-�-�/�0��c�?����c�5�)�R��
�
�6�$�+�+�
�>�*��|�|��S�=�3�:�:�3�?�C�2�39�6�#�v�3F���c�
��K�K��9�@�@��E�F��
���	 ��;�;�?�?�1�%�����!�!�(�+���3���������
��03�l�/B�4�,�s�+�+����K�K�	�
�\�\�(�H�
-��&�	����y�!�'�.��<�<��&�-�-�h�7�8��/
!�M ���*�)��*�)��>.�
-�s0�:P-�P:�Q�"Q�-P7�:Q�Q�Q�__main__r")lr��version�
__author__�__credits__�builtinsrrEr�r�r)rqr�r�rir��rer�r�r�r��AttributeError�NotImplementedErrorr�r��__all__r?rrur�r�r�r�r�r{r�r(r&r�r�r�r.�CONTTYPEr�r�r�r�r�r�rrrrr�r r�rrr�rWrr�r
�getfilesystemencodingrErLr\rdrnrrr�rrrrr	r
rr�r�r�rYr�r�r��objectr�r�BufferedReaderr8rrrrrrrjrrrr�r��compiler�rrrrEr�r�rFrD�<module>rTs���:���6�
�H��
'�
�	�	�
���
��	������$�%8�'�B��*�����	�
��^�
��	��������
�
����
��
��
��
��
������������
��
������
�
�
�
����H�g��G�X��W�g�#�%5�!�	#���(��>�+�
��/�
�
�	�.�
�9��
�
�
����
���7�7�d�?��H�(�s�(�(�*�H�0�&�
�(�N�
�<*�"&��$��2�	�y�	�	�8�	�	��	�	�x�	�	�(�	�	�(�	�	�{�	�	�;�	�	�[�	�	��	�	�K�	���0r�r�j�6��<e�&�e�P"�2�$�$�"�	�(�	�J��J�
?�k�?�@�{�@�
L��L�
?�+�?�=�~���*�����	���&�2�:�:�&8�9��Z9�f�Z9�zL�f�L�d$�$�|�|��]9�~�z���F���Y��
�C�����
�C��s"�I�I�I�I�I�I

Hacked By AnonymousFox1.0, Coded By AnonymousFox