Current File : //lib/python3.9/site-packages/pip/_internal/utils/__pycache__/filesystem.cpython-39.pyc |
a
[��f � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl m
Z
d dlmZm
Z
mZmZmZmZ d dlmZmZmZ d dlmZ d dlmZ eed�d d
�Zeedd�dd
�Zeed�dd�Zeeeee
d�dd��Zeded�ed�d�Z e ej!�Z!eed�dd�Z"eed�dd�Z#eeee d�dd�Z$eee%e&f d�dd�Z'eed�d d!�Z(eee%e&f d�d"d#�Z)eed�d$d%�Z*dS )&� N)�contextmanager)�NamedTemporaryFile)�Any�BinaryIO�Iterator�List�Union�cast)�retry�stop_after_delay�
wait_fixed)�get_path_uid)�format_size)�path�returnc C s� t jdksttd�sdS tj�| �s(J �d }| |kr�tj�| �r�t�� dkrvzt| �}W n t yl Y dS 0 |dkS t�
| tj�S q,| tj�| � }} q,dS )N�win32�geteuidTr F)
�sys�platform�hasattr�osr �isabs�lexistsr r
�OSError�access�W_OK�dirname)r ZpreviousZpath_uid� r �B/usr/lib/python3.9/site-packages/pip/_internal/utils/filesystem.py�check_path_owner s r )�src�destr c C sn zt �| |� W nX tyh | |fD ]:}zt|�}W n tyH Y q&0 |r&t �d|� d���q&� Y n0 dS )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! �fZis_socket_filer r r �copy2_fixed- s r( c C s t �t�| �j�S �N)�stat�S_ISSOCKr �lstat�st_mode�r r r r r% D s r% )r �kwargsr c k s� t f dtj�| �tj�| �dd�|���T}tt|�}z |V W |�� t�|� � � n|�� t�|� � � 0 W d � n1 s�0 Y dS )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)
r r r r �basenamer r �flush�fsync�fileno)r r/ r'