a *eg@sddlZddlZddlmZddlmZmZddlmZddl m Z m Z ddl m Z mZddlmZddlmZeeZGd d d eZdS) N)Values)AnyList)Command)ERRORSUCCESS) CommandErrorPipError) filesystem) 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)cmd_opts add_optionparserinsert_option_group)selfrF/usr/local/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)dirinfolistremovepurgezr<r?messagerrrr(Ys4     zCacheCommand.get_cache_infocCsVt|dkrtd|r"|d}nd}|||}|jdkrH||n ||dS)Nr&r4rr6r)r@rrBrformat_for_humanformat_for_abspath)rrr patternfilesrrrr)s     zCacheCommand.list_cache_items)rOr cCsp|stddSg}|D]2}tj|}t|}|d|d|dqtdtdt |dS)NzNo locally built wheels cached.z - z ()zCache contents:  ) r-r"ospathbasenamer format_file_sizeappendr/r0)rrOresultsfilenamewheelsizerrrrLs    zCacheCommand.format_for_humancCs|rtdt|dS)NrQ)r-r"r/r0)rrOrrrrMszCacheCommand.format_for_abspathcCst|dkrtd|s td|||d}d}|ddkrP|||7}n|d|dd7}|srt||D]}t|td |qvt d t|dS) Nr&r4zPlease provide a patternrzNo matching packagesr6z for pattern ""z Removed %szFiles removed: %s) r@rrBrAr-warningrRunlinkverboser")rrr rOZno_matching_msgrXrrrr*s    zCacheCommand.remove_cache_itemscCs|r td||dgS)Nr4r6)rr*r5rrrr+szCacheCommand.purge_cache)rsubdirr cCstj|j|S)N)rRrSr/r,)rrr_rrrrCszCacheCommand._cache_dir)rr cCs0||d}||d}t|dt|dS)Nr8r7r6rCr find_files)rrZ old_http_dirZ new_http_dirrrrrAs   zCacheCommand._find_http_files)rrNr cCs,||d}|d|vrdnd}t||S)Nr9-z*.whlz-*.whlr`)rrrN wheel_dirrrrrBs zCacheCommand._find_wheels)__name__ __module__ __qualname____doc__ignore_require_venvusagerrrstrintr3rr'r(r)rLrMr*r+rCrArBrrrrr s  * r )rRrGoptparsertypingrrpip._internal.cli.base_commandrpip._internal.cli.status_codesrrpip._internal.exceptionsrr Zpip._internal.utilsr pip._internal.utils.loggingr rdr-r rrrrs