a ˆljiã@sZddlZddlZddlZddlZddlZddlZddlZejdd„ƒZdd„Z dd„Z dS)éNc cs.t ¡}z|VWt |¡n t |¡0dS)z2Create a temporary directory in a context manager.N)ÚtempfileZmkdtempÚshutilÚrmtree)Ztd©rú?/usr/lib/python3.9/site-packages/pip/_vendor/pep517/dirtools.pyÚtempdir src OsJztj|i|¤ŽWStyD}z|jtjkr0‚WYd}~n d}~00dS)zWLike `mkdir`, but does not raise an exception if the directory already exists. N)ÚosÚmkdirÚOSErrorÚerrnoZEEXIST)ÚargsÚkwargsÚexcrrrÚmkdir_ps  rcCs–t ¡}t |d¡}t |¡D]r\}}}|D]0}tj ||¡}tj ||¡}|  |dd¡q,|D],}tj ||¡}tj ||¡}|  ||¡qbq|S)z0Construct an in-memory zip file for a directory.Úwú/Ú) ÚioÚBytesIOÚzipfileÚZipFilerÚwalkÚpathÚjoinÚrelpathZwritestrÚwrite)ÚrootÚbufferZzip_fileÚdirsÚfilesrZfs_pathZrel_pathrrrÚdir_to_zipfiles r ) rrÚ contextlibrrr rÚcontextmanagerrrr rrrrÚs