
    жvg                         d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl	m
Z
mZ d dlmZmZ d dlmZ d dlmZ  ee          Z G d	 d
e          ZdS )    N)Values)AnyList)Command)ERRORSUCCESS)CommandErrorPipError)
filesystem)	getLoggerc                   j   e Zd ZdZdZdZddZdedee	         de
fd	Zdedee         ddfd
Zdedee         ddfdZdedee         ddfdZdee	         ddfdZdee	         ddfdZdedee         ddfdZdedee         ddfdZdede	de	fdZdedee	         fdZdede	dee	         fdZdS )CacheCommandaw  
    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                     | j                             dddddd           | j                            d| j                    d S )	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    Y/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/pip/_internal/commands/cache.pyadd_optionszCacheCommand.add_options'   sU      (M 	! 	
 	
 	
 	''4=99999    optionsargsc                    | j         | j        | j        | j        | j        d}|j        s!t                              d           t          S |r
|d         |vrBt                              dd	                    t          |                               t          S |d         }	  ||         ||dd                     nC# t          $ r6}t                              |j        d                    t          cY d }~S d }~ww xY wt          S )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   runzCacheCommand.run3   s   %')-%
 
   	LLWXXXL  	tAwh..LL1		&**++   La	HVWd122h//// 	 	 	LL###LLLLLL	 s   !B< <
C<+C71C<7C<c                 f    |rt          d          t                              |j                   d S )NToo many arguments)r	   r1   r&   r0   r   r"   r#   s      r   r+   zCacheCommand.get_cache_dirS   s4     	53444G%&&&&&r!   c           	         |rt          d          t          |                     |                    }t          |                     |d                    }|                     |d          }|                     |d          }|                     |d          }t          j        t          j        |          t          j        |          z             }t          j        |          }	t          j
        d                              |||||||	                                          }
t                              |
           d S )Nr9   *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   format_sizedirectory_sizeformat_directory_sizetextwrapdedentformatstripr1   r&   )r   r"   r#   rC   num_packagesr@   rA   rD   rB   rF   messages              r   r,   zCacheCommand.get_cache_infoY   sB    	53444T227;;<<4,,Wc::;;"oogyAA"&//'6"B"B $ B B$0%&9::'(?@@A
 
 '<=RSS O
 
 V$7(? /-&;*"3    UWW+ 	0 	Gr!   c                     t          |          dk    rt          d          |r	|d         }nd}|                     ||          }|j        dk    r|                     |           d S |                     |           d S )Nr*   r9   r   r<   r   )rG   r	   rI   r   format_for_humanformat_for_abspath)r   r"   r#   patternfiless        r   r-   zCacheCommand.list_cache_items   s    t99q==3444 	1gGGG!!'733'))!!%(((((##E*****r!   rX   c                    |st                               d           d S g }|D ]Q}t          j                            |          }t          j        |          }|                    d| d| d           Rt                               d           t                               d                    t          |                               d S )NzNo locally built wheels cached.z - z ()zCache contents:

)
r1   r&   ospathbasenamer   format_file_sizeappendr3   r4   )r   rX   resultsfilenamewheelsizes         r   rU   zCacheCommand.format_for_human   s     	KK9:::F 	3 	3HG$$X..E.x88DNN111$1112222'(((DIIfWoo../////r!   c                     |r<t                               d                    t          |                               d S d S )Nr[   )r1   r&   r3   r4   )r   rX   s     r   rV   zCacheCommand.format_for_abspath   s>     	2KK		&--0011111	2 	2r!   c                     t          |          dk    rt          d          |st          d          |                     ||d                   }d}|d         dk    r||                     |          z  }n|d|d          dz  }|st                              |           |D ]1}t          j        |           t                              d	|           2t          	                    d
t          |                     d S )Nr*   r9   zPlease provide a patternr   zNo matching packagesr<   z for pattern ""z
Removed %szFiles removed: %s)
rG   r	   rI   rH   r1   warningr\   unlinkverboser&   )r   r"   r#   rX   no_matching_msgrb   s         r   r.   zCacheCommand.remove_cache_items   s	   t99q==3444 	;9:::!!'473307c>>T**7333EE :Q::::O 	,NN?+++ 	3 	3HIhNN<2222'U44444r!   c                 R    |rt          d          |                     |dg          S )Nr9   r<   )r	   r.   r:   s      r   r/   zCacheCommand.purge_cache   s1     	53444&&w666r!   subdirc                 L    t           j                            |j        |          S )N)r\   r]   r3   r0   )r   r"   rm   s      r   rJ   zCacheCommand._cache_dir   s    w||G-v666r!   c                     |                      |d          }|                      |d          }t          j        |d          t          j        |d          z   S )Nr>   r=   r<   rJ   r   
find_files)r   r"   old_http_dirnew_http_dirs       r   rH   zCacheCommand._find_http_files   sV    w77w	::$\377*:O#;
 ;
 
 	
r!   rW   c                 n    |                      |d          }|d|v rdndz   }t          j        ||          S )Nr?   -z*.whlz-*.whlrp   )r   r"   rW   	wheel_dirs       r   rI   zCacheCommand._find_wheels   s@    OOGX66	$ wWWHE$Y888r!   )r   N)__name__
__module____qualname____doc__ignore_require_venvusager    r   r   strintr7   r   r+   r,   r-   rU   rV   r.   r/   rJ   rH   rI    r!   r   r   r      s         E
: 
: 
: 
:6 c s    @'V '49 ' ' ' ' '(f (DI ($ ( ( ( (T+ +d3i +D + + + +0d3i 0D 0 0 0 02S	 2d 2 2 2 25& 5S	 5d 5 5 5 5276 7c 7t 7 7 7 77& 7# 7# 7 7 7 7
 
49 
 
 
 
9F 9S 9T#Y 9 9 9 9 9 9r!   r   )r\   rN   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   rw   r1   r   r   r!   r   <module>r      s    				                2 2 2 2 2 2 9 9 9 9 9 9 9 9 ; ; ; ; ; ; ; ; * * * * * * 1 1 1 1 1 1	8		R9 R9 R9 R9 R97 R9 R9 R9 R9 R9r!   