Current File : //lib/python3.9/site-packages/pip/_internal/commands/__pycache__/cache.cpython-39.pyc
a

[��fd�@s�ddlZddlZddlmZddlmZmZddlmm	m
Z
ddlmZddl
mZmZddlmZmZddlmZee�ZGdd	�d	e�ZdS)
�N)�Values)�Any�List)�Command)�ERROR�SUCCESS)�CommandError�PipError)�	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)Zcmd_optsZ
add_option�parserZinsert_option_group)�self�r�@/usr/lib/python3.9/site-packages/pip/_internal/commands/cache.py�add_options's�	zCacheCommand.add_options)�options�argsrc
Cs�|j|j|j|j|jd�}|js.t�d�tS|r>|d|vrXt�dd�	t
|���tS|d}z||||dd��Wn8ty�}z t�|jd�tWYd}~Sd}~00t
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	rr)rrr�handlersr�errr�run4s,�
�zCacheCommand.runcCs|rtd��t�|j�dS)N�Too many arguments)rr)rr(�rrrrrrr#TszCacheCommand.get_cache_dirc
Cs�|rtd��t|�|��}t|�|d��}|�|d�}|�|d�}t�|�}t�|�}t�d�j	||||||d��
�}	t�|	�dS)Nr0�*�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_locationZ
package_count�wheels_cache_size)
r�len�_find_http_files�_find_wheels�
_cache_dir�
filesystemZformat_directory_size�textwrap�dedent�format�stripr)r)
rrrr7Znum_packagesr5r8r6r9�messagerrrr$Zs(

���zCacheCommand.get_cache_infocCsVt|�dkrtd��|r"|d}nd}|�||�}|jdkrH|�|�n
|�|�dS)Nr"r0rr2r)r:rr<r�format_for_human�format_for_abspath)rrr�pattern�filesrrrr%~s

zCacheCommand.list_cache_items)rGrcCsp|st�d�dSg}|D]2}tj�|�}t�|�}|�d|�d|�d��qt�d�t�d�t	|���dS)NzNothing cached.z - z (�)zCache contents:
�
)
r)r�os�path�basenamer>Zformat_file_size�appendr+r,)rrG�results�filenameZwheel�sizerrrrD�s


zCacheCommand.format_for_humancCs8|sdSg}|D]}|�|�qt�d�t|���dS)NrI)rMr)rr+r,)rrGrNrOrrrrE�szCacheCommand.format_for_abspathcCs�t|�dkrtd��|s td��|�||d�}d}|ddkrP||�|�7}n|d�|d�7}|spt�|�|D]}t�|�t�	d|�qtt�
d	t|��dS)
Nr"r0zPlease provide a patternrzNo matching packagesr2z for pattern "{}"z
Removed %szFiles removed: %s)r:rr<r;rAr)ZwarningrJ�unlink�verboser)rrrrGZno_matching_msgrOrrrr&�s

zCacheCommand.remove_cache_itemscCs|rtd��|�|dg�S)Nr0r2)rr&r1rrrr'�szCacheCommand.purge_cache)r�subdirrcCstj�|j|�S)N)rJrKr+r()rrrSrrrr=�szCacheCommand._cache_dir)rrcCs|�|d�}t�|d�S)Nr3r2�r=r>Z
find_files)rrZhttp_dirrrrr;�szCacheCommand._find_http_files)rrFrcCs,|�|d�}|d|vrdnd}t�||�S)Nr4�-z*.whlz-*.whlrT)rrrFZ	wheel_dirrrrr<�szCacheCommand._find_wheels)�__name__�
__module__�__qualname__�__doc__Zignore_require_venv�usagerrr�str�intr/rr#r$r%rDrEr&r'r=r;r<rrrrrs
 $

r)rJr?Zoptparser�typingrrZpip._internal.utils.filesystemZ	_internalZutilsr>Zpip._internal.cli.base_commandrZpip._internal.cli.status_codesrrZpip._internal.exceptionsrr	Zpip._internal.utils.loggingr
rVr)rrrrr�<module>s