HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pip/_internal/commands/__pycache__/cache.cpython-310.pyc
o

��h& �@s�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZddlmZdd	lmZee�ZGd
d�de�ZdS)�N)�Values)�Callable)�Command)�ERROR�SUCCESS)�CommandError�PipError)�
filesystem)�	getLogger)�format_sizec@sVeZdZdZdZdZd%dd�Zdeee	e
eegdfffdd	�Zd
e
deede
fdd
�Zd
e
deeddfdd�Zd
e
deeddfdd�Zd
e
deeddfdd�Zdeeddfdd�Zdeeddfdd�Zd
e
deeddfdd�Zd
e
deeddfdd�Zd
e
dedefdd�Zd
e
deefd d!�Zd
e
d"edeefd#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
    �returnNcCs,|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�G/usr/local/lib/python3.10/dist-packages/pip/_internal/commands/cache.py�add_options(s�	zCacheCommand.add_optionscCs|j|j|j|j|jd�S)N)�dir�info�list�remove�purge)�
get_cache_dir�get_cache_info�list_cache_items�remove_cache_items�purge_cacherrrr�handler_map4s�zCacheCommand.handler_map�options�argsc
Cs�|��}|jst�d�tS|r|d|vr#t�dd�t|���tS|d}z||||dd��Wt	StyQ}zt�|jd�tWYd}~Sd}~ww)Nz<pip cache commands can not function since cache is disabled.rzNeed an action (%s) to perform.z, �)
r*�	cache_dir�logger�errorr�join�sortedrr,r)rr+r,r*r�errr�run=s&
����zCacheCommand.runcCs|rtd��t�|j�dS)N�Too many arguments)rr/r!r.�rr+r,rrrr%WszCacheCommand.get_cache_dirc	Cs�|rtd��t|�|��}t|�|d��}|�|d�}|�|d�}|�|d�}t�t�|�t�|��}t�|�}	t	�
d�j|||||||	d���}
t
�|
�dS)Nr5�*�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�stripr/r!)rr+r,r>�num_packagesr;r<r?r=rA�messagerrrr&]s8��
���zCacheCommand.get_cache_infocCsXt|�dkr
td��|r|d}nd}|�||�}|jdkr%|�|�dS|�|�dS)Nr-r5rr7r)rBrrDr�format_for_human�format_for_abspath)rr+r,�pattern�filesrrrr'�s

zCacheCommand.list_cache_itemsrQcCsp|s	t�d�dSg}|D]}tj�|�}t�|�}|�d|�d|�d��q
t�d�t�d�t	|���dS)NzNo locally built wheels cached.z - z (�)zCache contents:
�
)
r/r!�os�path�basenamer	�format_file_size�appendr1r2)rrQ�results�filename�wheel�sizerrrrN�s


zCacheCommand.format_for_humancCs |rt�d�t|���dSdS)NrS)r/r!r1r2)rrQrrrrO�s�zCacheCommand.format_for_abspathcCs�t|�dkr
td��|std��|�||d�}d}|ddkr(||�|�7}n
|d|d�d�7}|s9t�|�d}|D]}|t�|�j7}t�	|�t�
d	|�q=t�d
t|�t|��dS)Nr-r5zPlease provide a patternrzNo matching packagesr7z for pattern "�"z
Removed %szFiles removed: %s (%s))
rBrrDrCr/�warningrT�stat�st_size�unlink�verboser!r)rr+r,rQ�no_matching_msg�
bytes_removedrZrrrr(�s"

zCacheCommand.remove_cache_itemscCs|rtd��|�|dg�S)Nr5r7)rr(r6rrrr)�szCacheCommand.purge_cache�subdircCstj�|j|�S)N)rTrUr1r.)rr+rerrrrE�szCacheCommand._cache_dircCs0|�|d�}|�|d�}t�|d�t�|d�S)Nr9r8r7�rEr	�
find_files)rr+�old_http_dir�new_http_dirrrrrC�s
�zCacheCommand._find_http_filesrPcCs,|�|d�}|d|vr
dnd}t�||�S)Nr:�-z*.whlz-*.whlrf)rr+rP�	wheel_dirrrrrD�szCacheCommand._find_wheels)r
N)�__name__�
__module__�__qualname__�__doc__�ignore_require_venv�usager�dict�strrrr"r*�intr4r%r&r'rNrOr(r)rErCrDrrrrrs"
&	*
r)rTrH�optparser�typingr�pip._internal.cli.base_commandr�pip._internal.cli.status_codesrr�pip._internal.exceptionsrr�pip._internal.utilsr	�pip._internal.utils.loggingr
�pip._internal.utils.miscrrlr/rrrrr�<module>s