B
    =)H[‰
  ã               @   sN   d dl mZ d dlZd dlZd dlZd dlmZ e e	¡Z
G dd„ deƒZdS )é    )Úabsolute_importN)Úrmtreec                   sJ   e Zd ZdZd‡ fdd„	Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Z	‡  Z
S )ÚTempDirectorya'  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 or None
        delete
            Whether the directory should be deleted when exiting
            (when used as a contextmanager)

    Methods:
        create()
            Creates a temporary directory and stores its path in the path
            attribute.
        cleanup()
            Deletes the temporary directory and sets path attribute to None

    When used as a context manager, a temporary directory is created on
    entering the context and, if the delete attribute is True, on exiting the
    context the created directory is deleted.
    NÚtempc                s8   t t| ƒ ¡  |d kr"|d kr"d}|| _|| _|| _d S )NT)Úsuperr   Ú__init__ÚpathÚdeleteÚkind)Úselfr   r	   r
   )Ú	__class__© ú]C:\Users\HIRONO~1\AppData\Local\Temp\pip-install-qz7kpjmn\pip\pip\_internal\utils\temp_dir.pyr   %   s    zTempDirectory.__init__c             C   s   d  | jj| j¡S )Nz	<{} {!r}>)Úformatr   Ú__name__r   )r   r   r   r   Ú__repr__1   s    zTempDirectory.__repr__c             C   s   |   ¡  | S )N)Úcreate)r   r   r   r   Ú	__enter__4   s    zTempDirectory.__enter__c             C   s   | j r|  ¡  d S )N)r	   Úcleanup)r   ÚexcÚvalueÚtbr   r   r   Ú__exit__8   s    zTempDirectory.__exit__c             C   sT   | j dk	r t d | j ¡¡ dS tj  tjd | j¡d�¡| _ t d | j ¡¡ dS )zFCreate a temporary directory and store it's path in self.path
        Nz+Skipped creation of temporary directory: {}zpip-{}-)ÚprefixzCreated temporary directory: {})	r   ÚloggerÚdebugr   ÚosÚrealpathÚtempfileÚmkdtempr
   )r   r   r   r   r   <   s    
zTempDirectory.createc             C   s,   | j dk	r"tj  | j ¡r"t| j ƒ d| _ dS )z?Remove the temporary directory created and reset state
        N)r   r   Úexistsr   )r   r   r   r   r   M   s    
zTempDirectory.cleanup)NNr   )r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   Ú__classcell__r   r   )r   r   r      s   r   )Ú
__future__r   ÚloggingÚos.pathr   r   Úpip._internal.utils.miscr   Ú	getLoggerr   r   Úobjectr   r   r   r   r   Ú<module>   s   
