관리-도구
편집 파일: temp_dir.cpython-38.opt-1.pyc
U ��.e� � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlZd dlm Z d dl mZ er\d dlm Z e�e�ZG dd� de�ZG dd � d e�ZdS ) � )�absolute_importN)�rmtree)�MYPY_CHECK_RUNNING)�Optionalc sV e Zd ZdZd� fdd� Zedd� �Zdd � Zd d� Zdd � Z dd� Z dd� Z� ZS )� TempDirectoryaM Helper class that owns and cleans up a temporary directory. This class can be used as a context manager or as an OO representation of a temporary directory. Attributes: path Location to the created temporary directory delete Whether the directory should be deleted when exiting (when used as a contextmanager) Methods: cleanup() Deletes the temporary directory When used as a context manager, if the delete attribute is True, on exiting the context the temporary directory is deleted. N�tempc sP t t| ��� |d kr"|d kr"d}|d kr4| �|�}|| _d| _|| _|| _d S )NTF)�superr �__init__�_create�_path�_deleted�delete�kind)�self�pathr r �� __class__� �@/usr/lib/python3.8/site-packages/pip/_internal/utils/temp_dir.pyr + s zTempDirectory.__init__c C s | j S �N)r �r r r r r @ s zTempDirectory.pathc C s d� | jj| j�S )Nz <{} {!r}>)�formatr �__name__r r r r r �__repr__H s zTempDirectory.__repr__c C s | S r r r r r r � __enter__K s zTempDirectory.__enter__c C s | j r| �� d S r )r �cleanup)r �exc�value�tbr r r �__exit__N s zTempDirectory.__exit__c C s. t j�tjd�|�d��}t�d�|�� |S )zECreate a temporary directory and store its path in self.path �pip-{}-��prefix�Created temporary directory: {})�osr �realpath�tempfile�mkdtempr �logger�debug)r r r r r r r R s �zTempDirectory._createc C s"