本文整理汇总了Python中optparse.OptionGroup方法的典型用法代码示例。如果您正苦于以下问题:Python optparse.OptionGroup方法的具体用法?Python optparse.OptionGroup怎么用?Python optparse.OptionGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optparse
的用法示例。
在下文中一共展示了optparse.OptionGroup方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def __init__(self, sslyze_version: str) -> None:
"""Generate SSLyze's command line parser.
"""
self._parser = OptionParser(version=sslyze_version, usage=self.SSLYZE_USAGE)
# Add generic command line options to the parser
self._add_default_options()
# Add plugin .ie scan command options to the parser
scan_commands_group = OptionGroup(self._parser, "Scan commands", "")
for option in self._get_plugin_scan_commands():
scan_commands_group.add_option(f"--{option.option}", help=option.help, action=option.action)
self._parser.add_option_group(scan_commands_group)
# Add the --regular command line parameter as a shortcut if possible
self._parser.add_option(
"--regular",
action="store_true",
dest=None,
help=f"Regular HTTPS scan; shortcut for --{'--'.join(self.REGULAR_CMD)}",
)
示例2: action_runserver
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def action_runserver(name, args):
"""run a llvmlab instance"""
import llvmlab
from optparse import OptionParser, OptionGroup
parser = OptionParser("%%prog %s [options]" % name)
parser.add_option("", "--reloader", dest="reloader", default=False,
action="store_true", help="use WSGI reload monitor")
parser.add_option("", "--debugger", dest="debugger", default=False,
action="store_true", help="use WSGI debugger")
parser.add_option("", "--profiler", dest="profiler", default=False,
action="store_true", help="enable WSGI profiler")
(opts, args) = parser.parse_args(args)
if len(args) != 0:
parser.error("invalid number of arguments")
app = llvmlab.ui.app.App.create_standalone()
if opts.debugger:
app.debug = True
if opts.profiler:
app.wsgi_app = werkzeug.contrib.profiler.ProfilerMiddleware(
app.wsgi_app, stream = open('profiler.log', 'w'))
app.run(use_reloader = opts.reloader,
use_debugger = opts.debugger)
示例3: add_option_group
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def add_option_group(self, group_name, _, options, provider):
# add option group to the command line parser
if group_name in self._mygroups:
group = self._mygroups[group_name]
else:
group = optparse.OptionGroup(self.cmdline_parser,
title=group_name.capitalize())
self.cmdline_parser.add_option_group(group)
group.level = provider.level
self._mygroups[group_name] = group
# add section to the config file
if group_name != "DEFAULT" and \
group_name not in self.cfgfile_parser._sections:
self.cfgfile_parser.add_section(group_name)
# add provider's specific options
for opt, optdict in options:
self.add_optik_option(provider, group, opt, optdict)
示例4: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def __init__(self, isolated=False):
parser_kw = {
'usage': self.usage,
'prog': '%s %s' % (get_prog(), self.name),
'formatter': UpdatingDefaultsHelpFormatter(),
'add_help_option': False,
'name': self.name,
'description': self.__doc__,
'isolated': isolated,
}
self.parser = ConfigOptionParser(**parser_kw)
# Commands should add options to this option group
optgroup_name = '%s Options' % self.name.capitalize()
self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name)
# Add the general options
gen_opts = cmdoptions.make_option_group(
cmdoptions.general_group,
self.parser,
)
self.parser.add_option_group(gen_opts)
示例5: add_option_group
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def add_option_group(self, group_name, _, options, provider):
# add option group to the command line parser
if group_name in self._mygroups:
group = self._mygroups[group_name]
else:
group = optparse.OptionGroup(
self.cmdline_parser, title=group_name.capitalize()
)
self.cmdline_parser.add_option_group(group)
group.level = provider.level
self._mygroups[group_name] = group
# add section to the config file
if (
group_name != "DEFAULT"
and group_name not in self.cfgfile_parser._sections
):
self.cfgfile_parser.add_section(group_name)
# add provider's specific options
for opt, optdict in options:
self.add_optik_option(provider, group, opt, optdict)
示例6: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def __init__(self):
optparse.OptionParser.__init__(self,
usage=('Usage: %prog [options] '
'[koji-pkg-spec]'))
general = optparse.OptionGroup(self, 'GENERAL OPTIONS')
general.add_option('-a', '--arch', dest='arch', default='x86_64',
help=('architecture of packages to list, together '
'with "noarch". defaults to "x86_64"'))
general.add_option('-t', '--tag', dest='tag', help='default koji tag')
self.add_option_group(general)
cartesian_config = optparse.OptionGroup(self, 'CARTESIAN CONFIG')
cartesian_config.add_option('-c', '--config', dest='config',
help=('use a cartesian configuration file '
'for fetching package values'))
self.add_option_group(cartesian_config)
示例7: getHachoirOptions
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def getHachoirOptions(parser):
"""
Create an option group (type optparse.OptionGroup) of Hachoir
library options.
"""
def setLogFilename(*args):
log.setFilename(args[2])
common = OptionGroup(parser, _("Hachoir library"), \
"Configure Hachoir library")
common.add_option("--verbose", help=_("Verbose mode"),
default=False, action="store_true")
common.add_option("--log", help=_("Write log in a file"),
type="string", action="callback", callback=setLogFilename)
common.add_option("--quiet", help=_("Quiet mode (don't display warning)"),
default=False, action="store_true")
common.add_option("--debug", help=_("Debug mode"),
default=False, action="store_true")
return common
示例8: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def __init__(self):
parser_kw = {
'usage': self.usage,
'prog': '%s %s' % (get_prog(), self.name),
'formatter': UpdatingDefaultsHelpFormatter(),
'add_help_option': False,
'name': self.name,
'description': self.__doc__,
}
self.parser = ConfigOptionParser(**parser_kw)
# Commands should add options to this option group
optgroup_name = '%s Options' % self.name.capitalize()
self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name)
# Add the general options
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, self.parser)
self.parser.add_option_group(gen_opts)
示例9: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def __init__(self, isolated=False):
# type: (bool) -> None
parser_kw = {
'usage': self.usage,
'prog': '%s %s' % (get_prog(), self.name),
'formatter': UpdatingDefaultsHelpFormatter(),
'add_help_option': False,
'name': self.name,
'description': self.__doc__,
'isolated': isolated,
}
self.parser = ConfigOptionParser(**parser_kw)
# Commands should add options to this option group
optgroup_name = '%s Options' % self.name.capitalize()
self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name)
# Add the general options
gen_opts = cmdoptions.make_option_group(
cmdoptions.general_group,
self.parser,
)
self.parser.add_option_group(gen_opts)
示例10: workaround_optparse_bug9161
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def workaround_optparse_bug9161():
op = optparse.OptionParser()
og = optparse.OptionGroup(op, 'foo')
try:
og.add_option('-t')
except TypeError:
real_add_option = optparse.OptionGroup.add_option
def _compat_add_option(self, *args, **kwargs):
enc = lambda v: (
v.encode('ascii', 'replace') if isinstance(v, compat_str)
else v)
bargs = [enc(a) for a in args]
bkwargs = dict(
(k, enc(v)) for k, v in kwargs.items())
return real_add_option(self, *bargs, **bkwargs)
optparse.OptionGroup.add_option = _compat_add_option
示例11: add_options
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def add_options(parser):
options = optparse.OptionGroup(parser, 'Atrace process dump options')
options.add_option('--process-dump', dest='process_dump_enable',
default=False, action='store_true',
help='Capture periodic per-process memory dumps.')
options.add_option('--process-dump-interval', dest='process_dump_interval_ms',
default=5000,
help='Interval between memory dumps in milliseconds.')
options.add_option('--process-dump-full', dest='process_dump_full_config',
default=None,
help='Capture full memory dumps for some processes.\n' \
'Value: all, apps or comma-separated process names.')
options.add_option('--process-dump-mmaps', dest='process_dump_mmaps',
default=False, action='store_true',
help='Capture VM regions and memory-mapped files.\n' \
'It increases dump size dramatically, hence only ' \
'has effect if --process-dump-full is a whitelist.')
return options
示例12: add_options
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def add_options(parser):
options = optparse.OptionGroup(parser, 'Atrace options')
options.add_option('--atrace-categories', dest='atrace_categories',
help='Select atrace categories with a comma-delimited '
'list, e.g. --atrace-categories=cat1,cat2,cat3')
options.add_option('-k', '--ktrace', dest='kfuncs', action='store',
help='specify a comma-separated list of kernel functions '
'to trace')
options.add_option('--no-compress', dest='compress_trace_data',
default=True, action='store_false',
help='Tell the device not to send the trace data in '
'compressed form.')
options.add_option('-a', '--app', dest='app_name', default=None,
type='string', action='store',
help='enable application-level tracing for '
'comma-separated list of app cmdlines')
options.add_option('--from-file', dest='from_file',
action='store', help='read the trace from a '
'file (compressed) rather than running a '
'live trace')
return options
示例13: main
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def main():
# Create the option parser.
optparser = OptionParser(usage='%prog [options] NAME ...',
version="Edloper's Doctest Driver, "
"version %s" % __version__)
action_group = OptionGroup(optparser, 'Actions (default=check)')
action_group.add_options([CHECK_OPT, UPDATE_OPT, DEBUG_OPT])
optparser.add_option_group(action_group)
reporting_group = OptionGroup(optparser, 'Reporting')
reporting_group.add_options([VERBOSE_OPT, QUIET_OPT,
UDIFF_OPT, CDIFF_OPT, NDIFF_OPT])
optparser.add_option_group(reporting_group)
compare_group = OptionGroup(optparser, 'Output Comparison')
compare_group.add_options([ELLIPSIS_OPT, NORMWS_OPT])
optparser.add_option_group(compare_group)
# Extract optionflags and the list of file names.
optionvals, names = optparser.parse_args()
if len(names) == 0:
optparser.error("No files specified")
optionflags = (optionvals.udiff * REPORT_UDIFF |
optionvals.cdiff * REPORT_CDIFF |
optionvals.ellipsis * ELLIPSIS |
optionvals.normws * NORMALIZE_WHITESPACE)
# Perform the requested action.
if optionvals.action == 'check':
run(names, optionflags, optionvals.verbosity)
elif optionvals.action == 'update':
update(names, optionflags, optionvals.verbosity)
elif optionvals.action == 'debug':
debug(names, optionflags, optionvals.verbosity)
else:
optparser.error('INTERNAL ERROR: Bad action %s' % optionvals.action)
示例14: add_help_section
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionGroup [as 别名]
def add_help_section(self, title, description, level=0):
"""add a dummy option section for help purpose """
group = optparse.OptionGroup(self.cmdline_parser,
title=title.capitalize(),
description=description)
group.level = level
self._maxlevel = max(self._maxlevel, level)
self.cmdline_parser.add_option_group(group)