
    Qh|                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZ d dlmZmZmZ d dlmZ d dlmZ d d	lmZ dd
Ze
dd       Z  edd      ej2                        ZddZddZddZddZddZddZddZ y)    )annotationsN)	Generator)contextmanager)NamedTemporaryFile)AnyBinaryIOcast)get_path_uid)format_size)retryc                   t         j                  dk(  st        t        d      syt        j                  j                  |       sJ d }| |k7  rt        j                  j                  |       rLt        j                         dk(  r	 t        |       }|dk(  S t        j                  | t        j                        S | t        j                  j                  |       } }| |k7  ry# t        $ r Y yw xY w)Nwin32geteuidTr   F)sysplatformhasattrospathisabslexistsr   r
   OSErroraccessW_OKdirname)r   previouspath_uids      Z/var/www/teggl/fontify/venv/lib/python3.12/site-packages/pip/_internal/utils/filesystem.pycheck_path_ownerr      s     ||wgb)&<77==H
(
77??4 zz|q !+D1H  1}$yyrww//!277??4#8dH (
   ! !s   C   	C,+C,c              +    K   t        ddt        j                  j                  |       t        j                  j	                  |       dd|5 }t        t        |      }	 | |j                          t        j                  |j                                	 ddd       y# |j                          t        j                  |j                                w xY w# 1 sw Y   yxY ww)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suffixN )
r   r   r   r   basenamer	   r   flushfsyncfileno)r   kwargsfresults       r   adjacent_tmp_filer,   -   s      
 
GGOOD!ww%	

 
 & 
h"	&LLLNHHV]]_%& & LLNHHV]]_%& &s6   AC$CB #3C	C$ 5CCC!C$   g      ?)stop_after_delaywaitc                R   t         j                  j                  |       sGt         j                  j                  |       }|| k(  rn"|} t         j                  j                  |       sGt         j                  dk(  r$t        j
                  | t         j                        S t        |       S )zgCheck if a directory is writable.

    Uses os.access() on POSIX, tries creating files on Windows.
    posix)r   r   isdirr   namer   r   _test_writable_dir_win)r   parents     r   test_writable_dirr6   K   su     ggmmD!&T>	 ggmmD! 
ww'yyrww''!$''    c                   d}dt        d      D ]  }|dj                  fdt        d      D              z   }t        j                  j                  | |      }	 t        j                  |t        j
                  t        j                  z  t        j                  z        }t        j                  |       t        j                  |        y t        d	      # t        $ r Y t        $ r Y  yw xY w)
N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789
    c              3  H   K   | ]  }t        j                          y wN)randomchoice).0_alphabets     r   	<genexpr>z)_test_writable_dir_win.<locals>.<genexpr>c   s     !La&--"9!Ls   "   TFz3Unexpected condition testing for writable directory)rangejoinr   r   openO_RDWRO_CREATO_EXCLcloseunlinkFileExistsErrorPermissionErrorr   )r   r%   rB   r3   filefdrC   s         @r   r4   r4   ]   s     :H5H2Y "''!L58!LLLww||D$'	ryy2::5		ABB HHRLIIdO#( G
HH  	 	 	s   AC	C0$C0/C0c                    g }t        j                  |       D ]6  \  }}t        j                  ||      }|j	                  fd|D               8 |S )zReturns a list of absolute paths of files beneath path, recursively,
    with filenames which match the UNIX-style shell glob pattern.c              3  ^   K   | ]$  }t         j                  j                  |       & y wr>   )r   r   rG   )rA   r*   roots     r   rD   zfind_files.<locals>.<genexpr>   s      =bggll4+=s   *-)r   walkfnmatchfilterextend)r   patternr+   rB   filesmatchesrT   s         @r   
find_filesr\   y   sP     F''$- >a..0=W==> Mr7   c                    t         j                  j                  |       ryt         j                  j                  |       S )Nr   )r   r   islinkgetsizer   s    r   	file_sizera      s(    	ww~~d77??4  r7   c                *    t        t        |             S r>   )r   ra   r`   s    r   format_file_sizerc      s    y''r7   c                    d}t        j                  |       D ];  \  }}}|D ]0  }t         j                  j                  ||      }|t	        |      z  }2 = |S )Ng        )r   rU   r   rG   ra   )r   sizerT   _dirsrZ   filename	file_paths          r   directory_sizeri      s^    D ggdm )eU 	)HT84IIi((D	)) Kr7   c                *    t        t        |             S r>   )r   ri   r`   s    r   format_directory_sizerk      s    ~d+,,r7   )r   strreturnbool)r   rl   r)   r   rm   zGenerator[BinaryIO, None, None])r   rl   rY   rl   rm   z	list[str])r   rl   rm   zint | float)r   rl   rm   rl   )!
__future__r   rV   r   os.pathr?   r   collections.abcr   
contextlibr   tempfiler   typingr   r   r	   pip._internal.utils.compatr
   pip._internal.utils.miscr   pip._internal.utils.retryr   r   r,   replacer6   r4   r\   ra   rc   ri   rk   r$   r7   r   <module>ry      s    "  	   
 % % ' & & 3 0 +6 & &0 /%
.rzz
:
($I8!(-r7   