o 7]hd@sddlZddlZddlmZddlmZmZddlmm m Z ddl m Z ddl mZmZddlmZmZddlmZeeZGdd d e ZdS) N)Values)AnyList)Command)ERRORSUCCESS) CommandErrorPipError) getLoggerc@s0eZdZdZdZdZd#ddZded ee de fd d Z ded ee ddfd d Z ded ee ddfddZded ee ddfddZdee ddfddZdee ddfddZded ee ddfddZded ee ddfddZdede de fddZdedee fddZded 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. ```` can be a glob expression or a package name. Tz %prog dir %prog info %prog list [] [--format=[human, abspath]] %prog remove %prog purge returnNcCs,|jjddddddd|jd|jdS) Nz--formatstore list_formathuman)rabspathz:Select the output format among: human (default) or abspath)actiondestdefaultchoiceshelpr)cmd_opts add_optionparserinsert_option_group)selfr>/usr/lib/python3/dist-packages/pip/_internal/commands/cache.py add_options's zCacheCommand.add_optionsoptionsargsc Cs|j|j|j|j|jd}|jstdtS|r|d|vr,tdd t |tS|d}z||||ddWt St yZ}zt|j dtWYd}~Sd}~ww)N)dirinfolistremovepurgezrr@rformat_for_humanformat_for_abspath)rrrpatternfilesrrrr(~s    zCacheCommand.list_cache_itemsrMcCsp|s tddSg}|D]}tj|}t|}|d|d|dq tdtdt |dS)NzNothing cached.z - z ()zCache contents:  ) r,r!ospathbasenamerBformat_file_sizeappendr.r/)rrMresultsfilenamewheelsizerrrrJs    zCacheCommand.format_for_humancCs8|sdSg}|D]}||qtdt|dS)NrO)rTr,r!r.r/)rrMrUrVrrrrKs  zCacheCommand.format_for_abspathcCst|dkr td|std|||d}d}|ddkr(|||7}n |d|d7}|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,warningrPunlinkverboser!)rrrrMno_matching_msgrVrrrr)s    zCacheCommand.remove_cache_itemscCs|rtd||dgS)Nr3r5)rr)r4rrrr*szCacheCommand.purge_cachesubdircCstj|j|S)N)rPrQr.r+)rrr]rrrrAszCacheCommand._cache_dircCs||d}t|dS)Nr6r5rArB find_files)rrhttp_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_venvusagerrrstrintr2rr&r'r(rJrKr)r*rAr?r@rrrrr s    $  r )rPrDoptparsertypingrrpip._internal.utils.filesystem _internalutilsrBpip._internal.cli.base_commandrpip._internal.cli.status_codesrrpip._internal.exceptionsrr pip._internal.utils.loggingr rcr,r rrrrs