
    4i                    j   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr  S SK	J
r
  S SKJr  S SKJr  S SKJrJrJrJr  S SKJr  S S	KJr  S S
KJr  SS jr\
SS j5       r\" SSS9" \R8                  5      rSS jrSS jrSS jrSS jr SS jr!SS jr"SS jr#S S jr$      S!S jr%S"S jr&S"S jr'g)#    )annotationsN)	Generator)contextmanager)Path)NamedTemporaryFile)AnyBinaryIOCallablecast)get_path_uid)format_size)retryc                   [         R                  S:X  d  [        [        S5      (       d  g[        R                  R                  U 5      (       d   eS nX:w  a  [        R                  R                  U 5      (       aO  [        R                  " 5       S:X  a   [        U 5      nUS:H  $ [        R                  " U [        R                  5      $ U [        R                  R                  U 5      pX:w  a  M  g! [         a     gf = f)Nwin32geteuidTr   F)sysplatformhasattrospathisabslexistsr   r   OSErroraccessW_OKdirname)r   previouspath_uids      `/var/www/html/dynamic-report/venv/lib/python3.13/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#8d 
   ! !s   C3 3
D ?D c              +    #    [        SS[        R                  R                  U 5      [        R                  R	                  U 5      SS.UD6 n[        [        U5      n Uv   UR                  5         [        R                  " UR                  5       5         SSS5        g! UR                  5         [        R                  " UR                  5       5        f = f! , (       d  f       g= f7f)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!#4C	C+!6CC
C($C+   g      ?)stop_after_delaywaitc                l   [         R                  R                  U 5      (       dM  [         R                  R                  U 5      nX:X  a  O(Un [         R                  R                  U 5      (       d  MM  [         R                  S:X  a%  [         R
                  " U [         R                  5      $ [        U 5      $ )z_Check 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   L   sy     ggmmD!!&>	 ggmmD!! 
ww'yyrww''!$''    c                  ^ SnSm[        S5       H  nUSR                  U4S j[        S5       5       5      -   n[        R                  R                  X5      n [        R                  " U[        R
                  [        R                  -  [        R                  -  5      n[        R                  " U5        [        R                  " U5          g   [        S	5      e! [         a     M  [         a       gf = f)
N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789
    c              3  P   >#    U  H  n[         R                  " T5      v   M     g 7fN)randomchoice).0_alphabets     r   	<genexpr>)_test_writable_dir_win.<locals>.<genexpr>d   s     !L8a&--"9"98s   #&   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   ^   s     :H5H2Y"''!L58!LLLww||D'	ryy2::5		ABB HHRLIIdO# ( G
HH  	 	 	s   AC
C7*	C76C7c                   ^ / n[         R                  " U 5       H7  u  mp4[        R                  " XA5      nUR	                  U4S jU 5       5        M9     U$ )zReturns a list of absolute paths of files beneath path, recursively,
with filenames which match the UNIX-style shell glob pattern.c              3  d   >#    U  H%  n[         R                  R                  TU5      v   M'     g 7fr@   )r   r   rJ   )rC   r,   roots     r   rF   find_files.<locals>.<genexpr>   s#     =Wbggll4++Ws   -0)r   walkfnmatchfilterextend)r   patternr-   rD   filesmatchesrW   s         @r   
find_filesr`   z   sG     F''$-a..0=W== ( Mr9   c                    [         R                  R                  U 5      (       a  g[         R                  R                  U 5      $ Nr   )r   r   islinkgetsizer   s    r   	file_sizerf      s+    	ww~~d77??4  r9   c                *    [        [        U 5      5      $ r@   )r   rf   re   s    r   format_file_sizerh      s    y''r9   c                    Sn[         R                  " U 5       H<  u  p#nU H0  n[         R                  R                  X%5      nU[	        U5      -  nM2     M>     U$ )Ng        )r   rY   r   rJ   rf   )r   sizerW   _dirsr^   filename	file_paths          r   directory_sizern      sP    D ggdmUHT4IIi((D  , Kr9   c                *    [        [        U 5      5      $ r@   )r   rn   re   s    r   format_directory_sizerp      s    ~d+,,r9   c                f   [         R                  " U 5      R                  S-  S-  n[         R                  [         R                  ;   a&  [         R                  " UR                  5       U5        g [         R                  [         R                  ;   a!  [         R                  " UR                  USS9  g g )Ni  i  F)follow_symlinks)r   statst_modechmodsupports_fdr*   supports_follow_symlinksr5   )	directorytarget_filemodes      r   copy_directory_permissionsr{      s|    
	""U*
	 	
 
xx2>>!
##%t,	R00	0
!!4? 
1r9   c              #    #    / n[        5       n[        R                  " [        U 5      R	                  5       5       Hg  u  pEn[        U5      nU" XF5      (       a8  UR                  [        UR                  5      SS 5        UR                  U5        UR                  U5        Mi     [        USS9 H  nX;  d  M
  Uv   M     g7f)zVYields every subdirectory of +path+ that has no files matching the
predicate under it.NT)reverse)setr   rY   r   resolveupdatelistparentsaddappendsorted)	r   	predicatedirectoriesexcludedroot_strrD   	filenamesrW   ds	            r   _subdirs_without_genericr      s      KuH"$''$t**<*<*>"?YH~X)) OOD.s34LL4  #@ K.G /s   B5C;	Cc                    [        U S 5      $ )z?Yields every subdirectory of +path+ that has no files under it.c                    [        U5      S:  $ rb   )lenrW   r   s     r   <lambda>'subdirs_without_files.<locals>.<lambda>   s    #i.STBTr9   r   re   s    r   subdirs_without_filesr      s    #D*TUUr9   c                    [        U S 5      $ )zDYields every subdirectory of +path+ that has no .whl files under it.c                &    [        S U 5       5      $ )Nc              3  B   #    U  H  oR                  S 5      v   M     g7f)z.whlN)endswith)rC   xs     r   rF   ;subdirs_without_wheels.<locals>.<lambda>.<locals>.<genexpr>   s     )Pi**V*<*<is   )anyr   s     r   r   (subdirs_without_wheels.<locals>.<lambda>   s    c)Pi)P&Pr9   r   re   s    r   subdirs_without_wheelsr      s    #P r9   )r   strreturnbool)r   r   r+   r   r   zGenerator[BinaryIO, None, None])r   r   r]   r   r   z	list[str])r   r   r   zint | float)r   r   r   r   )rx   r   ry   r	   r   None)r   r   r   z Callable[[str, list[str]], bool]r   Generator[Path])r   r   r   r   )(
__future__r   rZ   r   os.pathrA   r   collections.abcr   
contextlibr   pathlibr   tempfiler   typingr   r	   r
   r   pip._internal.utils.compatr   pip._internal.utils.miscr   pip._internal.utils.retryr   r    r.   replacer8   r6   r`   rf   rh   rn   rp   r{   r   r   r   r&   r9   r   <module>r      s    "  	   
 % %  ' 0 0 3 0 +6 & &0 
.rzz
:
($I8!(-	@
:4V
r9   