
    q"h                         S SK r S SKrS SKJr  S SKJr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)AnyList)Command)ERRORSUCCESS)CommandErrorPipError)
filesystem)	getLogger)format_sizec                   L   \ rS rSrSrSrSrS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    N/var/www/html/env/lib/python3.13/site-packages/pip/_internal/commands/cache.pyadd_optionsCacheCommand.add_options(   sE      (M 	! 	
 	''4==9    optionsargsc                    U R                   U R                  U R                  U R                  U R                  S.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)N)dirinfolistremovepurgez<pip cache commands can not function since cache is disabled.r   zNeed an action (%s) to perform.z,    )get_cache_dirget_cache_infolist_cache_itemsremove_cache_itemspurge_cache	cache_dirloggererrorr   joinsortedr
   r&   r   )r    r%   r&   handlersr   es         r!   runCacheCommand.run4   s    %%''))--%%
   LLWXL tAwh.LL1		&*+ La	W12h/
 	  	LL#L	s   1C 
D 'C;5D ;D c                 f    U(       a  [        S5      e[        R                  UR                  5        g )NToo many arguments)r	   r4   r)   r3   r    r%   r&   s      r!   r.   CacheCommand.get_cache_dirT   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stripr4   r)   )r    r%   r&   rH   num_packagesrE   rF   rI   rG   rK   messages              r!   r/   CacheCommand.get_cache_infoZ   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 )Nr-   r=   r   rA   r   )rL   r	   rN   r   format_for_humanformat_for_abspath)r    r%   r&   patternfiless        r!   r0   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:

)
r4   r)   ospathbasenamer   format_file_sizeappendr6   r7   )r    r]   resultsfilenamewheelsizes         r!   rZ   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 )Nra   )r4   r)   r6   r7   )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 )Nr-   r=   zPlease provide a patternr   zNo matching packagesrA   z for pattern ""z
Removed %szFiles removed: %s (%s))rL   r	   rN   rM   r4   warningrb   statst_sizeunlinkverboser)   r   )r    r%   r&   r]   no_matching_msgbytes_removedrh   s          r!   r1   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=   rA   )r	   r1   r>   s      r!   r2   CacheCommand.purge_cache   s&    344&&w66r$   subdirc                 V    [         R                  R                  UR                  U5      $ )N)rb   rc   r6   r3   )r    r%   rz   s      r!   rO   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      -   $ )NrC   rB   rA   rO   r   
find_files)r    r%   old_http_dirnew_http_dirs       r!   rM   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      $ )NrD   -z*.whlz-*.whlr~   )r    r%   r\   	wheel_dirs       r!   rN   CacheCommand._find_wheels   s7    OOGX6	$ wWHE$$Y88r$    )r   N)__name__
__module____qualname____firstlineno____doc__ignore_require_venvusager"   r   r   strintr:   r   r.   r/   r0   rZ   r[   r1   r2   rO   rM   rN   __static_attributes__r   r$   r!   r   r      sR    E
:6 c s @'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   )rb   rR   optparser   typingr   r   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   r4   r   r   r$   r!   <module>r      s;    	    2 9 ; * 1 0	8	T97 T9r$   