
    wOgV              
          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
mZmZmZmZmZ d dlmZ d dlmZ d dlmZ ded	efd
Zedede
d	eeddf         fd            Z  edd          ej                  Zded	efdZded	efdZdeded	ee         fdZded	eeef         fdZ ded	efdZ!ded	eeef         fdZ"ded	efdZ#dS )    N)contextmanager)NamedTemporaryFile)AnyBinaryIO	GeneratorListUnioncast)get_path_uid)format_size)retrypathreturnc                    t           j        dk    st          t          d          sdS t          j                            |           sJ d }| |k    rt          j                            |           r^t          j                    dk    r(	 t          |           }n# t          $ r Y dS w xY w|dk    S t          j
        | t          j                  S | t          j                            |           } }| |k    dS )Nwin32geteuidTr   F)sysplatformhasattrosr   isabslexistsr   r   OSErroraccessW_OKdirname)r   previouspath_uids      X/var/www/AppWebDeiv/myenv/lib/python3.11/site-packages/pip/_internal/utils/filesystem.pycheck_path_ownerr       s     |wgb)&<&<t7==H
(

7??4   	9z||q  !+D11HH ! ! ! 55!1}$yrw///!27??4#8#8dH (

 5s   B 
B&%B&kwargsc              +     K   t          ddt          j                            |           t          j                            |           dd|5 }t          t          |          }	 |V  |                                 t          j        |	                                           n?# |                                 t          j        |	                                           w xY w	 ddd           dS # 1 swxY w Y   dS )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   r!   fresults       r   adjacent_tmp_filer.   *   s0      
 
GOOD!!w%%	
 

 
 
 & 
h""	&LLLLLNNNHV]]__%%%% LLNNNHV]]__%%%%%& & & & & & & & & & & & & & & & & &s*   C1%B$);C1$<C  C11C58C5   g      ?)stop_after_delaywaitc                 J   t           j                            |           sGt           j                            |           }|| k    rn!|} t           j                            |           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_dirr8   H   s     gmmD!! &&T>>	 gmmD!!  
w'yrw'''!$'''    c                    d}dt          d          D ]}|d                    fdt          d          D                       z   }t          j                            | |          }	 t          j        |t          j        t          j        z  t          j        z            }t          j        |           t          j	        |            dS # t          $ r Y t          $ r Y  dS w xY wt          d	          )
N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789
    c              3   @   K   | ]}t          j                  V  d S N)randomchoice).0_alphabets     r   	<genexpr>z)_test_writable_dir_win.<locals>.<genexpr>`   s-      !L!La&-"9"9!L!L!L!L!L!Lr9      TFz3Unexpected condition testing for writable directory)rangejoinr   r   openO_RDWRO_CREATO_EXCLcloseunlinkFileExistsErrorPermissionErrorr   )r   r(   rD   r5   filefdrE   s         @r   r6   r6   Z   s    :H5H2YY  "''!L!L!L!L588!L!L!LLLLw||D$''	ry2:5	ABBB HRLLLIdOOO44  	 	 	D 	 	 	 555	 G
H
HHs   )9C
C'	C'&C'patternc                     g }t          j        |           D ]<\  }}t          j        ||          }|                    fd|D                        =|S )zReturns a list of absolute paths of files beneath path, recursively,
    with filenames which match the UNIX-style shell glob pattern.c              3   X   K   | ]$}t           j                            |          V  %d S r@   )r   r   rI   )rC   r,   roots     r   rF   zfind_files.<locals>.<genexpr>|   s3      ==bgll4++======r9   )r   walkfnmatchfilterextend)r   rT   r-   rD   filesmatchesrW   s         @r   
find_filesr^   v   sg     F'$-- > >a.00====W=======Mr9   c                     t           j                            |           rdS t           j                            |           S )Nr   )r   r   islinkgetsizer   s    r   	file_sizerc      s1    	w~~d q7??4   r9   c                 :    t          t          |                     S r@   )r   rc   rb   s    r   format_file_sizere      s    y'''r9   c                     d}t          j        |           D ]=\  }}}|D ]4}t           j                            ||          }|t	          |          z  }5>|S )Ng        )r   rX   r   rI   rc   )r   sizerW   _dirsr\   filename	file_paths          r   directory_sizerk      si    D gdmm ) )eU 	) 	)HT844IIi(((DD	) Kr9   c                 :    t          t          |                     S r@   )r   rk   rb   s    r   format_directory_sizerm      s    ~d++,,,r9   )$rY   r   os.pathrA   r   
contextlibr   tempfiler   typingr   r   r   r   r	   r
   pip._internal.utils.compatr   pip._internal.utils.miscr   pip._internal.utils.retryr   strboolr    r.   replacer8   r6   r^   intfloatrc   re   rk   rm   r'   r9   r   <module>rz      s\    				   



 % % % % % % ' ' ' ' ' ' > > > > > > > > > > > > > > > > 3 3 3 3 3 3 0 0 0 0 0 0 + + + + + +3 4    6 &C &3 &9XtT=Q3R & & & &0 /%%
.
.
.rz
:
:
(C (D ( ( ( ($I I I I I I8S 3 49    !C !E#u*- ! ! ! !(3 (3 ( ( ( ( sEz!2    - - - - - - - -r9   