本文整理汇总了Python中argh.ArghParser.parse_args方法的典型用法代码示例。如果您正苦于以下问题:Python ArghParser.parse_args方法的具体用法?Python ArghParser.parse_args怎么用?Python ArghParser.parse_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argh.ArghParser
的用法示例。
在下文中一共展示了ArghParser.parse_args方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eventparser_entry
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import parse_args [as 别名]
def eventparser_entry():
parser = ArghParser(parents=[COMMON_PARSER])
parser.set_default_command(eventparser)
completion.autocomplete(parser)
# Parse ahead
args = parser.parse_args()
if args.debug:
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s: %(message)s'
)
parser.dispatch()
示例2: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import parse_args [as 别名]
def main():
parser = ArghParser(parents=[COMMON_PARSER])
parser.add_commands(
[
ting
]
)
completion.autocomplete(parser)
# Parse ahead
args = parser.parse_args()
if args.debug:
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s: %(message)s'
)
parser.dispatch()
示例3: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import parse_args [as 别名]
def main():
"""
Main entrypoint for the application. Parses the command-line arguments the
dispatches the correct methods.
"""
parser = ArghParser(parents=[COMMON_PARSER])
parser.add_commands(
[
exporttracks, checktoken,
allaccessimport, exportplaylist
]
)
args = parser.parse_args()
if args.debug:
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s: %(message)s'
)
parser.dispatch()
示例4: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import parse_args [as 别名]
def main():
"""Main application entrypoint"""
parser = ArghParser(parents=[COMMON_PARSER])
set_default_command(parser, upload)
completion.autocomplete(parser)
# Peek CLI arguments and globally enable debugging
args = parser.parse_args()
if args.debug:
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s: %(message)s'
)
# Cut down suds logs
logging.getLogger('suds').setLevel(logging.WARNING)
if args.version:
print_version()
return
parser.dispatch()
示例5: init_parser
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import parse_args [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