
    4Քh&                          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	J
r
  S SKJrJr  S SKJr  S SKJr  S S	KJr  \" \5      r " S
 S\5      rg)    N)Values)Callable)Command)ERRORSUCCESS)CommandErrorPipError)
filesystem)	getLogger)format_sizec                   x   \ rS rSrSrSrSrSS jrS\\	\
\\\	   /S4   4   4S jrS	\S
\\	   S\4S jrS	\S
\\	   SS4S jrS	\S
\\	   SS4S jrS	\S
\\	   SS4S jrS\\	   SS4S jrS\\	   SS4S jrS	\S
\\	   SS4S jrS	\S
\\	   SS4S jrS	\S\	S\	4S jrS	\S\\	   4S jrS	\S\	S\\	   4S jrSrg)CacheCommand   aS  
Inspect and manage pip's wheel cache.

Subcommands:

- dir: Show the cache directory.
- info: Show information about the cache.
- list: List filenames of packages stored in the cache.
- remove: Remove one or more package from the cache.
- purge: Remove all items from the cache.

``<pattern>`` can be a glob expression or a package name.
Tz
        %prog dir
        %prog info
        %prog list [<pattern>] [--format=[human, abspath]]
        %prog remove <pattern>
        %prog purge
    returnNc           	          U R                   R                  SSSSSSS9  U R                  R                  SU R                   5        g )	Nz--formatstorelist_formathuman)r   abspathz:Select the output format among: human (default) or abspath)actiondestdefaultchoiceshelpr   )cmd_opts
add_optionparserinsert_option_groupselfs    T/var/www/auris/envauris/lib/python3.13/site-packages/pip/_internal/commands/cache.pyadd_optionsCacheCommand.add_options(   sE      (M 	! 	
 	''4==9    c                 v    U R                   U R                  U R                  U R                  U R                  S.$ )N)dirinfolistremovepurge)get_cache_dirget_cache_infolist_cache_itemsremove_cache_itemspurge_cacher   s    r!   handler_mapCacheCommand.handler_map4   s9    %%''))--%%
 	
r$   optionsargsc                    U R                  5       nUR                  (       d  [        R                  S5        [        $ U(       a	  US   U;  a4  [        R                  SSR                  [        U5      5      5        [        $ US   n X4   " XSS  5        [        $ ! [         a2  n[        R                  UR                  S   5        [        s S nA$ S nAff = f)Nz<pip cache commands can not function since cache is disabled.r   zNeed an action (%s) to perform.z,    )
r0   	cache_dirloggererrorr   joinsortedr	   r3   r   )r    r2   r3   r0   r   es         r!   runCacheCommand.run=   s    &&(  LLWXL tAwk1LL1		&-. La	ab2
 	  	LL#L	s   B 
C$'CCCc                 f    U(       a  [        S5      e[        R                  UR                  5        g )NToo many arguments)r   r7   r'   r6   r    r2   r3   s      r!   r+   CacheCommand.get_cache_dirW   s#    344G%%&r$   c           
      D   U(       a  [        S5      e[        U R                  U5      5      n[        U R                  US5      5      nU R	                  US5      nU R	                  US5      nU R	                  US5      n[
        R                  " [
        R                  " U5      [
        R                  " U5      -   5      n[
        R                  " U5      n	[        R                  " S5      R                  UUUUUUU	S9R                  5       n
[        R                  U
5        g )Nr?   *http-v2httpwheelsa  
                    Package index page cache location (pip v23.3+): {http_cache_location}
                    Package index page cache location (older pips): {old_http_cache_location}
                    Package index page cache size: {http_cache_size}
                    Number of HTTP files: {num_http_files}
                    Locally built wheels location: {wheels_cache_location}
                    Locally built wheels size: {wheels_cache_size}
                    Number of locally built wheels: {package_count}
                )http_cache_locationold_http_cache_locationhttp_cache_sizenum_http_fileswheels_cache_locationpackage_countwheels_cache_size)r   len_find_http_files_find_wheels
_cache_dirr
   r   directory_sizeformat_directory_sizetextwrapdedentformatstripr7   r'   )r    r2   r3   rJ   num_packagesrG   rH   rK   rI   rM   messages              r!   r,   CacheCommand.get_cache_info]   s   344T227;<4,,Wc:;"oogyA"&//'6"B $ B$00%%&9:''(?@A
 '<<=RS OO
 V$7(? /-&;*"3   UW+ 	0 	Gr$   c                     [        U5      S:  a  [        S5      eU(       a  US   nOSnU R                  X5      nUR                  S:X  a  U R	                  U5        g U R                  U5        g )Nr5   r?   r   rC   r   )rN   r   rP   r   format_for_humanformat_for_abspath)r    r2   r3   patternfiless        r!   r-   CacheCommand.list_cache_items   sd    t9q=3441gGG!!'3')!!%(##E*r$   r_   c                 r   U(       d  [         R                  S5        g / nU HP  n[        R                  R	                  U5      n[
        R                  " U5      nUR                  SU SU S35        MR     [         R                  S5        [         R                  SR                  [        U5      5      5        g )NzNo locally built wheels cached.z - z ()zCache contents:

)
r7   r'   ospathbasenamer
   format_file_sizeappendr9   r:   )r    r_   resultsfilenamewheelsizes         r!   r\   CacheCommand.format_for_human   s    KK9:HGG$$X.E..x8DNNSr$q12  	'(DIIfWo./r$   c                 n    U(       a.  [         R                  SR                  [        U5      5      5        g g )Nrc   )r7   r'   r9   r:   )r    r_   s     r!   r]   CacheCommand.format_for_abspath   s#    KK		&-01 r$   c                    [        U5      S:  a  [        S5      eU(       d  [        S5      eU R                  XS   5      nSnUS   S:X  a  X0R                  U5      -  nOUSUS    S3-  nU(       d  [        R                  U5        SnU HR  nU[        R                  " U5      R                  -  n[        R                  " U5        [        R                  S	U5        MT     [        R                  S
[        U5      [        U5      5        g )Nr5   r?   zPlease provide a patternr   zNo matching packagesrC   z for pattern ""z
Removed %szFiles removed: %s (%s))rN   r   rP   rO   r7   warningrd   statst_sizeunlinkverboser'   r   )r    r2   r3   r_   no_matching_msgbytes_removedrj   s          r!   r.   CacheCommand.remove_cache_items   s    t9q=3449::!!'7307c>**733E Qy::ONN?+HRWWX.666MIIhNN<2  	,c%j+m:TUr$   c                 L    U(       a  [        S5      eU R                  US/5      $ )Nr?   rC   )r   r.   r@   s      r!   r/   CacheCommand.purge_cache   s&    344&&w66r$   subdirc                 V    [         R                  R                  UR                  U5      $ )N)rd   re   r9   r6   )r    r2   r|   s      r!   rQ   CacheCommand._cache_dir   s    ww||G--v66r$   c                     U R                  US5      nU R                  US5      n[        R                  " US5      [        R                  " US5      -   $ )NrE   rD   rC   rQ   r
   
find_files)r    r2   old_http_dirnew_http_dirs       r!   rO   CacheCommand._find_http_files   sN    w7w	:$$\37*:O:O#;
 
 	
r$   r^   c                 l    U R                  US5      nUSU;   a  SOS-   n[        R                  " X25      $ )NrF   -z*.whlz-*.whlr   )r    r2   r^   	wheel_dirs       r!   rP   CacheCommand._find_wheels   s7    OOGX6	$ wWHE$$Y88r$    )r   N)__name__
__module____qualname____firstlineno____doc__ignore_require_venvusager"   dictstrr   r   r(   r0   intr<   r+   r,   r-   r\   r]   r.   r/   rQ   rO   rP   __static_attributes__r   r$   r!   r   r      sz    E
:
T#xc0CT0I'J"JK 
6 c s 4'V '49 ' '(f (DI ($ (T+ +d3i +D +0d3i 0D 02S	 2d 2V& VS	 Vd V676 7c 7t 77& 7# 7# 7
 
49 
9F 9S 9T#Y 9r$   r   )rd   rT   optparser   typingr   pip._internal.cli.base_commandr   pip._internal.cli.status_codesr   r   pip._internal.exceptionsr   r	   pip._internal.utilsr
   pip._internal.utils.loggingr   pip._internal.utils.miscr   r   r7   r   r   r$   r!   <module>r      s;    	    2 9 ; * 1 0	8	W97 W9r$   