� c��j�b���dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z e jZ ddlZ ddlZgd�ZGd�de�ZGd�de�ZexZZdZd Zd ZdZd Zd Zd Zd ZdZdZ dZ!dZ"dZ#dZ$ejJe#�Z&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.d Z/dZ0dZ1dZ2ejJe1�Z3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;d ZdZ?d Z@dZAd ZBd ZCd!ZDd"ZEd#ZFdZGdZHd ZId$ZJd%ZKd&ZLd'ZMd(ZNejJeM�ZOdZPdZQdZRdZSdZTdZUdZVdZWd ZXdZYdZZdZ[d)Z\d*Z]ejJe\�Z^d+Z_d,Z`ejJe_�ZadZbdZcdZddZedZfdZgdZhdZid ZjdZkd-Zlej�d.�Znd/�Zod0�Zpd1�Zqd2�Zrd3�Zsd4�ZtGd5�d6eu�Zvdawd7�Zxd8�ZyGd9�d:�ZzGd;�d<�Z{idd=�dd>�dd?�dd?�dd?�dd?�dd@�ddA�d dB�ddC�dd@�d dD�d dE�d#dF�dGdH�dIdJ�dKdL�Z|dM�Z}d^dN�Z~dO�ZGdP�dQ�Z�GdR�dS�Z�GdT�dUe�j�Z�GdV�dWe�j�Z�GdX�dY�Z�GdZ�d[e��Z�d^d\�Z�dd]l�m�Z�m�Z�y#e$rdZ ejZ Y��$wxYw#e$rdZY��-wxYw#e$rdZY��6wxYw)_zP Read and write ZIP files. XXX references to utf-8 need further investigation. �N) � BadZipFile� BadZipfile�error� ZIP_STORED� ZIP_DEFLATED� ZIP_BZIP2�ZIP_LZMA� is_zipfile�ZipInfo�ZipFile� PyZipFile� LargeZipFile�Pathc� �eZdZy)rN)�__name__� __module__� __qualname__���)/usr/lib64/python3.12/zipfile/__init__.pyrr's��rrc��eZdZdZy)rzu Raised when writing a zipfile, the zipfile requires ZIP64 extensions and those extensions are disabled. N)rrr�__doc__rrrrr+s��rri�������� ���-�.�?s<4s4H2LHsPK�������� z<4s4B4HL2L5H2LsPK� � � ����� �@iz <4s2B4HL2L2HsPKz<4sLQLsPKz <4sQ2H2L4QsPKiPK�� t|�ry y#t$rYywxYw)NTF)� _EndRecData�OSError��fps r�_check_zipfilerH�s2�� � �r�?�� � �� � � � � �s � � �c���d} t|d�rt|��}|St|d�5}t|�}ddd�|S#1swY|SxYw#ttf$rY|SwxYw)z�Quickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too. F�readrF�rbN)�hasattrrH�openrEr)�filename�resultrGs rr r �sw�� �F� � �8�V� $�#�x�0�F� �M� �h��%��'��+��&� �M� &� �M�� �Z� � � � �M� �s2�A � A � A�A �A �A � A � A �A c ��|tz}|dkr|S|j|�|jt�}t|�tk7r t d��t j t|�\}}}}|tk7r|S|dk7s|dkDr td��|tz}||kDr td��|j|�||z }|jt�}t|�tk7r t d��|jt�sJ||k7rE|j|�d}|jt�}t|�tk7r t d��|jt�s td��t j t|�\ }} } } } } }}}}||z|k7s| dzt|zk7r td��||t<| |t<| |t <||t"<||t$<||t&<||t(<||z |t*<|S) zM Read the ZIP64 end-of-archive records and use that to update endrec rzUnknown I/O errorr!z3zipfiles that span multiple disks are not supportedz.Corrupt zip64 end of central directory locatorz/Zip64 end of central directory record not foundrz-Corrupt zip64 end of central directory record)�sizeEndCentDir64Locator�seekrJr6rE�structr5�structEndArchive64Locator�stringEndArchive64Locatorr�sizeEndCentDir64� startswith�stringEndArchive64�structEndArchive64�_ECD_SIGNATURE�_ECD_DISK_NUMBER�_ECD_DISK_START�_ECD_ENTRIES_THIS_DISK�_ECD_ENTRIES_TOTAL� _ECD_SIZE� _ECD_OFFSET� _ECD_LOCATION)�fpin�offset�endrec�data�sig�diskno�reloff�disks�extrasz�sz�create_version� read_version�disk_num�disk_dir�dircount� dircount2�dirsize� diroffsets r� _EndRecData64rt�s �� �%�%�F� ��z�� ��I�I�f�� �9�9�,� -�D� �4�y�+�+��)�*�*�!'���/H�$�!O��C���� �'�'�� � ��{�e�a�i��N�O�O� ���F� ����I�J�J��I�I�f���v�o�G� �9�9�%� &�D� �4�y�$�$��)�*�*� �?�?�-� .�6�V�3C� � � �&�����y�y�)�*�� �t�9�(� (��-�.� .� �?�?�-� .��J�K�K� � � �(�$�/�0�C��^�\�8�X��)�W�i��G��v�%� �R��#�g�-�-��H�I�I�!�F�>��'�F� ��&�F�?��%-�F� !�"�!*�F� ���F�9��#�F�;��"�W�,�F�=�� �Mrc���|jdd�|j�} |jt d�|j t�}t |�tk(rv|ddt k(rj|dddk(rbtjt|�}t|�}|jd�|j|tz �t||tz |�St|tz tz d�}|j|d�|j ttz�}|jt �}|dk\r�|||tz}t |�tk7ryttjt|��}|t }||tz|tz|z}|j|�|j||z�t|||z|�Sy#t$rYywxYw)z�Return data from the "End of Central Directory" record, or None. The data is a list of the nine items in the ZIP "End of central dir" record followed by a tenth item, the file seek offset of this record.rr"Nr$�����sr)rR�tell�sizeEndCentDirrErJr6�stringEndArchiverSr5�structEndArchive�listr7rt�max�ZIP_MAX_COMMENT�rfind�_ECD_COMMENT_SIZE) rb�filesizererd�maxCommentStartr=�recData� commentSize�comments rrDrD*s��� �I�I�a��O��y�y�{�H� � � � �>�/�1�%� �9�9�^� $�D� �D� �^�#� �Q�q� �%�%� �R�S� �[� ����/��6���F�|�� � � �c��� � �h��/�0��T�8�n�#<�f�E�E��(�_�4�~�E�q�I�O��I�I�o�q�!� �9�9�_�~�5� 6�D� �J�J�'� (�E� ��z��u�U�>�1�2�� �w�<�>� )���f�m�m�$4�g�>�?���.�/� ��u�^�+�E�.�,@��,L�M��� � �g��� � �o��-�.��T�?�U�#:�F�C�C� ��U ����s�G� G�Gc��|jtd��}|dk\r|d|}tjdk7r2tj|vr |j tjd�}tj rEtj dk7r2tj |vr |j tj d�}|S)zzTerminate the file name at the first null byte and ensure paths always use forward slashes as the directory separator.r�/)�find�chr�os�sep�replace�altsep)rN� null_bytes r�_sanitize_filenamer�es��� � � �c�!�f�%�I��A�~��A�i�(�� �v�v��}����8�+��#�#�B�F�F�C�0�� �y�y�R�Y�Y�#�%�"�)�)�x�*?��#�#�B�I�I�s�3�� �Orc�T�eZdZdZdZd d�Zd�Zdd�Zd�Zd�Z e dd d �d ��Z d �Z y)r z>Class with attributes describing each file in the ZIP archive.)� orig_filenamerN� date_time� compress_type�_compresslevelr�r9� create_systemrl�extract_version�reserved� flag_bits�volume� internal_attr� external_attr� header_offset�CRC� compress_size� file_size� _raw_time� _end_offsetc��||_t|�}||_||_|ddkr t d��t |_d|_d|_d|_ tjdk(rd|_ nd|_ t|_t|_d|_d|_d|_d|_d|_d|_d|_d|_y)Nr�z+ZIP does not support timestamps before 1980r�win32r#)r�r�rNr�� ValueErrorrr�r�r�r9�sys�platformr��DEFAULT_VERSIONrlr�r�r�r�r�r�r�r�r�)�selfrNr�s r�__init__zZipInfo.__init__�s���%���&�h�/�� �� �"��� �Q�<�$� ��J�K� K�(���"����� ��� � �<�<�7� "�!"�D� �"#�D� �-���.����� ������ ���������������rc��d|jj�d|j��g}|jtk7r<|j dt j|j|j�z�|jdz }|jdz}|r'|j dtj|�z�|r|j d|z�|j�}|r |jr|j d|jz�|r |jrJ|jtk7s|j|jk7r|j d |jz�|j d �d j|�S) N��)� __class__rrNr�rr7�compressor_names�getr��stat�filemode�is_dirr�r�r8)r�rO�hi�lo�isdirs r�__repr__zZipInfo.__repr__�s;��'+�~�~�'>�'>�� � �N�O�� � � �� +� �M�M�-�*�.�.�t�/A�/A�/3�/A�/A�C�C� D�� � �2� %�� � � �&� (�� � �M�M�.�4�=�=��+<�<� =� � �M�M�.��3� 4�� � � ������ �M�M�/�D�N�N�:� ;��$�,�,� � � �:� -� �^�^�t�1�1� 1� �M�M�-��0B�0B�B� C�� � �c���w�w�v��rNc��|j}|ddz dz|ddzz|dz}|ddz|d dzz|ddzz}|jtzrdx}x}}n$|j}|j}|j }|j }d} |�|tkDxs |tkD}|r>d } |tj| dtj| �d z ||�z}d }d }t} |jtk(rtt| �} n#|jt k(rtt"| �} t| |j$�|_t| |j&�|_|j)�\} } tjt*t,|j$|j.| |j|||||t1| �t1|�� } | | z|zS) z�Return the per-file header as a bytes object. When the optional zip64 arg is None rather than a bool, we will decide based upon the file_size and compress_size, if known, False otherwise. rr�r(r!r%r"r#r*r$z�>�5� 5�./� /�C� /�-�)��(�(�C� �.�.�M����I�� � ��� � �=�� �+�J�}�{�/J�E� ��C��F�K�K��()�6�?�?�3�+?��+A�9�m�]�]�E�"�I�&�M�'�K� � � �� *��m�[�9�K� � � �8� +��l�K�8�K�"�;��0D�0D�E���!�+�t�/B�/B�C���"�7�7�9���)����-�/?�!�1�1�4�=�=�)�!�/�/��'�3�*�I� ��]�C��J� 8�� �� �5�(�(rc��� |jjd�|jfS#t$r1|jjd�|jtzfcYSwxYw)N�ascii�utf-8)rN�encoder��UnicodeEncodeError�_MASK_UTF_FILENAME�r�s rr�zZipInfo._encodeFilenameFlags�s[�� V��=�=�'�'��0�$�.�.�@� @��!� V��=�=�'�'��0�$�.�.�CU�2U�U� U� V�s�&)�7A#�"A#c��|j}tj}t|�dk\�r2|d|dd�\}}|dzt|�kDrt d||fz��|dk(r|d|dz} |j dvrd}|d|dd�\|_|dd}|j d k(rd }|d|dd�\|_|dd}|jd k(rd }|d|dd�\|_ne|dk(r`|d|dz} |d|dd�\}} |dk(rC| |k(r>|ddjd�} | rt| �|_ nddl } | jdd��||dzd}t|�dk\r��1yy#tj$rt d �d ��d�wxYw#tj$r} t d�| �d} ~ wt$r} t d�| �d} ~ wwxYw)Nr$r2z"Corrupt extra field %04x (size=%d)r!)l����r�z File sizezCorrupt unicode path extra field (0x7075): invalid utf-8 bytes)r9rSr5r6rr�r�r�r�decoder�rN�warnings�warn�UnicodeDecodeError) r�� filename_crcr9r5�tp�lnre�field� up_version� up_name_crc�up_unicode_namer��es r� _decodeExtrazZipInfo._decodeExtras��� � �������%�j�A�o��E�5��!�9�-�F�B���!�t�c�%�j� � �!E��R��!P�Q�Q��V�|��Q�r�!�t�}��F��~�~�)M�M� +��*0��t�B�Q�x�*@����#�A�B�x���)�)�[�8� /��.4�T�4���8�.D�+��*�#�A�B�x���)�)�[�8� /��.4�T�4���8�.D�+��*���v���Q�r�!�t�}�� n�.4�U�D��!�H�.E�+�J� �!�Q��;�,�+F�*.�q�r�(�/�/�'�*B��*�,>��,O�D�M�+�$�M�M�*S�`a�M�b� �"�Q�$�%�L�E�O�%�j�A�o��&�|�|�F�$�'B�(-�w�k�&;�<�AE�F�F���|�|�Y�$�%P�Q�WX�X��)�n�$�%e�f�lm�m��n�s2�*A5E�.AF�$F�G� F%�% G�1 F=�=GT��strict_timestampsc��t|tj�rtj|�}tj|�}t j |j �}tj|j�}|dd}|s |ddkrd}n |s |ddkDrd}|�|}tjjtjj|�d�}|dtjtjfvr+|dd}|dtjtjfvr�+|r|d z }|||�}|j d zd z|_|rd|_|xjd zc_|S|j"|_|S) a_Construct an appropriate ZipInfo for a file on the filesystem. filename should be the path to a file or directory on the filesystem. arcname is the name which it will have within the archive (by default, this will be the same as filename, but without a drive letter and with leading path separators removed). rr&r��r�r!r!rrr�;)r�r���;r�Nr!r�rr-)� isinstancer��PathLike�fspathr��S_ISDIR�st_mode�time� localtime�st_mtime�path�normpath� splitdriver�r�r�r��st_size) �clsrN�arcnamer��str��mtimer��zinfos r� from_filezZipInfo.from_file1sV�� �h�� � � ,��y�y��*�H� �W�W�X� ��� � �R�Z�Z�(�����r�{�{�+���!�A�J� � �Y�q�\�D�%8�-�I�"�y��|�d�':�2�I� �?��G��'�'�"�"�2�7�7�#5�#5�g�#>�q�#A�B���a�j�R�V�V�R�Y�Y�/�/��a�b�k�G��a�j�R�V�V�R�Y�Y�/�/� � �s�N�G��G�Y�'��!�z�z�F�2�r�9��� ��E�O� � � �4� '� �� �!�j�j�E�O�� rc� �|jjd�rytjjrM|jjtjj tjjf�Sy)z2Return True if this archive member is a directory.r�TF)rN�endswithr�r�r�r�r�s rr�zZipInfo.is_dirWsQ�� �=�=� !� !�#� &�� �7�7�>�>��=�=�)�)�2�7�7�;�;������*G�H� H�r)�NoNamer��N) rrrr� __slots__r�r�r�r�r�� classmethodr�r�rrrr r xsJ��H��I�0  �J�,.)�`V� +!�Z�#�D�#��#�J rr c�L�td�D]}|dzr |dz dz }�|dz}�|S)Nrr!l q[)�range)�crcrAs r�_gen_crcris5�� �1�X�� ��7��!�8�z�)�C� �A�I�C� � �Jrc��������d�d�d�t�"tttt d���at��fd������fd��|D] }�|�� ��fd�}|S)NixV4i�gE#i�xV4�c�&��|dz �||z dzz S)z(Compute the CRC32 primitive on one byte.r��r)�chr�crctables �r�crc32z_ZipDecrypter..crc32�s ����q��H�c�B�h�$�%6�7�7�7rc�\���|�����dzzdz��dzdzdz���dz ���y)Nr r�i�r!�r)�cr�key0�key1�key2s ����r� update_keysz"_ZipDecrypter..update_keys�sE����Q��~����t� �$� �2���y� �1�$� �2���T�R�Z��&�rc���t�}|j}|D](}�dz}|||dz zdz dzz}�|�||��*t|�S)zDecrypt a bytes object.r"r!rr )� bytearrayr7�bytes)rerOr7r�krrs ��r� decrypterz _ZipDecrypter..decrypter�s\�����������A��q��A� �1��!��9��"�d�*� *�A� ��N� �1�I� � �V�}�r)� _crctabler{�maprr) �pwd�prrr rrrrs @@@@@@r� _ZipDecrypterrys^��� �D� �D� �D�����X�u�S�z�2�3� ��H�8�'����A��� � �rc�$�eZdZd�Zd�Zd�Zd�Zy)�LZMACompressorc��d|_yr)�_compr�s rr�zLZMACompressor.__init__�s ���� rc�.�tjdtji�}tjtjtj tj|�g��|_tjdddt|��|zS)N�id��filterszzLZMADecompressor.decompress�s��� �<�<� � � � �� $� ��4�#�#�$��)���]�]�4��)9�)9�!�A�)>�?�F�E��4�#�#�$��E� �1���0�0�����.�.�t�/@�/@�/3�/?�/?��!�e�)�/L�N�K��D�L��#�#�A��I�J�/�D�� ����(�(��z�:���<�<�#�#���� rN������)rrrr��propertyr<r>rrrr5r5�s ��� �(��(�rr5�store�shrink�reduce�implode�tokenize�deflate� deflate64�bzip2r(�terse��lz77�a�wavpack�b�ppmdc���|tk(ry|tk(rts td��y|tk(rt s td��y|t k(rts td��ytd��)Nz.Compression requires the (missing) zlib modulez-Compression requires the (missing) bz2 modulez.Compression requires the (missing) lzma modulez(That compression method is not supported) rr�zlib� RuntimeErrorr�bz2r r(�NotImplementedError)� compressions r�_check_compressionrY�s����j� � � � � $���@�B� B�� � � !���?�A� A�� �� ���@�B� B��"�"L�M�Mrc�X�|tk(rZ|�%tj|tjd�Stjtjtjd�S|t k(r+|�t j|�St j�S|tk(r t�Sy)N�����) rrT� compressobj�DEFLATED�Z_DEFAULT_COMPRESSIONrrV� BZ2Compressorr r!)r�� compresslevels r�_get_compressorras���� �$� � $��#�#�M�4�=�=�#�F� F����� :� :�D�M�M�3�O�O� �)� #� � $��$�$�]�3� 3�� � �"�"� �(� "����rc�4�t|�|tk(ry|tk(rtjd�S|t k(rt j�S|tk(r t�Stj|�}|rtd||fz��td|fz��)Nr[zcompression type %d (%s)zcompression type %d) rYrrrT� decompressobjrrV�BZ2Decompressorr r5r�r�rW)r��descrs r�_get_decompressorrfs����}�%�� �"�� �,� &��!�!�#�&�&� �)� #��"�"�$�$� �(� "��!�!� �$�$�]�3�� �%�&@�M�SX�CY�&Y�Z� Z�%�&;�}�>N�&N�O� Orc�.�eZdZd�Zd�Zdd�Zdd�Zd�Zy) � _SharedFilec�l�||_||_||_||_||_|j |_yr)�_file�_pos�_close�_lock�_writing�seekable)r��file�pos�close�lock�writings rr�z_SharedFile.__init__%s0���� ��� ��� ��� ��� �� � �� rc��|jSr)rkr�s rrwz_SharedFile.tell-s ���y�y�rc��|j5|j�r td��|tjk(r)|j j |j|z�n|j j ||�|j j�|_|jcddd�S#1swYyxYw)Nz}Can't reposition in the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.) rmrnr�r��SEEK_CURrjrRrkrw)r�rc�whences rrRz_SharedFile.seek0s��� �Z�Z��}�}�� �"J�K�K�����$�� � ���� � �F� 2�3�� � �����/�� � ���)�D�I��9�9��Z�Z�s �BB5�5B>c�>�|j5|j�r td��|jj |j �|jj |�}|jj�|_|cddd�S#1swYyxYw)N�yCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)rmrnr�rjrRrkrJrw�r��nres rrJz_SharedFile.read=sn�� �Z�Z��}�}�� �"J�K�K� �J�J�O�O�D�I�I� &��:�:�?�?�1�%�D�� � ���)�D�I���Z�Z�s �A$rY�{wxYw) NFrrr�Trr rzBad password for file %r)'�_fileobj�_pwd�_close_fileobjr��_compress_typer��_compress_leftr��_leftrf� _decompressor�_eof� _readbuffer�_offset�newlines�moderN�namerLr�� _expected_crcr� _running_crc� _seekablerorw�_orig_compress_start�_orig_compress_size�_orig_file_size�_orig_start_crc� _orig_crc�AttributeError� _decrypterr�r�r��_init_decrypterrUr�)r�r~r��zipinfor� close_fileobj� check_byte�hs rr�zZipExtFile.__init__qs����� ��� �+���%�3�3���%�3�3����&�&�� �.�t�/B�/B�C����� ������ ��� ��� ��$�$�� � �7�E� "�!(���D� � %�c� �D� �!%�D� ���� ����!�,3�L�L�N��)�+2�+@�+@��(�'.�'8�'8��$�'+�'8�'8��$�!%�!3�!3���!%������ �� � �#<�<�%�/�/�1�4��<� �&�k�k�R�/�4�7� ��$�$�&�A��J��"�#=��@U�@U�#U�V�V�� �� � � � �s�A0F4�4 G�?Gc��t|j�|_|jj d�}|xj dzc_|j|�dS)Nrr*)rr�r�r�rJr�)r�r�s rr�zZipExtFile._init_decrypter�sM��'�� � �2��� ���#�#�B�'�� ���r�!�����v�&�r�*�*rc���d|jj�d|jj��g}|js{|j d|j �d|j ���|jtk7rN|j dtj|j|j�z�n|j d�|j d�dj|�S) Nr��.z name=z mode=r�� [closed]r�r�) r�rr�closedr7r�r�r�rr�r�r8�r�rOs rr�zZipExtFile.__repr__�s���"�n�n�7�7�"�n�n�9�9�;�<���{�{� �M�M�� � �4�9�9�E� F��"�"�j�0�� � �1�.�2�2�4�3F�3F�37�3F�3F�H�H�I� �M�M�+� &�� � �c���w�w�v��rc���|dkrP|jjd|j�dz}|dkDr"|j|j|}||_|Stjj ||�S)zrRead and return a line from the stream. If limit is specified, at most limit bytes will be read. r� r!)r�r�r��io�BufferedIOBase�readline)r��limitr>�lines rr�zZipExtFile.readline�sn�� �1�9�� � �%�%�e�T�\�\�:�Q�>�A��1�u��'�'�� � �a�8�� �� �� �� � �)�)�$��6�6rc�x�|t|j�|jz kDrp|j|�}t|�|jkDr)||j|jdz|_d|_n|xjt|�zc_|j|j|jdzS)z6Returns buffered bytes without advancing the position.Nri)r6r�r�rJ)r�r|�chunks r�peekzZipExtFile.peek�s��� �s�4�#�#�$�t�|�|�3� 3��I�I�a�L�E��5�z�D�L�L�(�#(�4�+;�+;�D�L�L�M�+J�#J�� � �� �� � ��E� �*� ����� � �d�l�l�S�.@�A�Arc�2�|jr td��y)N�I/O operation on closed file.T)r�r�r�s r�readablezZipExtFile.readable�s�� �;�;��<�=� =�rc���|jr td��|�|dkr`|j|jd}d|_d|_|js+||j |j �z }|js�+|S||jz}|t|j�kr"|j|j|}||_|S|t|j�z }|j|jd}d|_d|_|dkDri|js]|j |�}|t|�kr||_||_||d|z } |S||z }|t|�z}|dkDr |js�]|S)z�Read and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached. zread from closed file.Nrr)r�r�r�r�r��_read1�MAX_Nr6)r�r|�buf�endres rrJzZipExtFile.read�sk�� �;�;��5�6� 6� �9��A���"�"�4�<�<�=�1�C�"�D� ��D�L��i�i��t�{�{�4�:�:�.�.���i�i��J��$�,�,��� ��T�%�%�&� &��"�"�4�<�<��4�C��D�L��J� �#�d�&�&�'� '�����t�|�|�}�-������� ��!�e�D�I�I��;�;�q�>�D��3�t�9�}�#'�� � �� ��t�B�Q�x����� � �4�K�C� ��T��N�A��!�e�D�I�I�� rc���|j�yt||j�|_|jr2|j|jk7rt d|j z��yy)NzBad CRC-32 for file %r)r�rr�r�rr�)r��newdatas r� _update_crczZipExtFile._update_crcs]�� � � � %� �!�'�4�+<�+<�=��� �9�9��*�*�d�.@�.@�@��5�� � �A�B� B�A�9rc��|�|dkrg|j|jd}d|_d|_|js2|j|j�}|r||z } |S|js�2|S||jz}|t |j�kr"|j|j|}||_|S|t |j�z }|j|jd}d|_d|_|dkDr[|jsO|j|�}|t |�kr||_||_||d|z } |S|r||z } |S|js�O|S)z7Read up to n bytes with at most one read() system call.Nrr)r�r�r�r�r�r6)r�r|r�rer�s r�read1zZipExtFile.read1 sb�� �9��A���"�"�4�<�<�=�1�C�"�D� ��D�L��i�i��{�{�4�:�:�.����4�K�C���J� �i�i� �J��$�,�,��� ��T�%�%�&� &��"�"�4�<�<��4�C��D�L��J� �#�d�&�&�'� '�����t�|�|�}�-������� � �q�5��i�i��{�{�1�~���s�4�y�=�'+�D�$�#$�D�L��4���8�O�C��� ���4�K�C��� ��i�i�� rc��|js|dkry|jtk(rE|jj}|t |�kDrq||j |t |�z �z }nP|jtk(r|j |�}n+t|jdd�r|j |�}nd}|jtk(r|jdk|_�n*|jtk(r�t||j�}|jj||�}|jjxs(|jdkxr|jj |_|jr�||jj�z }nv |jj|t||j��}|jjxs(|jdkxrt|jdd�|_|d|j }|xj t |�zc_|j dkrd|_|j#|�|S#t$r|jj|�}Y��wxYw)Nrrr<T)r�r�rr��unconsumed_tailr6�_read2r�getattrr�r|� MIN_READ_SIZEr>r9r3� TypeErrorr�r�r{s rr�zZipExtFile._read12s6�� �9�9��Q��� � � �,� .��%�%�5�5�D��3�t�9�}��� � �A��D� �M�2�2�� � � �J� .��;�;�q�>�D��t�)�)�=�$�?��{�{�1�~���� � � �*� ,��+�+�q�0�D�I� � � �L� 0��A�t�)�)�*�A��%�%�0�0��q�9�D��+�+�/�/�@��,�,��1�@�!�/�/�?�?�?� �I��y�y���*�*�0�0�2�2��  ;��)�)�4�4�T�3�q�$�BT�BT�;U�V���+�+�/�/�J��,�,��1�J� ��!3�!3�]�D�I� �I��K�T�Z�Z� �� � � �c�$�i�� � �:�:��?��D�I� ������ ��� ;��)�)�4�4�T�:�� ;�s�0I$�$$J � J c�:�|jdkryt||j�}t||j�}|jj |�}|xjt |�zc_|st�|j�|j|�}|S)Nrr) r�r|r��minr�rJr6�EOFErrorr�r{s rr�zZipExtFile._read2fs��� � � �!� #�� ��4�%�%� &�� ��4�&�&� '���}�}�!�!�!�$�� ���s�4�y�(����N� �?�?� &��?�?�4�(�D�� rc��� |jr|jj�t�|� �y#t�|� �wxYwr)r�r�rr�super)r�r�s �rrrzZipExtFile.closevs4��� ��"�"�� � �#�#�%� �G�M�O��E�G�M�O�s �&8�Ac�H�|jr td��|jS�Nr�)r�r�r�r�s rrozZipExtFile.seekable}s�� �;�;��<�=� =��~�~�rc��|jr td��|jstjd��|j �}|t jk(r|}nG|t jk(r||z}n.|t jk(r|j|z}n td��||jkDr |j}|dkrd}||z }||jz}|dk\r#|t|j�kr ||_ d}�n�|jtk(r�|j ��|dk7r�d|_|t|j�|jz z}|j$j'|t j�|xj(|zc_|xj*|zc_|j(dk|_d}d|_ d|_ n�|dkr�|j$j'|j.�|j0|_|j4|_|j6|_|j|_d|_ d|_ t9|j�|_d|_|}|j �|j=�|dkDr2t?|j@|�}|jC|�||z}|dkDr�2|j �S)Nzseek on closed file.�!underlying stream is not seekablezCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)rrF)"r�r�r�r��UnsupportedOperationrwr��SEEK_SETrw�SEEK_ENDr�r�r6r�r�rr�r�r�rRr�r�r�r�r�r�r�r�rfr�r�r�� MAX_SEEK_READrJ)r�rcrx�curr_pos�new_pos� read_offset� buff_offset�read_lens rrRzZipExtFile.seek�ss�� �;�;��3�4� 4��~�~��)�)�*M�N� N��9�9�;�� �R�[�[� ��G� �r�{�{� "���'�G� �r�{�{� "��*�*�V�3�G��C�D� D� �T�)�)� )��*�*�G� �Q�;��G���(� �!�D�L�L�0� � �!� � �c�$�2B�2B�.C� C�&�D�L��K� � � �J� .�4�?�?�3J�{�^_�O_�!%�D� � �3�t�/�/�0�4�<�<�?� ?�K� �M�M� � �{�B�K�K� 8� �J�J�+� %�J� � � �;� .� �� � �a��D�I��K�"�D� ��D�L� �1�_� �M�M� � �t�8�8� 9� $� 4� 4�D� �!%���D� �"&�":�":�D� ��-�-�D�J�"�D� ��D�L�!2�4�3F�3F�!G�D� ��D�I�!�K����*��$�$�&��A�o��4�-�-�{�;�H� �I�I�h� � �8� #�K��A�o� �y�y�{�rc���|jr td��|jstjd��|j |j z t|j�z |jz}|S)Nztell on closed file.r�) r�r�r�r�r�r�r�r6r�r�)r��fileposs rrwzZipExtFile.tell�s`�� �;�;��3�4� 4��~�~��)�)�*M�N� N��&�&����3�c�$�:J�:J�6K�K�d�l�l�Z���r)NFrA�r!)rrrrr�r�r�r�r�r�r�r�r�rJr�r�r�r�rrror�r�rRrw� __classcell__�r�s@rr�r�cs���� �E��M��M�37�$�1W�h +� �7� B�� !�FC�#�J2�h� �� #%�+�+�?�Brr�c�@��eZdZd�Zed��Zd�Zd�Z�fd�Z�xZ S)� _ZipWriteFilec��||_||_||_t|j|j �|_d|_d|_d|_ yr�) �_zinfo�_zip64�_zipfilerar�r�� _compressor� _file_size�_compress_size�_crc)r��zfr�r�s rr�z_ZipWriteFile.__init__�sL���� ��� ��� �*�5�+>�+>�+0�+?�+?�A����������� rc�.�|jjSr)r�rGr�s rr�z_ZipWriteFile._fileobj�s���}�}���rc��yr;rr�s r�writablez_ZipWriteFile.writable�s��rc���|jr td��t|ttf�r t |�}nt |�}|j}|xj|z c_t||j�|_ |jr9|jj|�}|xjt |�z c_ |jj|�|Sr�)r�r�r�rrr6� memoryview�nbytesr�rr�r�r0r�r�r�)r�rer�s rr�z_ZipWriteFile.write�s��� �;�;��<�=� =� �d�U�I�.� /���Y�F��d�#�D��[�[�F� ���6�!���$�� � �*�� � � � ��#�#�,�,�T�2�D� � � �3�t�9� ,� � � � ���D�!�� rc ���|jry t�|� �|jro|jj �}|xj t |�z c_|jj|�|j |j_ n|j|j_ |j|j_ |j|j_|js<|jt kDr t#d��|j t kDr t#d��|jj$t&zr�|jrdnd}|jjt)j*|t,|jj|jj|jj��|jj/�|j0_n�|jj/�|j0_|jj5|jj6�|jj|jj9|j��|jj5|j0j2�|j0j:j=|j�|j|j0j>|jj@<d|j0_!y#d|j0_!wxYw)Nz*File size too large, try using force_zip64z0Compressed size too large, try using force_zip64z�� � �'� +/�-�-�*<�*<�*>�� � �'�� � �"�"�4�;�;�#<�#<�=�� � �#�#�D�K�K�$:�$:�4�;�;�$G�H�� � �"�"�4�=�=�#:�#:�;� �M�M� "� "� )� )�$�+�+� 6�=A�[�[�D�M�M� $� $�T�[�[�%9�%9� :�%*�D�M�M� "��U�D�M�M� "�s �LL8�8M ) rrrr�rCr�r�r�rrr�r�s@rr�r��s0����� �� ���&++�++rr�c�&�eZdZdZdZdZdZdeddfddd�d�Zd�Z d �Z d �Z d �Z d �Z d �Zd$d�Zd�Zd�Zd�Zed��Zej*d��Zd$d�Zd%dd�d�Zd&d�Zd'd�Zd(d�Zed��Zd�Zd�Z d(d�Z d'd�Z d)d�Z!d �Z"d!�Z#d"�Z$d#�Z%y)*r ai Class with methods to open, read, write, close, list zip files. z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True, compresslevel=None) file: Either the path to the file, or a file-like object. If it is a path, the file will be opened and closed by ZipFile. mode: The mode can be either read 'r', write 'w', exclusive create 'x', or append 'a'. compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib), ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma). allowZip64: if True ZipFile will create files with ZIP64 extensions when needed, otherwise it will raise an exception when this would be necessary. compresslevel: None (default for the given compression type) or an integer specifying the level to pass to the compressor. When using ZIP_STORED or ZIP_LZMA this keyword has no effect. When using ZIP_DEFLATED integers 0 through 9 are accepted. When using ZIP_BZIP2 integers 1 through 9 are accepted. NF�rT)r��metadata_encodingc���|dvr td��t|�||_d|_d|_i|_g|_||_||_||_ d|_ d|_ ||_ ||_ |jr|dk7r td��t|tj �rtj"|�}t|t$�r;d|_||_d d d d d d dd�}||} t+j,|| �|_n d|_||_t3|dd�|_d|_t7j8�|_d|_d|_ |dk(r|jA�y|dvrNd|_ |j.jC�|_" |j.jG|jD�y|dk(r7 |jA�|j.jG|jD�ytd��#t0$r| |vr|| } Y��1�wxYw#tHt0f$r d|_YywxYw#tHt0f$r+tK|j.�|_d|_"d|_YywxYw#tL$rE|j.jGdd�d|_|j.jC�|_"YywxYw#|j.} d|_|jO| ��xYw)z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', or append 'a'.)r��w�x�az+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNrr�z5metadata_encoding is only supported for reading filesrK�w+b�x+b�r+b�wb�xb)r�r�r�r�rrrTr!r�)r�r�r�r"z"Mode must be 'r', 'w', 'x', or 'a')(r�rY� _allowZip64� _didModify�debugr�r�rXr`r�r�_comment�_strict_timestampsr�r�r�r�r��str� _filePassedrNr�rMrGrEr�� _fileRefCnt� threading�RLockrmr�rn�_RealGetContentsrwr�rRr�r�r�_fpclose) r�rpr�rX� allowZip64r`r�r��modeDictr�rGs rr�zZipFile.__init__;s��� �+� +��J�K� K��;�'�%�������� ������ �&���*����� ������ �"3���!2��� � !� !�d�c�k��G�I� I� �d�B�K�K� (��9�9�T�?�D� �d�C� � �D� � �D�M�"��U�%�$�T�$�@�H���~�H��� �g�g�d�H�5�D�G� � �D� ��D�G�#�D�&�$�7�D�M�����_�_�&�� ������ �' ��s�{��%�%�'���#�#'��� /�%)�W�W�\�\�^�D�N�/���� � �T�^�^�4���� 4��)�)�+��G�G�L�L����0�!�!E�F�F��c���8�+�#+�H�#5�� �� ��@+�G�4�/�).���/��'��0�+�'����0�D�G�%&�D�N�%*�D�N�+�� "�4��G�G�L�L��A�&�'+�D�O�%)�W�W�\�\�^�D�N�4�� ����B��D�G� �M�M�"� � �s��)H�K�* K�6H9�%H�<K�5I6�8 K�H�H�H6�3K�5H6�6K�97I3�0K�2I3�3K�6A K�K�K�K�'K.c��|Srrr�s r� __enter__zZipFile.__enter__�s��� rc�$�|j�yr�rr)r��type�value� tracebacks r�__exit__zZipFile.__exit__�s �� � � � rc���d|jj�d|jj��g}|j�t|jr|j d|jz�n*|j �|j d|j z�|j d|jz�n|j d�|j d�dj|�S) Nr�r�z file=%rz filename=%rz mode=%rr�r�r�) r�rrrGr r7rNr�r8r�s rr�zZipFile.__repr__�s���"�n�n�7�7�"�n�n�9�9�;�<�� �7�7� ����� � �j�4�7�7�2�3����*�� � �n�t�}�}�<�=� �M�M�*�t�y�y�0� 1� �M�M�+� &�� � �c���w�w�v��rc ���|j} t|�}|s td��|jdkDr t |�|t }|t}|t|_ |t|z |z }|jdkDr||z}t d|||�||z|_ |jdkr td��|j|jd�|j|�}tj|�}d}||k�r�|jt �} t#| �t k7r td��t%j&t(| �} | t*t,k7r td��|jdkDr t | �|j| t.�} t1| �} | t2} | t4zr| j7d �} n| j7|j8xsd �} t;| �} |j| t<�| _|j| t@�| _!| tD| _#| dd \ | _$| _%| _&| _'| _(| _)}}| _*| _+| _,| jLtZkDrt]d | jLd z z��| dd\| _/| _0| _1|| _2|dz dz|dz dz|dz|dz |dz dz|dzdzf| _3| ji| �| jF|z| _#|jjjm| �| |jn| jp<|t z| t.z| t<z| t@z}|jdkDr t d|�||kr���|j}tstu|jjd����D]}||_;|jF}�y#t$r td��wxYw)z/Read in the table of contents for the ZIP file.zFile is not a zip filer!r"zgiven, inferred, offsetrz Bad offset for central directoryzTruncated central directoryz&Bad magic number for central directoryr��cp437rzzip file version %.1fr)r,r/r(r�r%r�r*r �totalc��|jSr)r�)r�s r�z*ZipFile._RealGetContents..�s ��u�7J�7Jr)�keyN)� �&�M���#���;�'� ��|�,�� �� �&��0�9�<�� �:�:��>�� �)�H� �+�Y��&� I�"�V�+��� �>�>�A� ��?�@� @� �������"��w�w�w��� �Z�Z�� �����g�o��g�g�n�-�G��7�|�~�-� �!>�?�?��m�m�$4�g�>�G��}�%�)9�9� �!I�J�J��z�z�A�~��g���w�w�w�':�;�<�H� %�h�� ��M�*�E��)�)�#�?�?�7�3��$�?�?�4�+A�+A�+L�W�M����!�A��g�g�g�&<�=�>�A�G�����(:� ;�<�A�I�%�&=�>�A�O�5<�A�b�M� 2�Q� �q���0A�1�:� �[�!�/�1�a� �U�A�O�Q�[�� � �#6�6�)�*A�+,�+<�+<�r�+A�+C�D�D�9@��B�� 6�A�H�a�o�q���A�K���T�4�K�!�Q�$���Q�t�V��r�E�A�q�D�$�;��4��1� �?�A�K� �N�N�,� -��o�o��6�A�O� �M�M� � �� #�*+�D�O�O�A�J�J� '��^�+�g�6I�.J�J��5�6�7��1�2�3�E��z�z�A�~��g�u�%�[�g�o�^�^�^� ��f�T�]�]�)J�L�M�E� *�E� ��,�,�J�M��Q� 7��5�6� 6� 7�s � O�O,c�T�|jD�cgc]}|j��c}Scc}w)z+Return a list of file names in the archive.)r�rNr1s r�namelistzZipFile.namelists"��*.�-�-�8�-�$�� � �-�8�8��8s�%c��|jS)zJReturn a list of class ZipInfo instances for files in the archive.)r�r�s r�infolistzZipFile.infolist����}�}�rc��tddz|��|jD];}d|jddz}td|j||jfz|���=y)z+Print a table of contents for the zip file.z%-46s %19s %12s)z File Namez Modified �Size�rpz%d-%02d-%02d %02d:%02d:%02dNr&z %-46s %s %12d)r"r�r�rNr�)r�rpr��dates r�printdirzZipFile.printdir sZ�� ��"G�G�� ��]�]�E�0�5�?�?�2�A�3F�F�D� �/�U�^�^�T�5�?�?�$K�K�� �#rc��d}|jD]L} |j|jd�5}|j|�r |j|�r�ddd��Ny#1swY� xYw#t$r|jcYcSwxYw)z�Read all the files and check the CRC. Return None if all files could be read successfully, or the name of the offending file otherwise.ir�N)r�rMrNrJr)r�� chunk_sizer��fs r�testzipzZipFile.testzipsx�� � ��]�]�E� &��Y�Y�u�~�~�s�3�q��&�&��,���&�&��,�4�� #�4�3��� &��~�~�%� &�s(�A+�$A�A+�A( �$A+�+B�Bc�\�|jj|�}|�td|z��|S)z,Return the instance of ZipInfo given 'name'.z(There is no item named %r in the archive)r�r��KeyError)r�r��infos r�getinfozZipFile.getinfo#s9�����"�"�4�(�� �<��:�T�A�C� C�� rc��|r1t|t�s!tdt|�jz��|r||_yd|_y)z)Set default password for encrypted files.�pwd: expected bytes, got %sN)r�rr�rrr)r�rs r� setpasswordzZipFile.setpassword,s:�� �z�#�u�-��9�D��I�zr t=d��|t@tBzr|jEd�} n|jE�jFxsd�} | |jHk7rt'd|jH�d|�d���|jJ��|jM�|jNz|jJkDrz|jJ|jk(rHddl(} | jSd|jH�d�tTjVjYtZ�f��nt'd|jH�d���|j8t\z} | rQ|s �j^}|r1t|t`�s!tcdte|�jfz��|stid|z��d}tk||||d�S#|jm��xYw)auReturn file-like object for 'name'. name is a string for the file name within the ZIP file, or a ZipInfo object. mode should be 'r' to read a file already in the ZIP file, or 'w' to write to a file newly added to the archive. pwd is the password to decrypt files (only used for reading). When writing, if the file size is not known in advance but may exceed 2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large files. If the size is known in advance, it is best to pass a ZipInfo instance for name, with zinfo.file_size set. >r�r�zopen() requires mode "r" or "w"r�z'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedrSrzr!c����jSr)rnr�s�rr zZipFile.open..|s ���$�-�-rzTruncated file headerz Bad magic number for file header)rxz$compressed patched data (flag bit 5)zstrong encryption (flag bit 6)r�rzFile name in directory z and header z differ.NrzOverlapped entries: z (possible zip bomb))�skip_file_prefixesrNz6File %r is encrypted, password required for extractionT)7r�rGr�r rXr�r`r�rL�_open_to_writernr rhr�rrmrJ�sizeFileHeaderr6rrSr5r�� _FH_SIGNATUREr��_FH_FILENAME_LENGTH�_FH_EXTRA_FIELD_LENGTHrRr��_MASK_COMPRESSED_PATCHrW�_MASK_STRONG_ENCRYPTION�_FH_GENERAL_PURPOSE_FLAG_BITSr�r�r�r�r�rwr�r�r�r�r��dirname�__file__�_MASK_ENCRYPTEDrrr�rrrUr�rr) r�r�r�rrTr��zef_file�fheader�fname� fname_strr�� is_encrypteds ` rrMz ZipFile.openMsd��� �z� !��>�?� ?� �D�C�K��F�G� G��w�w��D�F� F� �d�G� $��E� �S�[��D�M�E�"&�"2�"2�E� �#'�#5�#5�E� ��L�L��&�E� �3�;��&�&�u�+�&�F� F� �=�=��F�G� G� ���A����t�w�w��(;�(;�#�}�}�d�j�j�:O�Q��= ��m�m�N�3�G��7�|�~�-� �!8�9�9��m�m�$4�g�>�G��}�%�)9�9� �!C�D�D��M�M�'�*=�">�?�E��-�.�� � �g�&<�=�a� �H����!7�7�)�*P�Q�Q����!8�8�)�*J�K�K��4�5�8J�J�!�L�L��1� �!�L�L��)?�)?�)J�7�K� ��E�/�/�/� ��*�*�E�3�4�4��!�!�-�� � ��%�"5�"5�5��8I�8I�I��$�$��(;�(;�;�#��M�M�.�u�/B�/B�.E�F.�/�,.�G�G�O�O�H�,E�+G�"�I� %�.�u�/B�/B�.E�F.�/�0�0� !�?�?�_�<�L����(�(�C��z�#�u�5�#�$A�D��I�DV�DV�$V�W�W��&�(A�CG�(H�I�I����h��e�S�$�?� ?�� � �N�N� � �s �I0N�Nc��|r|js td��|jr td��d|_d|_d|_|j tk(r|xj tzc_|js|xj tzc_|jsd|_ |xs|jdztkD}|js |r td��|jr%|jj!|j"�|jj%�|_|j)|�d|_|jj-|j/|��d|_t1|||�S)NzHforce_zip64 is True, but allowZip64 was False when opening the ZIP file.zzCan't write to the ZIP file while there is another write handle open on it. Close the first handle before opening another.r��g�������?z'Filesize would require ZIP64 extensionsT)rr�rnr�r�r�r�r �_MASK_COMPRESS_OPTION_1r�r�r�r�r�rrGrRr�rwr�� _writecheckrr�r�r�)r�r�rTr�s rrXzZipFile._open_to_write�s=�� �t�/�/�� �� � �=�=��N�O� O�  ����� ���� � � �(� *� �O�O�6� 6�O��~�~� �O�O�8� 8�O��"�"�"-�E� ��E����$� 6�� D�����E��H�I� I� �>�>� �G�G�L�L���� (�"�g�g�l�l�n��� �������� ��� � �e�&�&�u�-�.��� ��T�5�%�0�0rc��|�tj�}ntj|�}|j|||�S)alExtract 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 ZipInfo object. You can specify a different directory using `path'. You can specify the password to decrypt the file using 'pwd'. )r��getcwdr��_extract_member)r��memberr�rs r�extractzZipFile.extract�s6�� �<��9�9�;�D��9�9�T�?�D��#�#�F�D�#�6�6rc��|�|j�}|�tj�}ntj|�}|D]}|j |||��y)a?Extract all members from the archive to the current working directory. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by namelist(). You can specify the password to decrypt all files using 'pwd'. N)r<r�rmr�rn)r�r��membersrr�s r� extractallzZipFile.extractall�sM�� �?��m�m�o�G� �<��9�9�;�D��9�9�T�?�D��G� � � ��$�� 4�rc���|j}|s+d}tj|dt|�z�}||_|j |�}d�|j |�D�}|j d�|D��}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*�_c3�>K�|]}|jd����y�w)z .N)�rstrip��.0r�s r� z1ZipFile._sanitize_windows_name..s����B�+A�a�1�8�8�D�>�+A�s�c3�&K�|] }|s�|��� y�wrrrxs rrzz1ZipFile._sanitize_windows_name..s����7�'�Q�Q�q�'�s��)�!_windows_illegal_name_trans_tabler � maketransr6� translate�splitr8)r�r��pathsep�table�illegals r�_sanitize_windows_namezZipFile._sanitize_windows_namest���5�5����G��M�M�'�3��W��+=�>�E�49�C� 1��#�#�E�*��B�7�=�=��+A�B���,�,�7�'�7�7���rc�� �t|t�s|j|�}|j}tj j dk7r*|jdtj j �}tj jr_tj jdk7rB|jtj jtj j �}tj j|�\}}}|jr|s|ry|jrDtj j|jtj j �vrydtj jtj jf� tj j j� fd�|jtj j �D��}tj j dk(r>|j|tj j �}|jr||k7ry|}|s(|j!�s|jryt#d��tj j||�}tj j%|�}tj j'|�}|r4tj j)|�st j*|�|j!�r6tj j-|�st j.|�|S|j1||��5} t1|d�5} t3j4| | �ddd�ddd�|S#1swY�xYw#1swY|SxYw) zbExtract the ZipInfo object 'member' to a physical file on the path targetpath. r�Nr�c3�*�K�|] }|�vr|��� y�wrr)ryr��invalid_path_partss �rrzz*ZipFile._extract_member..+s#�����#C�.H��&'�/A�&A�$%�.H�s��\zEmpty filename.)rr)r�r rLrNr�r�r�r�r�� splitroot�_ignore_invalid_names�pardirr�curdirr8r�r�r�r�r`�exists�makedirsr��mkdirrM�shutil� copyfileobj) r�ro� targetpathrr��drive�root�arcname2� upperdirs�source�targetr�s @rrnzZipFile._extract_membersy����&�'�*��\�\�&�)�F��/�/�� �7�7�;�;�#� ��o�o�c�2�7�7�;�;�7�G� �7�7�>�>�b�g�g�n�n��3��o�o�b�g�g�n�n�b�g�g�k�k�B�G� "�w�w�0�0��9���t�W� � %� %�5�D�� � %� %�"�'�'�.�.�G�M�M�"�'�'�+�+��>�T�_�_� ,� � �M�M�.����?�A�M� N� �9�9�O� +��E�F� F��w�w��F�H� H��5�.�.�/����!�N��4�=�=�!�%8�8�!.�����;�.�!+���$�$�{�2�!/���"�>�#D�$E�F�F�� rc�.�|js td��|jr td��tj |||j ��}|j �r d|_d|_|j|�y|�||_ n|j|_ |�||_ n|j|_ t|d�5}|j|d�5}tj ||d�ddd�ddd�y#1swY�xYw#1swYyxYw) zLPut the bytes from filename into the archive under the name arcname.�7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsr�rNrKr�i )rGr�rnr r�r r�r�r�r�r�rXr�r`rMr�r�)r�rNr�r�r`r��src�dests rr�z ZipFile.writecs����w�w��I�K� K� �=�=��P�� ��!�!�(�G�48�4K�4K�"�M�� �<�<�>�"#�E� ��E�I� �J�J�u� ��(�&3��#�&*�&6�&6��#��(�'4��$�'+�'9�'9��$��h��%��d�i�i��s�.C�t��"�"�3��f�5�/D�%�%�.C�.C��%�%�s$�D �C?�.D �?D �D � Dc���t|t�r|jd�}t|t�s�t|t j t j��dd��}|j |_|j|_ |jjd�rd|_ |xjdzc_ n d|_ n|}|js td ��|jr td ��|�||_|�||_ t!|�|_|j$5|j'|d � �5}|j)|�ddd�ddd�y#1swY�xYw#1swYyxYw) aWrite a file into the archive. The contents is 'data', which may be either a 'str' or a 'bytes' instance; if it is a 'str', it is encoded as UTF-8 first. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.r�Nr&)rNr�r�i�Ar-rir�z?Can't write to ZIP archive while an open writing handle exists.r�)r�)r�r r�r r�r�rXr�r`r�rNr�r�rGr�rnr6r�rmrMr�)r��zinfo_or_arcnamerer�r`r�r�s r�writestrzZipFile.writestr�s;�� �d�C� ��;�;�w�'�D��*�G�4��%5�&*�n�n�T�Y�Y�[�&A�"�1�&E�G�E�"&�"2�"2�E� �#'�#5�#5�E� ��~�~�&�&�s�+�&3��#��#�#�t�+�#�&1��#�$�E��w�w��I�K� K� �=�=��Q�� � � $�"/�E� � � $�#0�E� ��d�)��� �Z�Z����5�s��+�t�� � �4� �,��Z�+�+���Z�s$�'E*�;E� E*�E' �#E*�*E3c��t|t�r|}|j�s�td��t|t�r^|}|j d�s|dz }t|�}d|_d|_d|zdzdz|_d|_ |xjdzc_n td��|j5|jr%|jj|j�|jj!�|_|j$t&k(r|xj(t*zc_|j-|�d|_|j0j3|�||j4|j6<|jj9|j;d ��|jj!�|_d d d �y #1swYy xYw) z+Creates a directory inside the zip archive.z/The given ZipInfo does not describe a directoryr�ri@rr-zExpected type str or ZipInfoTFN)r�r r�r�r r�r�r�r�r�r�rmr�rGrRr�rwr�r�r r�rjrkrr�r7r�rNr�r�)r��zinfo_or_directory_namer�r��directory_names rr�z ZipFile.mkdir�sb�� �-�w� 7�+�E��<�<�>� �!R�S�S� �/�� 5�4�N�!�*�*�3�/��#�%���N�+�E�"#�E� ��E�I�$+�d�N�f�#<��"C�E� ��E�O� � � �4� '� ��:�;� ;� �Z�Z��~�~���� � �T�^�^�,�"&�'�'�,�,�.�E� ��"�"�h�.����#:�:�� � � �U� #�"�D�O� �M�M� � �� '�.3�D�O�O�E�N�N� +� �G�G�M�M�%�*�*�5�1� 2�!�W�W�\�\�^�D�N��Z�Z�s �3DG�Gc�$�|j�y)z2Call the "close()" method in case the user forgot.Nrr�s r�__del__zZipFile.__del__�s �� � � � rc���|j�y|jr td�� |jdvrb|jrV|j 5|j r%|jj|j�|j�ddd�|j}d|_|j|�y#1swY�.xYw#|j}d|_|j|�wxYw)zOClose the file, and for mode 'w', 'x' and 'a' write the ending records.NzvCan't close the ZIP file while there is an open writing handle on it. Close the writing handle before closing the zip.r�) rGrnr�r�rrmr�rRr��_write_end_recordrr�s rrrz ZipFile.close�s��� �7�7�?� � �=�=��P�Q� Q� ��y�y�O�+�����Z�Z��~�~���� � �T�^�^�4��*�*�,� � ���B��D�G� �M�M�"� � �Z�� ���B��D�G� �M�M�"� �s$�&C� AB;�C�;C�C�&C-c�� �|jD�]�}|j}|ddz dz|ddzz|dz}|ddz|d dzz|ddzz}g}|jtkDs|jtkDr;|j |j�|j |j�d }d }n|j}|j}|j tkDr|j |j �d }n |j }|j} d} |rHt| d �} tjd d t|�zzddt|�zg|���| z} t} |jtk(rtt | �} n#|jt"k(rtt$| �} t| |j&�} t| |j(�} |j+�\} }tjt,t.| |j0| |j2||j|||j4||t| �t| �t|j6�d|j8|j:|�}|j<j?|�|j<j?| �|j<j?| �|j<j?|j6����|j<jA�}t|j�}||jBz }|jB}d}|tDkDrd}n|tkDrd}n |tkDrd}|r�|jFstI|dz��tjtJtLtNdz dddd||||� }|j<j?|�tjtPtRd|d�}|j<j?|�tU|d�}tU|d �}tU|d �}tjtVtXdd||||t|jZ�� }|j<j?|�|j<j?|jZ�|j\dk(r|j<j_�|j<ja�y)Nrr�r(r!r%r"r#r*r$r�r�r2�Qrr�zCentral directory offsetzCentral directory sizer�rrrr�)1r�r�r�r�r�r7r�r9rBrSr�r6r�r�rr|r�r r�r�rlr�r&r(r�r�r�r�r�r�rGr�rwr�r�rrrYrXrVrTrUr�rzryrr��truncater3)r�r�r�r�r�r9r�r�r�� extra_datar�r�rlrNr�r5�pos2� centDirCount� centDirSize� centDirOffsetr�� zip64endrec� zip64locrecrds rr�zZipFile._write_end_record�s ���]�]�E����B��!�u�t�|��)�B�q�E�Q�J�6��A��>�G���e�r�k�B�q�E�Q�J�.�"�Q�%�1�*�=�G��E�����,��%�%� �3�� � �U�_�_�-�� � �U�0�0�1�&� � *� �!�O�O� � %� 3� 3� ��"�"�[�0�� � �U�0�0�1� *� � %� 3� 3� ����J��K��)�*�d�;� �#�[�[��C��E� �N�*��q��U��|�-�&+�-�/9�:� �,� ��"�"�i�/�!�-��=� ��$�$��0�!�,� �<� �!�+�u�/D�/D�E�O� ��e�.B�.B�C�N�"'�"<�"<�">� �H�i��k�k�"2�"2�N�"'�"5�"5�����"+�U�-@�-@�'�7�"'�)�)�]�I�"%�h�-��Z��#�e�m�m�BT�"#�U�%8�%8�%�:M�:M�"/�1�G� �G�G�M�M�'� "� �G�G�M�M�(� #� �G�G�M�M�*� %� �G�G�M�M�%�-�-� (�g#�j�w�w�|�|�~���4�=�=�)� ��T�^�^�+� ���� ��� �-� -�*�N� �[� (�7�N� �;� &�5�N� ��#�#�"�>�#D�$E�F�F� �+�+�"�$6� �2�%�r�2�q�!�\�<��]�,�K� �G�G�M�M�+� &� �+�+�)�)�1�d�A�7�K� �G�G�M�M�+� &��|�V�4�L��k�:�6�K�� �z�:�M����-�/?���<��(�-��T�]�]�9K�M�� ��� � �f�� ��� � �d�m�m�$� �9�9�� � �G�G� � � � ��� � �rc��|xjdzc_|js|js|j�yyy)Nr!)r r rrr�s rrzZipFile._fpcloseHs5�� ���A�������(8�(8� �H�H�J�)9�rr)r�N)F)NN)NNN)i�)&rrrrrGr|r�rr�rrr�rr<r>rDrHrLrOrCr��setterrJrMrXrprsrr�rnrkr�r�r�r�rrr�rrrrr r s���, �B�(,�%�!��"%�:�$�#�^�:>�RV�^�@�� �P-�d9�� �&� ������ �^�^� �� �� m�E�m�^(1�T 7�5�$� �� �5�nF�.'+�04�6�D48�'!�R!,�F��,\�|rr c�.�eZdZdZdeddfd�Zd d�Zd�Zy) r zDClass to create ZIP archives with Python library files and packages.r�TrBc�F�tj|||||��||_y)N)r�rXr)r r�� _optimize)r�rpr�rXr�optimizes rr�zPyZipFile.__init__Rs'������t�$�K�$.� � 0�!��rNc���tj|�}|rI||�sA|jr4tjj |�rdnd}t |�d|�d��ytjj |�\}}tjj |��r�tjj|d�}tjj|��r�|r|�d|��}n|}|jrt d|d |�|j|d d |�\}} |jr t d | �|j|| �ttj|��} | jd�| D�]$} tjj|| �} tjj| �\} }tjj | �rStjjtjj| d��s��|j| ||� ���|dk(s��|r#|| �s|jrt d| z���|j| d d |�\}} |jr t d | �|j|| ���'y|jr t d|�ttj|��D]�} tjj|| �} tjj| �\} }|dk(s�K|r#|| �s|jrt d| z��p|j| d d |�\}} |jr t d | �|j|| ���y|d ddk7r t!d��|j|d d |�\}} |jr t d| �|j|| �y)a�Add all files from "pathname" to the ZIP archive. If pathname is a package directory, search the directory and all package subdirectories recursively for all *.py and enter the modules into the archive. If pathname is a plain directory, listdir *.py and enter all modules. Else, pathname must be a Python *.py file and the module will be put into the archive. Added modules are always module.pyc. This method will compile the module.py into module.pyc if necessary. If filterfunc(pathname) is given, it is called with every argument. When it is False, the file or directory is skipped. r�rp� z skipped by filterfuncNz __init__.pyr�zAdding package in�asr������Adding)� filterfunc�.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"z Adding file)r�r�rr�r�r"rr8�isfile� _get_codenamer�r0�listdir�remove�splitext�writepyrU)r��pathname�basenamer��label�dirr��initnamerer��dirlistrNr�r��exts rr�zPyZipFile.writepyXs���9�9�X�&�� �j��2��z�z�"$�'�'�-�-��"9��v���u�h�G�H� ��G�G�M�M�(�+� ��T� �7�7�=�=�� "��w�w�|�|�H�m�<�H��w�w�~�~�h�'��*2�D�9�H�#�H��:�:��-�x��x�H�!%�!3�!3�H�Q�r�N�H�!M���w��:�:��(�G�,�� � �5�'�*� ����H�!5�6�����}�-� '�H��7�7�<�<��(�;�D� "��� 0� 0�� :�I�D�#��w�w�}�}�T�*��7�7�>�>�"�'�'�,�,�t�]�*K�L� �L�L��x�4>�)�@����%�j��.>�#�z�z� %�&E��&L� M�$�)-�);�);�D��2�J��#�z�z� %�&E��&L� M�$�)-�);�);�D��2�J�._compile�s\��� ��z�z��k�4�(� ��"�"�4���"�I����,�,� ��c�g�g���� �s�4�A"�A�A"r�z.pycr�)� optimizationr!r"rz"invalid value for 'optimize': {!r})r�r�rA)� importlib�util�cache_from_sourcer�r�r�r�r�r�r�r7r��formatr�r) r�r�r�r��file_py�file_pyc� pycache_opt0� pycache_opt1� pycache_opt2r�rer�� archivenames ` rr�zPyZipFile._get_codename�s���� ��e�#���f�$�� �~�~�7�7��b�7�Q� � �~�~�7�7��a�7�P� � �~�~�7�7��a�7�P� � �>�>�R� ������x�(��'�'�(�#�,�,�����0@�0I�0I�I�"*�*��%��'�'�.�.��.��'�'�,�'�0�0�B�G�G�G�4D�4M�4M�M�%��"���'�'�.�.��.��'�'�,�'�0�0�B�G�G�G�4D�4M�4M�M�%��"���'�'�.�.��.��'�'�,�'�0�0�B�G�G�G�4D�4M�4M�M�%��"���G�$��y�y�)�)�Q�.� ,�����+�+�q�0� ,�� ,��&�G�&-�-�E�G��~�~��"�$��"��"���>�>�Q�&�(�E��^�^�q�(�(�E�>�E�E�d�n�n�U�C�$�S�/�)��G�G�N�N�5�)��G�G�E�N�+�+�r�w�w�w�/?�/H�/H�H���$�.�.�A�&-�-�E�G��g�g�m�m�G�,�Q�/� � �%-�{�;�K��{�#�#r)r�N)rrrrrr�r�r�rrrr r Os!��N�"%�:� �2�"� P'�dP$rr c����ddl}d}|j|��}|jd��}|jdddd � �|jd d d dd��|jddddd��|jdddd� �|jddd� �|j |�}|j }|j �[|j }t|d|��5}|j�}ddd�rtdj|��td�y|j�4|j}t|d|��5}|j�ddd�y|j�8|j\}} t|d|��5}|j| �ddd�y|j��|r0td t j"�!�t!j$d"�|jj'd�} |j} �fd#��t| d$�5}| D]�} t(j*j-| �} | szShow listing of a zipfile)�metavar�helpz-ez --extractr")r�z zExtract zipfile into target dir)�nargsr�r�z-cz--create�+)zzzCreate zipfile from sourcesz-tz--testzTest if a zipfile is validz--metadata-encodingz z2Specify encoding of member names for -l, -e and -tr�)r�z.The following enclosed file is corrupted: {!r}z Done testingz/Non-conforming encodings not supported with -c.rBr!c ���tjj|�r|j||t�ytjj |�r~|r|j||�t tj|��D]H}�|tjj||�tjj||���Jyyr) r�r�r�r�rr�r0r�r8)r�r��zippath�nm�addToZips �rr�zmain..addToZip. s�����w�w�~�~�d�#�����w� �5������t�$���H�H�T�7�+� ����D�!1�2�B��R��W�W�\�\�$��3�R�W�W�\�\�'�2�5N�P�3�%rr�r�)�argparse�ArgumentParser�add_mutually_exclusive_group� add_argument� parse_argsr��testr rHr"r�r{rDrprs�creater��stderr�exit�popr�r�r�r`r�r�)�argsr�r��parser�group�encodingr�r��badfiler��zip_name�filesr�r�r�s @r�mainr�s�����G�K� � $� $�� $� =�F� � /� /�� /� >�E� ���t�X�{�7��9� ���t�[��<�=��?� ���t�Z�s�3�9��;� ���t�X�{�8��:� ���-�|�Q��S� � � �T� "�D��%�%�H� �y�y���i�i�� �S�#�� :�b��j�j�l�G�;� � �B�I�I�'�R� S� �n�� ��� ��i�i�� �S�#�� :�b� �K�K�M�;� :� ��� !��l�l� ��V� �S�#�� :�b� �M�M�&� !�;� :� ��� � � �C��z�z� #� �H�H�Q�K��;�;�?�?�1�%��� � �� P��X�s� #�r����'�'�*�*�4�0��� �g�g�.�.�r�w�w���t�/D�E�G��r�2�9�9�b�i�i�8�8� �G���T�7�+� �$� #�) !�!;� :��;� :�� ;� :��.$� #�s1�J4�K�K �BK�4J>�K � K�K")r� CompleteDirsr)�r�binascii�importlib.utilr�r�r�r�r�rSr�r r�rTr� ImportErrorrVr(�__all__� Exceptionrrrrr�r�r}rrrr r�r�r�r�r.rzryr�rxrZr[r\r]r^r_r`rr#rar&r(r%r'�_CD_CREATE_VERSION�_CD_CREATE_SYSTEM�_CD_EXTRACT_VERSION�_CD_EXTRACT_SYSTEMr*�_CD_COMPRESS_TYPE�_CD_TIME�_CD_DATE�_CD_CRC�_CD_COMPRESSED_SIZE�_CD_UNCOMPRESSED_SIZEr)r+r,�_CD_DISK_NUMBER_START�_CD_INTERNAL_FILE_ATTRIBUTES�_CD_EXTERNAL_FILE_ATTRIBUTESr-rbrjr�r]r^r�r�r�rYrZ�_FH_EXTRACT_VERSION�_FH_EXTRACT_SYSTEMr_�_FH_COMPRESSION_METHOD�_FH_LAST_MOD_TIME�_FH_LAST_MOD_DATE�_FH_CRC�_FH_COMPRESSED_SIZE�_FH_UNCOMPRESSED_SIZEr[r\rTrUrQrYrXrV�_CD64_SIGNATURE�_CD64_DIRECTORY_RECSIZE�_CD64_CREATE_VERSION�_CD64_EXTRACT_VERSION�_CD64_DISK_NUMBER�_CD64_DISK_NUMBER_START�_CD64_NUMBER_ENTRIES_THIS_DISK�_CD64_NUMBER_ENTRIES_TOTAL�_CD64_DIRECTORY_SIZE�_CD64_OFFSET_START_CENTDIRr��Structr4rBrHr rtrDr��objectr rrrr!r5r�rYrarfrhr�r�r�r�r r r�_pathrrrrr�r,s���� �� � � � � � �� ��� �J�J�E� ���� ��  �� ��9��  ��� �� �#����� �� � � � ����� �� �� ����� �� ����!1�2������������ � �� ���� �� �$�� �� ����!1�2��� ���������� ��� �� �� ��������������!��!������ �� #�� �� �� ��"�� �� ����!1�2��� ����� !�������� ����������%��)��)�&�/�/�*C�D��"��"��"�6�?�?�#5�6��������������!"��������� �#�f�m�m�E�*���*�� 9�x9�v�&i�v�i�` � �� #�L"�"�."�"�J��w���x���x���x� � �x� � �x� ��y���z���y���{��� �������������� � �!�"��#��(N�& � P�$(!�(!�V��(f��"�"�f�R P+�B�%�%�P+�hl �l �^k$��k$�\C,�L���_I�� �D� �N�N�E��� �� �C��� �� �D��s4�I �I$�I2� I!� I!�$I/�.I/�2I=�<I=