Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pip/_internal/utils/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pip/_internal/utils/__pycache__/filesystem.cpython-312.pyc

�

4ΜgV�
��ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZddlmZddlmZddlmZded	efd
�Zedede
d	eeddffd��Zed
d��ej4�Zded	efd�Zded	efd�Zdeded	e
efd�Zded	eeeffd�Z ded	efd�Z!ded	eeeffd�Z"ded	efd�Z#y)�N)�contextmanager)�NamedTemporaryFile)�Any�BinaryIO�	Generator�List�Union�cast)�get_path_uid)�format_size)�retry�path�returnc���tjdk(sttd�sytjj|�sJ�d}||k7r�tjj
|�rLtj�dk(r	t|�}|dk(Stj|tj�S|tjj|�}}||k7r��y#t$rYywxYw)N�win32�geteuidTrF)
�sys�platform�hasattr�osr�isabs�lexistsrr�OSError�access�W_OK�dirname)r�previous�path_uids   �I/usr/local/lib/python3.12/site-packages/pip/_internal/utils/filesystem.py�check_path_ownerr s����|�|�w��g�b�)�&<��
�7�7�=�=������H�
�(�
�
�7�7�?�?�4� ��z�z�|�q� �!�+�D�1�H� �1�}�$��y�y��r�w�w�/�/�!�2�7�7�?�?�4�#8�d�H��(�
����!� �!�s�C � 	C,�+C,�kwargsc+��K�tddtjj|�tjj	|�dd�|��5}tt|�}	|��|j�tj|j��	ddd�y#|j�tj|j��wxYw#1swYyxYw�w)a%Return a file-like object pointing to a tmp file next to path.

    The file is created securely and is ensured to be written to disk
    after the context reaches its end.

    kwargs will be passed to tempfile.NamedTemporaryFile to control
    the way the temporary file will be opened.
    Fz.tmp)�delete�dir�prefix�suffixN�)
rrrr�basenamer
r�flush�fsync�fileno)rr!�f�results    r�adjacent_tmp_filer.*s�����
�
���G�G�O�O�D�!��w�w����%��	
�
�
�
��h��"��	&��L��L�L�N��H�H�V�]�]�_�%�
�
��
�L�L�N��H�H�V�]�]�_�%��
�
�s6�AC$�
C�B �#3C�	C$� 5C�C�C!�C$�g�?)�stop_after_delay�waitc�R�tjj|�sGtjj|�}||k(rn"|}tjj|�s�Gtjdk(r$tj
|tj�St|�S)zgCheck if a directory is writable.

    Uses os.access() on POSIX, tries creating files on Windows.
    �posix)rr�isdirr�namerr�_test_writable_dir_win)r�parents  r�test_writable_dirr8Hsu���g�g�m�m�D�!�������&���T�>����	�g�g�m�m�D�!�
�w�w�'���y�y��r�w�w�'�'�!�$�'�'�c����d}d�td�D]�}|dj�fd�td�D��z}tjj||�}	tj|tj
tjztjz�}tj|�tj|�ytd	��#t$rY��t$rYywxYw)
N�(accesstest_deleteme_fishfingers_custard_�$abcdefghijklmnopqrstuvwxyz0123456789�
�c3�H�K�|]}tj�����y�w�N)�random�choice)�.0�_�alphabets  �r�	<genexpr>z)_test_writable_dir_win.<locals>.<genexpr>`s�����!L�8�a�&�-�-��"9�8�s�"�TFz3Unexpected condition testing for writable directory)
�range�joinrr�open�O_RDWR�O_CREAT�O_EXCL�close�unlink�FileExistsError�PermissionErrorr)rr(rDr5�file�fdrEs      @rr6r6Zs����:�H�5�H�
�2�Y���"�'�'�!L�5��8�!L�L�L���w�w�|�|�D�$�'��	�����r�y�y�2�:�:�5��	�	�A�B�B�
�H�H�R�L��I�I�d�O��#�(�G�
H�H���	���	��
	�s�AC�	C0�$C0�/C0�patternc���g}tj|�D]6\�}}tj||�}|j	�fd�|D���8|S)z�Returns a list of absolute paths of files beneath path, recursively,
    with filenames which match the UNIX-style shell glob pattern.c3�^�K�|]$}tjj�|����&y�wr@)rrrI)rCr,�roots  �rrFzfind_files.<locals>.<genexpr>|s!�����=�W��b�g�g�l�l�4��+�W�s�*-)r�walk�fnmatch�filter�extend)rrTr-rD�files�matchesrWs      @r�
find_filesr^vsK����F��'�'�$�-���a���.�.���0���
�
�=�W�=�=�(��Mr9c��tjj|�rytjj|�S)Nr)rr�islink�getsize�rs r�	file_sizerc�s(��	�w�w�~�~�d���
�7�7�?�?�4� � r9c�*�tt|��Sr@)rrcrbs r�format_file_sizere�s���y���'�'r9c��d}tj|�D];\}}}|D]0}tjj||�}|t	|�z
}�2�=|S)Ng)rrXrrIrc)r�sizerW�_dirsr\�filename�	file_paths       r�directory_sizerk�sT���D� �g�g�d�m���e�U��H������T�8�4�I��I�i�(�(�D��,��Kr9c�*�tt|��Sr@)rrkrbs r�format_directory_sizerm�s���~�d�+�,�,r9)$rYr�os.pathrAr�
contextlibr�tempfiler�typingrrrrr	r
�pip._internal.utils.compatr�pip._internal.utils.miscr�pip._internal.utils.retryr
�str�boolr r.�replacer8r6r^�int�floatrcrerkrmr'r9r�<module>rzs/���	��
�
�%�'�>�>�3�0�+��3��4��6�&�C�&�3�&�9�X�t�T�=Q�3R�&��&�0/�%���
.�r�z�z�
:��
(�C�(�D�(�$I��I��I�8�S��3��4��9��!�C�!�E�#�u�*�-�!�(�3�(�3�(�����s�E�z�!2��-��-��-r9

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists