HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/utils/__pycache__/filesystem.cpython-310.pyc
o

@%Ne�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZddlmZmZmZddlmZddlmZded	efd
d�Zded
ed	dfdd�Zded	efdd�Zededed	ee
fdd��Zeded�ed�d�Z e ej!�Z!ded	efdd�Z"ded	efdd�Z#deded	eefdd�Z$ded	ee%e&ffd d!�Z'ded	efd"d#�Z(ded	ee%e&ffd$d%�Z)ded	efd&d'�Z*dS)(�N)�contextmanager)�NamedTemporaryFile)�Any�BinaryIO�Iterator�List�Union�cast)�retry�stop_after_delay�
wait_fixed)�get_path_uid)�format_size�path�returncCs�tjdks
ttd�sdStj�|�sJ�d}||krNtj�|�rAt��dkr:z	t|�}W|dkSt	y9YdSwt�
|tj�S|tj�|�}}||ksdS)N�win32�geteuidTrF)
�sys�platform�hasattr�osr�isabs�lexistsrr
�OSError�access�W_OK�dirname)r�previous�path_uid�r�@/usr/lib/python3/dist-packages/pip/_internal/utils/filesystem.py�check_path_owners"
���r!�src�destcCshz	t�||�WdSty3||fD]}zt|�}Wn	ty%Yqw|r1t�d|�d���q�w)z�Wrap shutil.copy2() but map errors copying socket files to
    SpecialFileError as expected.

    See also https://bugs.python.org/issue37700.
    �`z
` is a socketN)�shutil�copy2r�	is_socket�SpecialFileError)r"r#�f�is_socket_filerrr �copy2_fixed-s���r+cCst�t�|�j�S�N)�stat�S_ISSOCKr�lstat�st_mode�rrrr r'Dsr'�kwargscks��tddtj�|�tj�|�dd�|���+}tt|�}z|VW|��t�|�	��n|��t�|�	��wWd�dS1sCwYdS)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�suffixNr)
rrrr�basenamer	r�flush�fsync�fileno)rr2r)�resultrrr �adjacent_tmp_fileHs$�


��
�"�r<T�g�?)�reraise�stop�waitcCsRtj�|�stj�|�}||krn|}tj�|�rtjdkr%t�|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�parentrrr �test_writable_diris�
rFc	s�d}d�td�D]H}|d��fdd�td�D��}tj�||�}zt�|tjtjBtjB�}Wnty9Yqt	yCYdSwt�
|�t�|�d	Std
��)N�(accesstest_deleteme_fishfingers_custard_�$abcdefghijklmnopqrstuvwxyz0123456789�
�c3s�|]}t���VqdSr,)�random�choice)�.0�_��alphabetrr �	<genexpr>�s�z)_test_writable_dir_win.<locals>.<genexpr>�FTz3Unexpected condition testing for writable directory)
�range�joinrr�open�O_RDWR�O_CREAT�O_EXCL�FileExistsError�PermissionError�close�unlinkr)rr7rNrC�file�fdrrOr rD{s  �

rD�patterncsBg}t�|�D]\�}}t�||�}|��fdd�|D��q|S)z�Returns a list of absolute paths of files beneath path, recursively,
    with filenames which match the UNIX-style shell glob pattern.c3s�|]
}tj��|�VqdSr,)rrrT)rMr)��rootrr rQ�s�zfind_files.<locals>.<genexpr>)r�walk�fnmatch�filter�extend)rr_r;rN�files�matchesrr`r �
find_files�s
rhcCstj�|�rdStj�|�S)Nr)rr�islink�getsizer1rrr �	file_size�srkcC�tt|��Sr,)rrkr1rrr �format_file_size��rmcCsBd}t�|�D]\}}}|D]}tj�||�}|t|�7}qq|S)Ng)rrbrrTrk)r�sizera�_dirsrf�filename�	file_pathrrr �directory_size�s�rscCrlr,)rrsr1rrr �format_directory_size�rnrt)+rcr�os.pathrKr%r-r�
contextlibr�tempfiler�typingrrrrrr	�pip._vendor.tenacityr
rr�pip._internal.utils.compatr
�pip._internal.utils.miscr�str�boolr!r+r'r<�_replace_retry�replacerFrDrh�int�floatrkrmrsrtrrrr �<module>s6