U n a@sRddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZddlmZddlmZmZerdd lmZmZmZmZmZGd d d eZd d ZddZddZ e ddZ!e dddZ"er e"ddZ#n e"ej#Z#ddZ$ddZ%ddZ&dd Z'd!d"Z(d#d$Z)d%d&Z*dS)'N)contextmanager)NamedTemporaryFile)retry)PY2) get_path_uid) format_size)MYPY_CHECK_RUNNINGcast)AnyBinaryIOIteratorListUnionc@seZdZeddZdS)NamedTemporaryFileResultcCsdSN)selfrr_C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\utils\filesystem.pyfileszNamedTemporaryFileResult.fileN)__name__ __module__ __qualname__propertyrrrrrrsrcCstjdksttdsdStj|s(td}||krtj|rtdkrxz t |}Wnt k rnYdSX|dkSt |tj Sq,|tj |}}q,dS)Nwin32geteuidTrF)sysplatformhasattrospathisabsAssertionErrorlexistsrrOSErroraccessW_OKdirname)rpreviouspath_uidrrrcheck_path_owners   r)c Csxzt||Wnbttfk rr||fD]>}z t|}Wntk rPYq,X|r,tdjftq,YnXdS)zWrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700. z`{f}` is a socketN)shutilcopy2r#IOError is_socketSpecialFileErrorformatlocals)srcdestfis_socket_filerrr copy2_fixed;s   r5cCstt|jSr)statS_ISSOCKrlstatst_moderrrrr-Tsr-c ksjtfdtj|tj|dd|8}td|}z |VW5|jt|j XW5QRXdS)a%Return a file-like object pointing to a tmp file next to path. The file is created securely and is ensured to be written to disk after the context reaches its end. kwargs will be passed to tempfile.NamedTemporaryFile to control the way the temporary file will be opened. Fz.tmp)deletedirprefixsuffixrN) rrrr&basenamer rflushfsyncfileno)rkwargsr3resultrrradjacent_tmp_fileYs      rEi)stop_max_delay wait_fixedcCs@zt||Wn*tk r:t|t||YnXdSr)rrenamer#remove)r1r2rrrreplacevs  rKcCsHtj|s(tj|}||kr"q(|}qtjdkr@t|tjSt|S)zgCheck if a directory is writable. Uses os.access() on POSIX, tries creating files on Windows. posix)rrisdirr&namer$r%_test_writable_dir_win)rparentrrrtest_writable_dirs   rQc sd}dtdD]}|dfddtdD}tj||}zt|tjtjBtjB}Wn\tk r}z>|j t j krWY,q|j t j ks|j t j krWY dSW5d}~XYqXt |t|d Sqtd dS) N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789 c3s|]}tVqdSr)randomchoice).0_alphabetrr sz)_test_writable_dir_win..FTz3Unexpected condition testing for writable directory)rangejoinrropenO_RDWRO_CREATO_EXCLr#errnoEEXISTEPERMEACCEScloseunlinkEnvironmentError)rr?irNrfderrZrrOs&      rOcsBg}t|D].\}}t||}|fdd|Dq|S)zReturns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.c3s|]}tj|VqdSr)rrr_)rXr3rootrrr\szfind_files..)rwalkfnmatchfilterextend)rpatternrDdirsfilesmatchesrrnr find_filess  rxcCstj|rdStj|S)Nr)rrislinkgetsizer:rrr file_sizes r{cCs tt|Sr)rr{r:rrrformat_file_sizesr|cCsBd}t|D].\}}}|D]}tj||}|t|7}qq|S)Ng)rrprr_r{)rsizero_dirsrvfilename file_pathrrrdirectory_sizes rcCs tt|Sr)rrr:rrrformat_directory_sizesr)+rdrqros.pathrVr*r6r contextlibrtempfilerpip._vendor.retryingrZpip._vendor.sixrpip._internal.utils.compatrpip._internal.utils.miscrpip._internal.utils.typingrr typingr r r r rrr)r5r-rE_replace_retryrKrQrOrxr{r|rrrrrrsD         "