3 Re@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)NamedTemporaryFileResultcCsdS)N)selfrr/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/utils/filesystem.pyfileszNamedTemporaryFileResult.fileN)__name__ __module__ __qualname__propertyrrrrrrsrc Cstjdksttd rdStjj|s*td}xp||krtjj|rtjdkrzy t |}Wnt k rpdSX|dkStj |tj Sq0|tjj |}}q0WdS)Nwin32geteuidTrF)sysplatformhasattrospathisabsAssertionErrorlexistsrrOSErroraccessW_OKdirname)rpreviouspath_uidrrrcheck_path_owners    r(cCs|ytj||Wnfttfk rvxJ||gD]>}y t|}Wntk rRYq.X|r.tjdjftq.WYnXdS)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,cksjtfdtjj|tjj|dd|8}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. Fz.tmp)deletedirprefixsuffixrN) rrrr%basenamer rflushfsyncfileno)rkwargsr2resultrrradjacent_tmp_fileYs      rCi)stop_max_delay wait_fixedc Cs@ytj||Wn*tk r:tj|tj||YnXdS)N)rrenamer"remove)r0r1rrrreplacevs  rIcCsLx*tjj|s*tjj|}||kr$P|}qWtjdkrDtj|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  rOcsd}dxtdD]}|djfddtdD}tjj||}ytj|tjtjBtjB}WnNtk r}z2|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$    rMcsFg}x.)rwalkfnmatchfilterextend)rpatternrBrWfilesmatchesr)rjr find_filess  rrcCstjj|rdStjj|S)Nr)rrislinkgetsize)rrrr file_sizes rucCs tt|S)N)rru)rrrrformat_file_sizesrvcCsJd}x@tj|D]2\}}}x&|D]}tjj||}|t|7}q WqW|S)Ng)rrkrr\ru)rsizerj_dirsrpfilename file_pathrrrdirectory_sizes  r{cCs tt|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@         $