B š•Reã@sRddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZddlmZddlmZmZerÈdd lmZmZmZmZmZGd d „d eƒZd d „Zdd„Zdd„Z e dd„ƒZ!e ddd�Z"e�r e"dd„ƒZ#n e"ej#ƒZ#dd„Z$dd„Z%dd„Z&dd „Z'd!d"„Z(d#d$„Z)d%d&„Z*dS)'éN)Úcontextmanager)ÚNamedTemporaryFile)Úretry)ÚPY2)Ú get_path_uid)Ú format_size)ÚMYPY_CHECK_RUNNINGÚcast)ÚAnyÚBinaryIOÚIteratorÚListÚUnionc@seZdZedd„ƒZdS)ÚNamedTemporaryFileResultcCsdS)N©)Úselfrrú�/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/utils/filesystem.pyÚfileszNamedTemporaryFileResult.fileN)Ú__name__Ú __module__Ú __qualname__ÚpropertyrrrrrrsrcCs¢tjdksttdƒsdStj |¡s(t‚d}xp||krœtj |¡rˆt ¡dkrxy t |ƒ}Wnt k rndSX|dkSt  |tj ¡Sq.|tj  |¡}}q.WdS)NÚwin32ÚgeteuidTrF)ÚsysÚplatformÚhasattrÚosÚpathÚisabsÚAssertionErrorÚlexistsrrÚOSErrorÚaccessÚW_OKÚdirname)rÚpreviousÚpath_uidrrrÚcheck_path_owners    r(c Cs|yt ||¡Wnfttfk rvxJ||gD]>}y t|ƒ}Wntk rRYq.X|r.t djftƒŽ¡‚q.W‚YnXdS)z“Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700. z`{f}` is a socketN)ÚshutilÚcopy2r"ÚIOErrorÚ is_socketÚSpecialFileErrorÚformatÚlocals)ÚsrcÚdestÚfÚis_socket_filerrrÚ copy2_fixed;s r4cCst t |¡j¡S)N)ÚstatÚS_ISSOCKrÚlstatÚst_mode)rrrrr,Tsr,c ksjtfdtj |¡tj |¡ddœ|—Ž�8}td|ƒ}z |VWd|j ¡t |j  ¡¡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)ÚdeleteÚdirÚprefixÚsuffixrN) rrrr%Úbasenamer rÚflushÚfsyncÚfileno)rÚkwargsr2ÚresultrrrÚadjacent_tmp_fileYs      rCièéú)Ústop_max_delayÚ wait_fixedcCs@yt ||¡Wn*tk r:t |¡t ||¡YnXdS)N)rÚrenamer"Úremove)r0r1rrrÚreplacevs  rIcCsLx*tj |¡s*tj |¡}||kr$P|}qWtjdkrDt |tj¡St|ƒS)zgCheck if a directory is writable. Uses os.access() on POSIX, tries creating files on Windows. Úposix)rrÚisdirr%Únamer#r$Ú_test_writable_dir_win)rÚparentrrrÚtest_writable_dir…s  rOc sÚd}d‰xÄtdƒD]¸}|d ‡fdd„tdƒDƒ¡}tj ||¡}yt |tjtjBtjB¡}WnNtk r°}z0|j t j kr‚w|j t j ksš|j t j krždS‚Wdd}~XYqXt  |¡t |¡d SqWtd ƒ‚dS) NÚ(accesstest_deleteme_fishfingers_custard_Ú$abcdefghijklmnopqrstuvwxyz0123456789é Úc3s|]}t ˆ¡VqdS)N)ÚrandomÚchoice)Ú.0Ú_)Úalphabetrrú Ÿsz)_test_writable_dir_win..éFTz3Unexpected condition testing for writable directory)ÚrangeÚjoinrrÚopenÚO_RDWRÚO_CREATÚO_EXCLr"ÚerrnoÚEEXISTÚEPERMÚEACCESÚcloseÚunlinkÚEnvironmentError)rr=rWrLrÚfdÚer)rXrrM˜s$    rMcsFg}x.)rÚwalkÚfnmatchÚfilterÚextend)rÚpatternrBrWÚfilesÚmatchesr)rjrÚ find_files¼s  rrcCstj |¡rdStj |¡S)Nr)rrÚislinkÚgetsize)rrrrÚ file_sizeÇs rucCs tt|ƒƒS)N)rru)rrrrÚformat_file_sizeÏsrvcCsJd}x@t |¡D]2\}}}x&|D]}tj ||¡}|t|ƒ7}q WqW|S)Ng)rrkrr\ru)rÚsizerjÚ_dirsrpÚfilenameÚ file_pathrrrÚdirectory_sizeÔs  r{cCs tt|ƒƒS)N)rr{)rrrrÚformat_directory_sizeÞsr|)+rarlrÚos.pathrTr)r5rÚ contextlibrÚtempfilerÚpip._vendor.retryingrZpip._vendor.sixrÚpip._internal.utils.compatrÚpip._internal.utils.miscrÚpip._internal.utils.typingrr Útypingr r r r rrr(r4r,rCÚ_replace_retryrIrOrMrrrurvr{r|rrrrÚs@         $