Re@sddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZddlmZddlmZmZerdd lmZmZmZmZmZGd d d eZd d ZddZddZ e ddZ!e ddddZ"ere"ddZ#ne"ej#Z#ddZ$ddZ%ddZ&d d!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@s"eZdZeddZdS)NamedTemporaryFileResultcCsdS)N)selfrr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/filesystem.pyfileszNamedTemporaryFileResult.fileN)__name__ __module__ __qualname__propertyrrrrrrs rc Cstjdksttd r#dStjj|s;td}x||krtjj|rtjdkryt |}Wnt k rdSYnX|dkStj |tj SqD|tjj |}}qDWdS)Nwin32geteuidTrF)sysplatformhasattrospathisabsAssertionErrorlexistsrrOSErroraccessW_OKdirname)rpreviouspath_uidrrrcheck_path_owners   r(cCsytj||Wnxttfk rxZ||gD]L}yt|}Wntk raYq7X|r7tjdjtq7WYnXdS)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 r4cCstjtj|jS)N)statS_ISSOCKrlstatst_mode)rrrrr,Tsr,ckstdddtjj|dtjj|dd|F}td|}z |VWd|jjtj|jj XWdQRXdS) 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. deleteFdirprefixsuffixz.tmprN) rrrr%basenamer rflushfsyncfileno)rkwargsr2resultrrradjacent_tmp_fileYs    rCstop_max_delayi wait_fixedc CsJytj||Wn/tk rEtj|tj||YnXdS)N)rrenamer"remove)r0r1rrrreplacevs   rIcCsjx;tjj|s=tjj|}||kr4P|}qWtjdkr`tj|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  rOcs!d}dxtdD]}|djfddtdD}tjj||}y'tj|tjtjBtjB}Wnetk r}zE|j t j krw|j t j ks|j t j krdSWYdd}~XqXtj |tj|d SqWtd dS) N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789 c3s|]}tjVqdS)N)randomchoice).0_)alphabetrr sz)_test_writable_dir_win..FTz3Unexpected condition testing for writable directory)rangejoinrropenO_RDWRO_CREATO_EXCLr"errnoEEXISTEPERMEACCEScloseunlinkEnvironmentError)rr=rWrLrfder)rXrrMs$,'$  rMcs_g}xRtj|D]A\}}tj||}|jfdd|DqW|S)zReturns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.c3s$|]}tjj|VqdS)N)rrr\)rVr2)rootrrrYszfind_files..)rwalkfnmatchfilterextend)rpatternrBrWfilesmatchesr)rjr find_filess $rrcCs&tjj|rdStjj|S)Nr)rrislinkgetsize)rrrr file_sizesrucCstt|S)N)rru)rrrrformat_file_sizesrvcCscd}xVtj|D]E\}}}x3|D]+}tjj||}|t|7}q,WqW|S)Ng)rrkrr\ru)rsizerj_dirsrpfilename file_pathrrrdirectory_sizes  r{cCstt|S)N)rr{)rrrrformat_directory_sizesr|)+rarlros.pathrTr)r5r contextlibrtempfilerpip._vendor.retryingrZpip._vendor.sixrpip._internal.utils.compatrpip._internal.utils.miscrpip._internal.utils.typingrr typingr r r r rrr(r4r,rC_replace_retryrIrOrMrrrurvr{r|rrrrs@        (      $