a
    !6ai  ã                   @   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  ¡ } z| V  W t | ¡ nt | ¡ 0 dS )z2Create a temporary directory in a context manager.N)ÚtempfileZmkdtempÚshutilZrmtree)Ztd© r   ú:lib/python3.9/site-packages/pip/_vendor/pep517/dirtools.pyÚtempdir
   s    r   c               
   O   sJ   zt j| i |¤ŽW S  tyD } z|jtjkr0‚ W Y d}~n
d}~0 0 dS )zWLike `mkdir`, but does not raise an exception if the
    directory already exists.
    N)ÚosÚmkdirÚOSErrorÚerrnoZEEXIST)ÚargsÚkwargsÚexcr   r   r   Úmkdir_p   s
    r   c                 C   s–   t  ¡ }t |d¡}t | ¡D ]r\} }}|D ]0}tj | |¡}tj || ¡}| 	|d d¡ q,|D ],}tj | |¡}tj || ¡}| 
||¡ qbq|S )z0Construct an in-memory zip file for a directory.Úwú/Ú )ÚioÚBytesIOÚzipfileZZipFiler   ÚwalkÚpathÚjoinÚrelpathZwritestrÚwrite)ÚrootÚbufferZzip_fileÚdirsÚfilesr   Zfs_pathZrel_pathr   r   r   Údir_to_zipfile   s    r   )r   r   Ú
contextlibr   r   r
   r   Úcontextmanagerr   r   r   r   r   r   r   Ú<module>   s   
	