a [fd@sddlZddlZddlmZddlmZmZddlmm m Z ddl m Z ddl mZmZddlmZmZddlmZeeZGdd d e ZdS) N)Values)AnyList)Command)ERRORSUCCESS) CommandErrorPipError) getLoggerc@seZdZdZdZdZddddZeee e dd d Z eee ddd d Z eee ddd dZeee ddddZee ddddZee ddddZeee ddddZeee ddddZee e dddZeee dddZee 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. ```` can be a glob expression or a package name. Tz %prog dir %prog info %prog list [] [--format=[human, abspath]] %prog remove %prog purge N)returncCs,|jjddddddd|jd|jdS) Nz--formatstore list_formathuman)rabspathz:Select the output format among: human (default) or abspath)actiondestdefaultchoiceshelpr)Zcmd_optsZ add_optionparserZinsert_option_group)selfr@/usr/lib/python3.9/site-packages/pip/_internal/commands/cache.py add_options's zCacheCommand.add_options)optionsargsr c Cs|j|j|j|j|jd}|js.tdtS|r>|d|vrXtdd t |tS|d}z||||ddWn8t y}z t|j dtWYd}~Sd}~00t S)N)dirinfolistremovepurgezZformat_file_sizeappendr+r,)rrGresultsfilenameZwheelsizerrrrDs    zCacheCommand.format_for_humancCs8|sdSg}|D]}||qtdt|dS)NrI)rMr)rr+r,)rrGrNrOrrrrEs  zCacheCommand.format_for_abspathcCst|dkrtd|s td|||d}d}|ddkrP|||7}n|d|d7}|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)ZwarningrJunlinkverboser)rrrrGZno_matching_msgrOrrrr&s    zCacheCommand.remove_cache_itemscCs|r td||dgS)Nr0r2)rr&r1rrrr'szCacheCommand.purge_cache)rsubdirr cCstj|j|S)N)rJrKr+r()rrrSrrrr=szCacheCommand._cache_dir)rr cCs||d}t|dS)Nr3r2r=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_venvusagerrrstrintr/rr#r$r%rDrEr&r'r=r;r<rrrrr s  $  r )rJr?ZoptparsertypingrrZpip._internal.utils.filesystemZ _internalZutilsr>Zpip._internal.cli.base_commandrZpip._internal.cli.status_codesrrZpip._internal.exceptionsrr Zpip._internal.utils.loggingr rVr)r rrrrs