3 ”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-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/utils/filesystem.pyÚfileszNamedTemporaryFileResult.fileN)Ú__name__Ú __module__Ú __qualname__Úpropertyrrrrrrsrc Cs¤tjdksttdƒ rdStjj|ƒs*t‚d}xp||kržtjj|ƒrŠtjƒdkrzy t |ƒ}Wnt k rpdSX|dkStj |tj ƒSq0|tjj |ƒ}}q0WdS)NÚwin32ÚgeteuidTrF)ÚsysÚplatformÚhasattrÚosÚpathÚisabsÚAssertionErrorÚlexistsrrÚOSErrorÚaccessÚW_OKÚdirname)rÚpreviousÚpath_uidrrrÚcheck_path_owners    r(cCs|ytj||ƒWnfttfk rvxJ||gD]>}y t|ƒ}Wntk rRYq.X|r.tjdjftƒŽƒ‚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 r4cCstjtj|ƒjƒS)N)ÚstatÚS_ISSOCKrÚlstatÚst_mode)rrrrr,Tsr,cksjtfdtjj|ƒtjj|ƒddœ|—Ž�8}td|ƒ}z |VWd|jjƒtj|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)ÚdeleteÚdirÚprefixÚsuffixrN) rrrr%Úbasenamer rÚflushÚfsyncÚfileno)rÚkwargsr2ÚresultrrrÚadjacent_tmp_fileYs      rCièéú)Ústop_max_delayÚ wait_fixedc Cs@ytj||ƒWn*tk r:tj|ƒtj||ƒYnXdS)N)rÚrenamer"Úremove)r0r1rrrÚreplacevs  rIcCsLx*tjj|ƒs*tjj|ƒ}||kr$P|}qWtjdkrDtj|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  rOcsÚd}d‰xÄtdƒD]¸}|dj‡fdd„tdƒDƒƒ}tjj||ƒ}ytj|tjtjBtjBƒ}WnNtk r°}z2|j t j kr‚w|j t j ksš|j t j krždS‚WYdd}~XqXtj |ƒtj|ƒd SqWtd ƒ‚dS) NÚ(accesstest_deleteme_fishfingers_custard_Ú$abcdefghijklmnopqrstuvwxyz0123456789é Úc3s|]}tjˆƒ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  rrcCstjj|ƒrdStjj|ƒS)Nr)rrÚislinkÚgetsize)rrrrÚ file_sizeÇs rucCs tt|ƒƒS)N)rru)rrrrÚformat_file_sizeÏsrvcCsJd}x@tj|ƒD]2\}}}x&|D]}tjj||ƒ}|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@         $