관리-도구
편집 파일: filesystem.cpython-38.pyc
U ��.e � @ s� d dl Z d dlZ d dlZd dlZd dlmZ d dlmZ d dlm Z d dl mZ d dlm Z d dlmZ d dlmZ er�d d lmZmZ G d d� de�Zdd � Zdd� Zdd� Zedd� �Ze ddd�Zer�edd� �Zn ee j�ZdS )� N)�contextmanager)�NamedTemporaryFile)�retry)�PY2)�get_path_uid)�cast)�MYPY_CHECK_RUNNING)�BinaryIO�Iteratorc @ s e Zd Zedd� �ZdS )�NamedTemporaryFileResultc C s d S �N� )�selfr r �B/usr/lib/python3.8/site-packages/pip/_internal/utils/filesystem.py�file s zNamedTemporaryFileResult.fileN)�__name__� __module__�__qualname__�propertyr r r r r r s r c C s� t td�sdS d }| |kr�tj�| �rnt�� dkr^zt| �}W n tk rT Y dS X |dkS t�| tj�S q| tj� | � }} qdS )N�geteuidTr F) �hasattr�os�path�lexistsr r �OSError�access�W_OK�dirname)r ZpreviousZpath_uidr r r �check_path_owner s r c C sr zt �| |� W n\ ttfk rl | |fD ]8}zt|�}W n tk rP Y q,X |r,t �d| ��q,� Y nX dS )z�Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700. z`%s` is a socketN)�shutilZcopy2r �IOError� is_socketZSpecialFileError)�src�dest�fZis_socket_filer r r �copy2_fixed5 s r% c C s t �t�| �j�S r )�stat�S_ISSOCKr �lstat�st_mode)r r r r r! M s r! c c sb t dtj�| �tj�| �dd��8}td|�}z |V W 5 |j�� t�|j� � � X W 5 Q R X dS )z�Given a path to a file, open a temp file next to it securely and ensure it is written to disk after the context reaches its end. Fz.tmp)�delete�dir�prefix�suffixr N) r r r r �basenamer r �flush�fsync�fileno)r r$ �resultr r r �adjacent_tmp_fileR s � r3 i� � )Zstop_max_delayZ wait_fixedc C s@ zt �| |� W n* tk r: t �|� t �| |� Y nX d S r )r �renamer �remove)r"