� ��^i�"� �.�dZddlZddlZddlZddlZddlZddlZddlmZm Z m Z ddlm Z ddl m Z ddlmZmZmZmZddlmZeje��ZeezZ ddlZeez Zn #e$re�d��YnwxYw ddlZeez Zn #e$re�d ��YnwxYwd efd �Zd ed e efd �Z deed e!fd�Z"deded e!fd�Z#d ed dfd�Z$de d e!fd�Z%ddedede!d dfd�Z&deded dfd�Z' ddedede ed dfd�Z(dS) zUtilities related archives. �N)�Iterable�List�Optional)�ZipInfo)�InstallationError)�BZ2_EXTENSIONS�TAR_EXTENSIONS� XZ_EXTENSIONS�ZIP_EXTENSIONS)� ensure_dirzbz2 module is not availablezlzma module is not available�returnc�V�tjd��}tj|��|S)zBGet the current umask which involves having to set it temporarily.r)�os�umask)�masks ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/utils/unpacking.py� current_umaskr+s!�� �8�A�;�;�D��H�T�N�N�N� �K��pathc�*�|�d���d��}d|vrJd|vr,|�d��|�d��ksd|vr|�dd��Sd|vr|�dd��S|dgS)N�/�\��)�lstrip�find�split�rs r�split_leading_dirr2s��� �;�;�s� � � "� "�4� (� (�D� �d�{�{� ����$�)�)�C�.�.�4�9�9�T�?�?�:�:�t�4�?O�?O��z�z�#�q�!�!�!� �����z�z�$��"�"�"��b�z�r�pathsc�^�d}|D]'}t|��\}}|sdS|�|}�||krdS�(dS)zyReturns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)NFT)r)r � common_prefixr�prefix�rests r�has_leading_dirr%>sa���M�����(��.�.� ���� ��5�5� � "�"�M�M� �}� $� $��5�5�%� �4r� directory�targetc���tj�|��}tj�|��}tj�||g��}||kS)zL Return true if the absolute path of target is within the directory )rr�abspath� commonprefix)r&r'� abs_directory� abs_targetr#s r�is_within_directoryr-MsO���G�O�O�I�.�.�M������(�(�J� �W� !� !�=�*�"=� >� >�F� �]� "�"rc�V�tj|dt��zdz��dS)zx Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs i��IN)r�chmodrrs r�2set_extracted_file_to_default_mode_plus_executabler1Xs-�� �H�T�E�]�_�_�,�,�u�4�6�6�6�6�6r�infoc�f�|jdz }t|otj|��o|dz��S)N�r/)� external_attr�bool�stat�S_ISREG)r2�modes r�zip_item_is_executabler:`s7�� � �� #�D� ��<���d�+�+�<��u� � =� =�=rT�filename�location�flattenc�|�t|��t|d��} tj|d���}t |�����o|}|���D�]�}|j}|}|rt|��d}tj � ||��}tj � |��} t||��s&d} t| �|||�����|�d��s|�d��rt|����t| ��|�|��} t|d��5} t#j| | ��d d d ��n #1swxYwY| ���t)|��rt+|����h#| ���t)|��rt+|��wwxYw |���d S#|���wxYw) a� Unzip the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. �rbT)� allowZip64rzQThe zip file ({}) has a file ({}) trying to install outside target directory ({})rr�wbN)r �open�zipfile�ZipFiler%�namelist�infolistr;rrr�join�dirnamer-r�format�endswith�shutil� copyfileobj�closer:r1) r;r<r=�zipfp�zip�leadingr2�name�fn�dir�message�fp�destfps r� unzip_filerWgsX���x���� ��4� � �E� ��o�e��5�5�5��!�#�,�,�.�.�1�1�=�g���L�L�N�N� O� O�D��=�D��B�� 0�&�t�,�,�Q�/������h��+�+�B��'�/�/�"�%�%�C�&�x��4�4� P�4��(����x��X�(N�(N�O�O�O��{�{�3��� O�2�;�;�t�#4�#4� O��2������3�����X�X�d�^�^��O��b�$���7�6��*�2�v�6�6�6�7�7�7�7�7�7�7�7�7�7�7����7�7�7�7��H�H�J�J�J�-�d�3�3�O�J�2�N�N�N����H�H�J�J�J�-�d�3�3�O�J�2�N�N�N�N�O����5 O�: � � � � � � � ��� � � � � � ���sH�EH%�%G�5F� G�F �G�F �G�"4H%�5H � H%�%H;c�.�t|��|����d��s'|����d��rd}n�|����t��rd}nv|����t��rd}nG|����d��rd}nt �d|��d }tj||d � ��} td �|� ��D����}|� ��D�]}|j }|rt|��d }tj�||��}t!||��s&d}t#|�|||�����|���rt|����|���rQ |�||����#t,$r,} t �d||j | ��Yd} ~ ��d} ~ wwxYw |�|��} nA#t0t2f$r-} t �d||j | ��Yd} ~ ��Pd} ~ wwxYwttj�|����| �J�t|d��5} t7j| | ��ddd��n #1swxYwY| ���|�||��|jdzrtA|���� |���dS#|���wxYw)a� Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. z.gzz.tgzzr:gzzr:bz2zr:xzz.tar�rz-Cannot determine compression type for file %szr:*zutf-8)�encodingc��g|] }|j�� S�)rQ)�.0�members r� zuntar_file..�s��"N�"N�"N�6�6�;�"N�"N�"NrrzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNrAr/)!r �lowerrJrr �logger�warning�tarfilerBr%� getmembersrQrrrrGr-rrI�isdir�issym�_extract_member� Exception� extractfile�KeyError�AttributeErrorrHrKrLrM�utimer9r1) r;r<r9�tarrPr^rRrrT�excrUrVs r� untar_filero�s����x�����~�~��� � ��'�'� �8�>�>�+;�+;�+D�+D�V�+L�+L� ���� ��� � � "� "�>� 2� 2� ���� ��� � � "� "�=� 1� 1� ���� ��� � � "� "�6� *� *�������� ;� � � � ��� �,�x��� 8� 8� 8�C�5�!�"N�"N�S�^�^�=M�=M�"N�"N�"N�O�O���n�n�&�&�1 M�1 M�F���B�� .�&�r�*�*�1�-���7�<�<��"�-�-�D�&�x��6�6� R�4��(����x��x�(P�(P�Q�Q�Q��|�|�~�~�& M��4� � � � ������$ M� ��'�'���5�5�5�5�� � � � ��N�N�I� �� �� ��� �H�H�H�H����� ���� �����0�0�B�B�� �.�1� � � ��N�N�I� �� �� ��� �H�H�H�H����� �����2�7�?�?�4�0�0�1�1�1��~�~�~��$��%�%�3���&�r�6�2�2�2�3�3�3�3�3�3�3�3�3�3�3����3�3�3�3���� � � �� � �&�$�'�'�'��;��&�M�F�t�L�L�L��c1 M�f � � � � � � � ��� � � � � � ���s��C.M>� H$�#M>�$ I�."I�M>�I�M>�I4�3M>�4J2�"J-�'M>�-J2�2AM>�5L� M>�L �M>�L �AM>�>N� content_typec�J�tj�|��}|dks@|����t ��st j|��r(t|||�d�� ���dS|dksPtj |��s<|����ttztz��rt||��dSt�d|||��t#d|�����)Nzapplication/zipz.whl)r=zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )rr�realpathr`rJr rC� is_zipfilerWrc� is_tarfiler rr rora�criticalr)r;r<rps r� unpack_filerv�s&�� �w����)�)�H��)�)�)� �>�>� � � $� $�^� 4� 4� *� � �h� '� '� *� �8�X�8�3D�3D�V�3L�3L�/L�M�M�M�M�M�M��,�,�,� � �h� '� '� -� �>�>� � � $� $�^�n�%D�}�%T� U� U� -� �8�X�&�&�&�&�&� ��� +� � � �  � � � � P�h� P� P�Q�Q�Qr)T)N))�__doc__�loggingrrKr7rcrC�typingrrrr�pip._internal.exceptionsr�pip._internal.utils.filetypesrr r r �pip._internal.utils.miscr � getLogger�__name__ra�SUPPORTED_EXTENSIONS�bz2� ImportError�debug�lzma�intr�strrr6r%r-r1r:rWrorvr\rr�r�s.�������� � � � � � � � � � � � ���������+�+�+�+�+�+�+�+�+�+�������6�6�6�6�6�6������������� 0�/�/�/�/�/� �� �8� $� $��&��6��0��J�J�J��N�*�����0�0�0� �L�L�.�/�/�/�/�/�0����1��K�K�K��M�)�����1�1�1� �L�L�/�0�0�0�0�0�1�����s����� �C� �D��I� � � � � �8�C�=� �T� � � � �#�3�#��#��#�#�#�#�7�S�7�T�7�7�7�7�>��>�T�>�>�>�>�+�+��+��+�d�+�d�+�+�+�+�\N��N��N��N�N�N�N�h#'�R�R��R��R��3�-�R� � R�R�R�R�R�Rs$� A#�#B�?B� B�B+�*B+