U ÀÒ.eiã@sZddlZddlZddlZddlZddlZddlZddlZejdd„ƒZdd„Z dd„Z dS)éNc cs$t ¡}z |VW5t |¡XdS)z2Create a temporary directory in a context manager.N)ÚtempfileZmkdtempÚshutilZrmtree)Ztd©rú?/usr/lib/python3.8/site-packages/pip/_vendor/pep517/dirtools.pyÚtempdir s rc OsDztj||ŽWStk r>}z|jtjkr.‚W5d}~XYnXdS)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ÚzipfileZZipFilerÚwalkÚpathÚjoinÚrelpathZwritestrÚwrite)ÚrootÚbufferZzip_fileÚdirsÚfilesrZfs_pathZrel_pathrrrÚdir_to_zipfiles r) rrÚ contextlibrrr rÚcontextmanagerrrrrrrrÚs