本文整理汇总了Python中argparse.ArgumentParser.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ArgumentParser.__init__方法的具体用法?Python ArgumentParser.__init__怎么用?Python ArgumentParser.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argparse.ArgumentParser
的用法示例。
在下文中一共展示了ArgumentParser.__init__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_execute_exception
# 需要导入模块: from argparse import ArgumentParser [as 别名]
# 或者: from argparse.ArgumentParser import __init__ [as 别名]
def test_execute_exception(self):
self.par = ArgumentParser.__init__
self.trb = traceback.format_exc
self.err = logger.error
self.isu = git_issuer.handle_error
traceback.format_exc = Mock()
logger.error = Mock()
git_issuer.handle_error = Mock()
ArgumentParser.__init__ = Mock(side_effect=Exception)
cmdline.execute('True')
git_issuer.handle_error.assert_called_once()
ArgumentParser.__init__ = self.par
traceback.format_exc = self.trb
logger.error = self.err
git_issuer.handle_error = self.isu
示例2: __init__
# 需要导入模块: from argparse import ArgumentParser [as 别名]
# 或者: from argparse.ArgumentParser import __init__ [as 别名]
def __init__(self, **kwargs):
"""Follow normal initialization and add BACpypes arguments."""
if _debug: ArgumentParser._debug("__init__")
if not _argparse_success:
raise ImportError("No module named argparse, install via pip or easy_install: https://pypi.python.org/pypi/argparse\n")
_ArgumentParser.__init__(self, **kwargs)
# add a way to get a list of the debugging hooks
self.add_argument("--buggers",
help="list the debugging logger names",
action="store_true",
)
# add a way to attach debuggers
self.add_argument('--debug', nargs='*',
help="add a log handler to each debugging logger",
)
# add a way to turn on color debugging
self.add_argument("--color",
help="turn on color debugging",
action="store_true",
)
示例3: __init__
# 需要导入模块: from argparse import ArgumentParser [as 别名]
# 或者: from argparse.ArgumentParser import __init__ [as 别名]
def __init__(self,description, epilog=''):
ArgArgumentParser.__init__(self,description=description, epilog=epilog)
self.add_argument('--filename',
help='file to read openstack credentials from. If not set it take the environment variables' )
self.add_argument('-v', '--verbose', action='count', default=0,
help='increase output verbosity (use up to 3 times)'
'(not everywhere implemented)')
self.add_argument('--timeout', type=int, default=10,
help='amount of seconds until execution stops with unknown state (default 10 seconds)')
self.add_argument('--insecure',
default=False,
action='store_true',
help="Explicitly allow client to perform \"insecure\" "
"SSL (https) requests. The server's certificate will "
"not be verified against any certificate authorities. "
"This option should be used with caution.")
self.add_argument('--cacert',
help="Specify a CA bundle file to use in verifying a TLS"
"(https) server certificate.")
示例4: __init__
# 需要导入模块: from argparse import ArgumentParser [as 别名]
# 或者: from argparse.ArgumentParser import __init__ [as 别名]
def __init__(self, argv, **kw):
self.__argv = argv
ArgumentParser.__init__(self, **kw)
示例5: __init__
# 需要导入模块: from argparse import ArgumentParser [as 别名]
# 或者: from argparse.ArgumentParser import __init__ [as 别名]
def __init__(self):
self._data = {}
self._read()