當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。