3
…U»gi  ã               @   sZ   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZejdd„ ƒZdd„ Z	dd„ Z
dS )é    Nc              c   s$   t jƒ } z
| V  W dtj| ƒ X dS )z2Create a temporary directory in a context manager.N)ÚtempfileÚmkdtempÚshutilÚrmtree)Útd© r   ú?/tmp/pip-unpacked-wheel-0ht26j5g/pip/_vendor/pep517/dirtools.pyÚtempdir
   s    
r	   c              O   sB   yt j| |ŽS  tk
r< } z|jtjkr,‚ W Y dd}~X nX dS )zWLike `mkdir`, but does not raise an exception if the
    directory already exists.
    N)ÚosÚmkdirÚOSErrorÚerrnoÚEEXIST)ÚargsÚkwargsÚexcr   r   r   Úmkdir_p   s
    r   c             C   s¢   t jƒ }tj|dƒ}xˆtj| ƒD ]z\} }}x8|D ]0}tjj| |ƒ}tjj|| ƒ}|j	|d dƒ q0W x4|D ],}tjj| |ƒ}tjj|| ƒ}|j
||ƒ qjW q W |S )z0Construct an in-memory zip file for a directory.Úwú/Ú )ÚioÚBytesIOÚzipfileÚZipFiler
   ÚwalkÚpathÚjoinÚrelpathÚwritestrÚwrite)ÚrootÚbufferÚzip_fileÚdirsÚfilesr   Zfs_pathÚrel_pathr   r   r   Údir_to_zipfile   s    

r&   )r
   r   Ú
contextlibr   r   r   r   Úcontextmanagerr	   r   r&   r   r   r   r   Ú<module>   s   
