2 Package containing all pip commands
4 from __future__ import absolute_import
6 from pip.commands.completion import CompletionCommand
7 from pip.commands.download import DownloadCommand
8 from pip.commands.freeze import FreezeCommand
9 from pip.commands.hash import HashCommand
10 from pip.commands.help import HelpCommand
11 from pip.commands.list import ListCommand
12 from pip.commands.check import CheckCommand
13 from pip.commands.search import SearchCommand
14 from pip.commands.show import ShowCommand
15 from pip.commands.install import InstallCommand
16 from pip.commands.uninstall import UninstallCommand
17 from pip.commands.wheel import WheelCommand
21 CompletionCommand.name: CompletionCommand,
22 FreezeCommand.name: FreezeCommand,
23 HashCommand.name: HashCommand,
24 HelpCommand.name: HelpCommand,
25 SearchCommand.name: SearchCommand,
26 ShowCommand.name: ShowCommand,
27 InstallCommand.name: InstallCommand,
28 UninstallCommand.name: UninstallCommand,
29 DownloadCommand.name: DownloadCommand,
30 ListCommand.name: ListCommand,
31 CheckCommand.name: CheckCommand,
32 WheelCommand.name: WheelCommand,
52 def get_summaries(ordered=True):
53 """Yields sorted (command name, command summary) tuples."""
56 cmditems = _sort_commands(commands_dict, commands_order)
58 cmditems = commands_dict.items()
60 for name, command_class in cmditems:
61 yield (name, command_class.summary)
64 def get_similar_commands(name):
65 """Command name auto-correct."""
66 from difflib import get_close_matches
70 close_commands = get_close_matches(name, commands_dict.keys())
73 return close_commands[0]
78 def _sort_commands(cmddict, order):
81 return order.index(key[1])
83 # unordered items should come last
86 return sorted(cmddict.items(), key=keyfn)