U ʗRe@sfddlZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z m Z mZmZddlmZmZmZddlmZddlmZeedd d Zeee e e ddfd d d ZedededdZeejZeedddZeedddZeee edddZ eee!e"fdddZ#eedddZ$eee!e"fdddZ%eeddd Z&dS)!N)contextmanager)NamedTemporaryFile)AnyBinaryIO GeneratorListUnioncast)retrystop_after_delay wait_fixed) get_path_uid) format_size)pathreturncCstjdksttdsdStj|s(td}||krtj|rtdkrxz t |}Wnt k rnYdSX|dkSt |tj Sq,|tj |}}q,dS)Nwin32geteuidTrF)sysplatformhasattrosrisabsAssertionErrorlexistsrr OSErroraccessW_OKdirname)rpreviouspath_uidr /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/utils/filesystem.pycheck_path_owners   r")rkwargsrc ksftfdtj|tj|dd|4}tt|}z |VW5|t| 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)deletedirprefixsuffixN) rrrrbasenamer rflushfsyncfileno)rr#fresultr r r!adjacent_tmp_file+s     r.Tg?)reraisestopwaitcCsHtj|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)rrisdirrnamerr_test_writable_dir_win)rparentr r r!test_writable_dirLs   r8c sd}dtdD]}|dfddtdD}tj||}zt|tjtjBtjB}Wn*tk rtYqt k rYdSXt |t |d Sqt d dS) N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789 c3s|]}tVqdSN)randomchoice).0_alphabetr r! dsz)_test_writable_dir_win..FTz3Unexpected condition testing for writable directory) rangejoinrropenO_RDWRO_CREATO_EXCLFileExistsErrorPermissionErrorcloseunlinkr)rr(rAr5filefdr rBr!r6^s     r6)rpatternrcsBg}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=)rrrG)r@r,rootr r!rDszfind_files..)rwalkfnmatchfilterextend)rrRr-rAfilesmatchesr rSr! find_fileszs  r[cCstj|rdStj|S)Nr)rrislinkgetsizerr r r! file_sizes r_cCs tt|Sr=)rr_r^r r r!format_file_sizesr`cCsBd}t|D].\}}}|D]}tj||}|t|7}qq|S)Ng)rrUrrGr_)rsizerT_dirsrYfilename file_pathr r r!directory_sizes recCs tt|Sr=)rrer^r r r!format_directory_sizesrf)'rVros.pathr>r contextlibrtempfilertypingrrrrrr pip._vendor.tenacityr r r pip._internal.utils.compatr pip._internal.utils.miscrstrboolr"r._replace_retryreplacer8r6r[intfloatr_r`rerfr r r r!s,