HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_internal/commands/__pycache__/cache.cpython-310.pyc
o

@%Ned�@s�ddlZddlZddlmZddlmZmZddlmm	m
Z
ddlmZddl
mZmZddlmZmZddlmZee�ZGdd	�d	e�ZdS)
�N)�Values)�Any�List)�Command)�ERROR�SUCCESS)�CommandError�PipError)�	getLoggerc@s0eZdZdZdZdZd#dd�Zded	ee	de
fd
d�Zded	eeddfdd
�Z
ded	eeddfdd�Zded	eeddfdd�Zdee	ddfdd�Zdee	ddfdd�Zded	eeddfdd�Zded	eeddfdd�Zdede	de	fdd�Zdedee	fdd�Zded e	dee	fd!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�>/usr/lib/python3/dist-packages/pip/_internal/commands/cache.py�add_options's�	zCacheCommand.add_options�options�argsc
Cs�|j|j|j|j|jd�}|jst�d�tS|r|d|vr,t�dd�	t
|���tS|d}z||||dd��Wt
StyZ}zt�|jd�tWYd}~Sd}~ww)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	rr)rrr�handlersr�errr�run4s0�
����zCacheCommand.runcCs|rtd��t�|j�dS)N�Too many arguments)rr,r!r+�rrrrrrr&TszCacheCommand.get_cache_dirc
Cs�|rtd��t|�|��}t|�|d��}|�|d�}|�|d�}t�|�}t�|�}t�d�j	||||||d��
�}	t�|	�dS)Nr3�*�http�wheelsa�
                    Package index page cache location: {http_cache_location}
                    Package index page cache size: {http_cache_size}
                    Number of HTTP files: {num_http_files}
                    Wheels location: {wheels_cache_location}
                    Wheels size: {wheels_cache_size}
                    Number of wheels: {package_count}
                )�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_dir�
filesystem�format_directory_size�textwrap�dedent�format�stripr,r!)
rrrr:�num_packagesr8r;r9r=�messagerrrr'Zs,

�
��zCacheCommand.get_cache_infocCsXt|�dkr
td��|r|d}nd}|�||�}|jdkr%|�|�dS|�|�dS)Nr%r3rr5r)r>rr@r�format_for_human�format_for_abspath)rrr�pattern�filesrrrr(~s

zCacheCommand.list_cache_itemsrMcCsp|s	t�d�dSg}|D]}tj�|�}t�|�}|�d|�d|�d��q
t�d�t�d�t	|���dS)NzNothing cached.z - z (�)zCache contents:
�
)
r,r!�os�path�basenamerB�format_file_size�appendr.r/)rrM�results�filename�wheel�sizerrrrJ�s


zCacheCommand.format_for_humancCs8|sdSg}|D]}|�|�qt�d�t|���dS)NrO)rTr,r!r.r/)rrMrUrVrrrrK�szCacheCommand.format_for_abspathcCs�t|�dkr
td��|std��|�||d�}d}|ddkr(||�|�7}n	|d�|d�7}|s8t�|�|D]
}t�|�t�	d|�q:t�
d	t|��dS)
Nr%r3zPlease provide a patternrzNo matching packagesr5z for pattern "{}"z
Removed %szFiles removed: %s)r>rr@r?rFr,�warningrP�unlink�verboser!)rrrrM�no_matching_msgrVrrrr)�s

zCacheCommand.remove_cache_itemscCs|rtd��|�|dg�S)Nr3r5)rr)r4rrrr*�szCacheCommand.purge_cache�subdircCstj�|j|�S)N)rPrQr.r+)rrr]rrrrA�szCacheCommand._cache_dircCs|�|d�}t�|d�S)Nr6r5�rArB�
find_files)rr�http_dirrrrr?�szCacheCommand._find_http_filesrLcCs,|�|d�}|d|vr
dnd}t�||�S)Nr7�-z*.whlz-*.whlr^)rrrL�	wheel_dirrrrr@�szCacheCommand._find_wheels)rN)�__name__�
__module__�__qualname__�__doc__�ignore_require_venv�usagerrr�str�intr2rr&r'r(rJrKr)r*rAr?r@rrrrrs 

 $

r)rPrD�optparser�typingrr�pip._internal.utils.filesystem�	_internal�utilsrB�pip._internal.cli.base_commandr�pip._internal.cli.status_codesrr�pip._internal.exceptionsrr	�pip._internal.utils.loggingr
rcr,rrrrr�<module>s