HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/commands/__pycache__/cache.cpython-37.pyc
B

L��g�@s�ddlZddlZddlmZddlmZmZddlmZddl	m
Z
mZddlm
Z
mZddlmZddlmZee�ZGd	d
�d
e�ZdS)�N)�Values)�Any�List)�Command)�ERROR�SUCCESS)�CommandError�PipError)�
filesystem)�	getLoggerc@seZdZdZdZdZdd�dd�Zeee	e
d�d	d
�Zeeedd�dd�Z
eeedd�d
d�Zeeedd�dd�Zee	dd�dd�Zee	dd�dd�Zeeedd�dd�Zeeedd�dd�Zee	e	d�dd�Zeee	d�dd�Zee	ee	d �d!d"�ZdS)#�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
    N)�returncCs,|jjddddddd�|j�d|j�dS)	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)�self�r�@/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/commands/cache.py�add_options'szCacheCommand.add_options)�options�argsr
c
Cs�|j|j|j|j|jd�}|js.t�d�tS|r>|d|krXt�dd�	t
|���tS|d}y||||dd��Wn2tk
r�}zt�|jd�tSd}~XYnXt
S)N)�dir�info�list�remove�purgez<pip cache commands can not function since cache is disabled.rzNeed 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)rrr �handlersr�errr�run3s(

zCacheCommand.runcCs|rtd��t�|j�dS)NzToo many arguments)rr-r"r,)rrr rrrr'SszCacheCommand.get_cache_dirc	Cs�|rtd��t|�|��}t|�|d��}|�|d�}|�|d�}|�|d�}t�t�|�t�|��}t�|�}	t	�
d�j|||||||	d���}
t
�|
�dS)NzToo many arguments�*zhttp-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_locationZ
package_count�wheels_cache_size)r�len�_find_http_files�_find_wheels�
_cache_dirr
�format_size�directory_size�format_directory_size�textwrap�dedent�format�stripr-r")rrr r:Znum_packagesr7r8r;r9r<�messagerrrr(Ys*
	zCacheCommand.get_cache_infocCsVt|�dkrtd��|r"|d}nd}|�||�}|jdkrH|�|�n
|�|�dS)Nr&zToo many argumentsrr4r)r=rr?r�format_for_human�format_for_abspath)rrr �pattern�filesrrrr)�s

zCacheCommand.list_cache_items)rLr
cCst|st�d�dSg}x:|D]2}tj�|�}t�|�}|�d|�d|�d��qWt�d�t�d�t	|���dS)NzNo locally built wheels cached.z - z (�)zCache contents:
�
)
r-r"�os�path�basenamer
�format_file_size�appendr/r0)rrL�results�filename�wheel�sizerrrrI�s



zCacheCommand.format_for_humancCs|rt�d�t|���dS)NrN)r-r"r/r0)rrLrrrrJ�szCacheCommand.format_for_abspathcCs�t|�dkrtd��|s td��|�||d�}d}|ddkrP||�|�7}n|d|d�d�7}|srt�|�x"|D]}t�|�t�d	|�qxWt�	d
t|��dS)Nr&zToo many argumentszPlease provide a patternrzNo matching packagesr4z for pattern "�"z
Removed %szFiles removed: %s)
r=rr?r>r-�warningrO�unlink�verboser")rrr rLZno_matching_msgrUrrrr*�s


zCacheCommand.remove_cache_itemscCs|rtd��|�|dg�S)NzToo many argumentsr4)rr*)rrr rrrr+�szCacheCommand.purge_cache)r�subdirr
cCstj�|j|�S)N)rOrPr/r,)rrr\rrrr@�szCacheCommand._cache_dir)rr
cCs0|�|d�}|�|d�}t�|d�t�|d�S)Nr5zhttp-v2r4)r@r
�
find_files)rrZold_http_dirZnew_http_dirrrrr>�szCacheCommand._find_http_files)rrKr
cCs,|�|d�}|d|krdnd}t�||�S)Nr6�-z*.whlz-*.whl)r@r
r])rrrK�	wheel_dirrrrr?�szCacheCommand._find_wheels)�__name__�
__module__�__qualname__�__doc__�ignore_require_venv�usagerrr�str�intr3rr'r(r)rIrJr*r+r@r>r?rrrrrs
 *
r)rOrD�optparser�typingrr�pip._internal.cli.base_commandr�pip._internal.cli.status_codesrr�pip._internal.exceptionsrr	Zpip._internal.utilsr
�pip._internal.utils.loggingrr`r-rrrrr�<module>s