本文整理汇总了Python中pip._internal.commands.get_summaries方法的典型用法代码示例。如果您正苦于以下问题:Python commands.get_summaries方法的具体用法?Python commands.get_summaries怎么用?Python commands.get_summaries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip._internal.commands
的用法示例。
在下文中一共展示了commands.get_summaries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_main_parser
# 需要导入模块: from pip._internal import commands [as 别名]
# 或者: from pip._internal.commands import get_summaries [as 别名]
def create_main_parser():
parser_kw = {
'usage': '\n%prog <command> [options]',
'add_help_option': False,
'formatter': UpdatingDefaultsHelpFormatter(),
'name': 'global',
'prog': get_prog(),
}
parser = ConfigOptionParser(**parser_kw)
parser.disable_interspersed_args()
pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
parser.version = 'pip %s from %s (python %s)' % (
__version__, pip_pkg_dir, sys.version[:3],
)
# add the general options
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
parser.add_option_group(gen_opts)
parser.main = True # so the help formatter knows
# create command listing for description
command_summaries = get_summaries()
description = [''] + ['%-27s %s' % (i, j) for i, j in command_summaries]
parser.description = '\n'.join(description)
return parser
示例2: get_summaries
# 需要导入模块: from pip._internal import commands [as 别名]
# 或者: from pip._internal.commands import get_summaries [as 别名]
def get_summaries():
return ((k, v.summary) for k, v in commands_dict.items())
示例3: get_main
# 需要导入模块: from pip._internal import commands [as 别名]
# 或者: from pip._internal.commands import get_summaries [as 别名]
def get_main(pip_main):
def main(argv=None):
argv = argv if argv is not None else sys.argv[1:]
def _add_platform_param(parser):
parser.add_argument(
'--platform', help=(
'Custom platform name. The default is auto-detected -- '
'Use `pip-custom-platform show-platform-name` to show.'
),
)
parser = argparse.ArgumentParser(
prog='pip-custom-platform',
description=(
'pip+wheel wrapper which allows you to choose a custom '
'platform name for building, downloading, and installing '
'wheels.\n\n'
'Any unparsed command arguments will be passed on to pip\n'
),
)
subparsers = parser.add_subparsers(dest='command')
subparsers.required = True
for cmd, summary in get_summaries():
subparser = subparsers.add_parser(cmd, help=summary)
if cmd in ('install', 'download', 'wheel'):
_add_platform_param(subparser)
if cmd == 'wheel':
subparser.add_argument(
'-w', '--wheel-dir', default='./wheelhouse',
help='Build wheels into this directory',
)
platform_name = subparsers.add_parser(
'show-platform-name', help='Show the default platform name',
)
_add_platform_param(platform_name)
args, rest = parser.parse_known_args(argv)
if args.command == 'wheel':
return _wheel(args.wheel_dir, pip_main, rest)
elif args.command == 'show-platform-name':
return _show_platform_name()
else:
return pip_main([args.command] + rest)
return main