当前位置: 首页>>代码示例>>Python>>正文


Python optparse.OptionGroup方法代码示例

本文整理汇总了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)}",
        ) 
开发者ID:nabla-c0d3,项目名称:sslyze,代码行数:23,代码来源:command_line_parser.py

示例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) 
开发者ID:llvm,项目名称:llvm-zorg,代码行数:27,代码来源:main.py

示例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) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:19,代码来源:config.py

示例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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:basecommand.py

示例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) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:22,代码来源:config.py

示例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) 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:20,代码来源:koji_pkgspec.py

示例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 
开发者ID:Yukinoshita47,项目名称:Yuki-Chan-The-Auto-Pentest,代码行数:21,代码来源:cmd_line.py

示例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) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:21,代码来源:basecommand.py

示例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) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:26,代码来源:base_command.py

示例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 
开发者ID:tvalacarta,项目名称:tvalacarta,代码行数:19,代码来源:compat.py

示例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 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:20,代码来源:atrace_process_dump.py

示例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 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:23,代码来源:atrace_agent.py

示例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) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:39,代码来源:doctest_driver.py

示例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) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:10,代码来源:config.py


注:本文中的optparse.OptionGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。