o ¡—gdã@s˜ddlZddlZddlmZddlmZmZddlmm m Z ddl m Z ddl mZmZddlmZmZddlmZeeƒZGdd „d e ƒZdS) éN)ÚValues)ÚAnyÚList)ÚCommand)ÚERRORÚSUCCESS)Ú CommandErrorÚPipError)Ú getLoggerc@s0eZdZdZdZdZd#dd„Zded ee de fd d „Z ded 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. ```` 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|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 St yZ}zt |j d¡tWYd}~Sd}~ww)N)ÚdirÚinfoÚlistÚremoveÚpurgezrr@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ÚsizerrrrJs    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@rrrrr s    $  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,r rrrrÚs