mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Add option to output full path of cache enty
This commit is contained in:
parent
8663855711
commit
0b3ba87bbf
1 changed files with 19 additions and 4 deletions
|
@ -37,11 +37,21 @@ class CacheCommand(Command):
|
|||
usage = """
|
||||
%prog dir
|
||||
%prog info
|
||||
%prog list [<pattern>]
|
||||
%prog list [<pattern>] [--abspath]
|
||||
%prog remove <pattern>
|
||||
%prog purge
|
||||
"""
|
||||
|
||||
def add_options(self):
|
||||
# type: () -> None
|
||||
self.cmd_opts.add_option(
|
||||
'--abspath',
|
||||
dest='abspath',
|
||||
action='store_true',
|
||||
help='List the absolute path of wheels')
|
||||
|
||||
self.parser.insert_option_group(0, self.cmd_opts)
|
||||
|
||||
def run(self, options, args):
|
||||
# type: (Values, List[Any]) -> int
|
||||
handlers = {
|
||||
|
@ -118,15 +128,20 @@ class CacheCommand(Command):
|
|||
files = self._find_wheels(options, pattern)
|
||||
|
||||
if not files:
|
||||
logger.info('Nothing cached.')
|
||||
if not options.abspath:
|
||||
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')
|
||||
if options.abspath:
|
||||
results.append(filename)
|
||||
else:
|
||||
results.append(' - {} ({})'.format(wheel, size))
|
||||
if not options.abspath:
|
||||
logger.info('Cache contents:\n')
|
||||
logger.info('\n'.join(sorted(results)))
|
||||
|
||||
def remove_cache_items(self, options, args):
|
||||
|
|
Loading…
Reference in a new issue