/
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
pip
/
_internal
/
commands
/
/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/commands
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
cache.py
5676
0644
edit
dl
rm
cache.pyc
5611
0644
edit
dl
rm
cache.pyo
5611
0644
edit
dl
rm
check.py
1677
0644
edit
dl
rm
check.pyc
1965
0644
edit
dl
rm
check.pyo
1965
0644
edit
dl
rm
completion.py
3081
0644
edit
dl
rm
completion.pyc
3616
0644
edit
dl
rm
completion.pyo
3616
0644
edit
dl
rm
configuration.py
9344
0644
edit
dl
rm
configuration.pyc
9903
0644
edit
dl
rm
configuration.pyo
9903
0644
edit
dl
rm
debug.py
7314
0644
edit
dl
rm
debug.pyc
8288
0644
edit
dl
rm
debug.pyo
8288
0644
edit
dl
rm
download.py
4918
0644
edit
dl
rm
download.pyc
4836
0644
edit
dl
rm
download.pyo
4836
0644
edit
dl
rm
freeze.py
3452
0644
edit
dl
rm
hash.py
1843
0644
edit
dl
rm
hash.pyc
2793
0644
edit
dl
rm
hash.pyo
2793
0644
edit
dl
rm
help.py
1270
0644
edit
dl
rm
help.pyc
1731
0644
edit
dl
rm
help.pyo
1731
0644
edit
dl
rm
install.py
28727
0644
edit
dl
rm
install.pyc
21122
0644
edit
dl
rm
install.pyo
21060
0644
edit
dl
rm
list.py
11312
0644
edit
dl
rm
search.py
5756
0644
edit
dl
rm
search.pyc
6054
0644
edit
dl
rm
search.pyo
6013
0644
edit
dl
rm
show.py
6996
0644
edit
dl
rm
show.pyc
7000
0644
edit
dl
rm
show.pyo
7000
0644
edit
dl
rm
uninstall.py
3311
0644
edit
dl
rm
uninstall.pyc
3576
0644
edit
dl
rm
uninstall.pyo
3576
0644
edit
dl
rm
wheel.py
6419
0644
edit
dl
rm
wheel.pyc
5978
0644
edit
dl
rm
wheel.pyo
5886
0644
edit
dl
rm
__init__.py
4100
0644
edit
dl
rm
__init__.pyc
3570
0644
edit
dl
rm
__init__.pyo
3570
0644
edit
dl
rm
Edit:
/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/commands/cache.py
(5676B)
from __future__ import absolute_import import logging import os import textwrap import pip._internal.utils.filesystem as filesystem from pip._internal.cli.base_command import Command from pip._internal.cli.status_codes import ERROR, SUCCESS from pip._internal.exceptions import CommandError, PipError from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from optparse import Values from typing import Any, List logger = logging.getLogger(__name__) class CacheCommand(Command): """ 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. """ ignore_require_venv = True usage = """ %prog dir %prog info %prog list [<pattern>] %prog remove <pattern> %prog purge """ def run(self, options, args): # type: (Values, List[Any]) -> int handlers = { "dir": self.get_cache_dir, "info": self.get_cache_info, "list": self.list_cache_items, "remove": self.remove_cache_items, "purge": self.purge_cache, } if not options.cache_dir: logger.error("pip cache commands can not " "function since cache is disabled.") return ERROR # Determine action if not args or args[0] not in handlers: logger.error( "Need an action (%s) to perform.", ", ".join(sorted(handlers)), ) return ERROR action = args[0] # Error handling happens here, not in the action-handlers. try: handlers[action](options, args[1:]) except PipError as e: logger.error(e.args[0]) return ERROR return SUCCESS def get_cache_dir(self, options, args): # type: (Values, List[Any]) -> None if args: raise CommandError('Too many arguments') logger.info(options.cache_dir) def get_cache_info(self, options, args): # type: (Values, List[Any]) -> None if args: raise CommandError('Too many arguments') num_packages = len(self._find_wheels(options, '*')) cache_location = self._wheels_cache_dir(options) cache_size = filesystem.format_directory_size(cache_location) message = textwrap.dedent(""" Location: {location} Size: {size} Number of wheels: {package_count} """).format( location=cache_location, package_count=num_packages, size=cache_size, ).strip() logger.info(message) def list_cache_items(self, options, args): # type: (Values, List[Any]) -> None if len(args) > 1: raise CommandError('Too many arguments') if args: pattern = args[0] else: pattern = '*' files = self._find_wheels(options, pattern) if not files: logger.info('Nothing cached.') return results = [] for filename in files: wheel = os.path.basename(filename) size = filesystem.format_file_size(filename) results.append(' - {} ({})'.format(wheel, size)) logger.info('Cache contents:\n') logger.info('\n'.join(sorted(results))) def remove_cache_items(self, options, args): # type: (Values, List[Any]) -> None if len(args) > 1: raise CommandError('Too many arguments') if not args: raise CommandError('Please provide a pattern') files = self._find_wheels(options, args[0]) if not files: raise CommandError('No matching packages') for filename in files: os.unlink(filename) logger.debug('Removed %s', filename) logger.info('Files removed: %s', len(files)) def purge_cache(self, options, args): # type: (Values, List[Any]) -> None if args: raise CommandError('Too many arguments') return self.remove_cache_items(options, ['*']) def _wheels_cache_dir(self, options): # type: (Values) -> str return os.path.join(options.cache_dir, 'wheels') def _find_wheels(self, options, pattern): # type: (Values, str) -> List[str] wheel_dir = self._wheels_cache_dir(options) # The wheel filename format, as specified in PEP 427, is: # {distribution}-{version}(-{build})?-{python}-{abi}-{platform}.whl # # Additionally, non-alphanumeric values in the distribution are # normalized to underscores (_), meaning hyphens can never occur # before `-{version}`. # # Given that information: # - If the pattern we're given contains a hyphen (-), the user is # providing at least the version. Thus, we can just append `*.whl` # to match the rest of it. # - If the pattern we're given doesn't contain a hyphen (-), the # user is only providing the name. Thus, we append `-*.whl` to # match the hyphen before the version, followed by anything else. # # PEP 427: https://www.python.org/dev/peps/pep-0427/ pattern = pattern + ("*.whl" if "-" in pattern else "-*.whl") return filesystem.find_files(wheel_dir, pattern)
Save
cmd:
run