本文整理汇总了Python中argh.ArghParser.formatter_class方法的典型用法代码示例。如果您正苦于以下问题:Python ArghParser.formatter_class方法的具体用法?Python ArghParser.formatter_class怎么用?Python ArghParser.formatter_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argh.ArghParser
的用法示例。
在下文中一共展示了ArghParser.formatter_class方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_parser
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import formatter_class [as 别名]
#.........这里部分代码省略.........
if isinstance(args.index_url, ITERABLE_T):
args.index_url = args.index_url[0]
args_manager['install']['packages_url'] = args.index_url + '/simple'
args_manager['install']['index_url'] = args.index_url + '/pypi'
if args.download_dir != args_manager['download']['download_dir']:
args_manager['download']['download_dir'] = args.download_dir
if args.prefer != args_manager['download']['prefer']:
args_manager['download']['prefer'] = args.prefer
if args.unpack:
args_manager['download']['unpack'] = True
opts.download_func(args)
@arg('-i', '--index-url', default='http://pypi.python.org', metavar='<url>', help='Base URL of Python Package Index (default to %(default)s)')
@arg('-y', '--yes', action='store_true', help='Do not ask confirmation for the upgrade')
def update(args):
'''
Check for updates for installed packages
'''
if isinstance(args.index_url, ITERABLE_T):
args.index_url = args.index_url[0]
args_manager['install']['packages_url'] = args.index_url + '/simple'
args_manager['install']['index_url'] = args.index_url + '/pypi'
if args.yes:
args_manager['update']['yes'] = True
opts.update_func()
@command
def shell():
'''
Fire up Pyg Shell
'''
opts.shell_func()
@arg('bundlename', help='Name of the bundle to create')
@arg('packages', nargs='*', help='Name of the package(s) to bundle')
@arg('-i', '--index-url', default='http://pypi.python.org', metavar='<url>', help='Base URL of Python Package Index (default to %(default)s)')
@arg('-r', '--req-file', action='append', metavar='<path>', help='Requirement files which contains packages to bundle')
@arg('-e', '--exclude', action='append', default=[], metavar='<requirement>', help='Exclude packages matching `requirement`')
@arg('-d', '--use-develop', action='store_true', help='Look for local packages before downloading them')
def bundle(args):
'''
Create bundles (like Pip's ones)
'''
if isinstance(args.index_url, ITERABLE_T):
args.index_url = args.index_url[0]
args_manager['install']['packages_url'] = args.index_url + '/simple'
args_manager['install']['index_url'] = args.index_url + '/pypi'
if args.exclude:
args_manager['bundle']['exclude'] = args.exclude
if args.use_develop:
args_manager['bundle']['use_develop'] = True
exclude, use_develop = args_manager['bundle']['exclude'], args_manager['bundle']['use_develop']
opts.bundle_func(args.packages, args.bundlename, exclude, args.req_file, use_develop)
@arg('packname', help='Name of the pack to create')
@arg('package', help='Name of the package to pack')
@arg('-i', '--index-url', default='http://pypi.python.org', metavar='<url>', help='Base URL of Python Package Index (default to %(default)s)')
@arg('-d', '--use-develop', action='store_true', help='Look for local packages before downloading them')
@arg('-e', '--exclude', action='append', default=[], metavar='<requirement>', help='Exclude packages matching `requirement`')
def pack(args):
'''
Create packs
'''
if isinstance(args.index_url, ITERABLE_T):
args.index_url = args.index_url[0]
args_manager['install']['packages_url'] = args.index_url + '/simple'
args_manager['install']['index_url'] = args.index_url + '/pypi'
# XXX: Duplication is evil. (See above.)
if args.exclude:
args_manager['pack']['exclude'] = args.exclude
if args.use_develop:
args_manager['pack']['use_develop'] = True
exclude, use_develop = args_manager['pack']['exclude'], args_manager['pack']['use_develop']
return opts.pack_func(args.package, args.packname, exclude, use_develop)
@command
def help():
'''
Show this help and exit
'''
return
parser.add_commands([install, remove, site, link, unlink, list, pack,
search, check, download, update, shell, bundle, help])
parser.formatter_class = _formatter(parser)
if parser.parse_args(sys.argv[1:]).no_colors:
args_manager['global']['no_colors'] = True
return parser