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


Python optparse.Option方法代码示例

本文整理汇总了Python中optparse.Option方法的典型用法代码示例。如果您正苦于以下问题:Python optparse.Option方法的具体用法?Python optparse.Option怎么用?Python optparse.Option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在optparse的用法示例。


在下文中一共展示了optparse.Option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def process(self, opt, value, values, parser):
        """
        Call the validator function on applicable settings and
        evaluate the 'overrides' option.
        Extends `optparse.Option.process`.
        """
        result = optparse.Option.process(self, opt, value, values, parser)
        setting = self.dest
        if setting:
            if self.validator:
                value = getattr(values, setting)
                try:
                    new_value = self.validator(setting, value, parser)
                except Exception as error:
                    raise optparse.OptionValueError(
                        'Error in option "%s":\n    %s'
                        % (opt, ErrorString(error)))
                setattr(values, setting, new_value)
            if self.overrides:
                setattr(values, self.overrides, None)
        return result 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:frontend.py

示例2: process

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def process(self, opt, value, values, parser):
        """
        Call the validator function on applicable settings and
        evaluate the 'overrides' option.
        Extends `optparse.Option.process`.
        """
        result = optparse.Option.process(self, opt, value, values, parser)
        setting = self.dest
        if setting:
            if self.validator:
                value = getattr(values, setting)
                try:
                    new_value = self.validator(setting, value, parser)
                except Exception, error:
                    raise (optparse.OptionValueError(
                        'Error in option "%s":\n    %s'
                        % (opt, ErrorString(error))),
                           None, sys.exc_info()[2])
                setattr(values, setting, new_value)
            if self.overrides:
                setattr(values, self.overrides, None) 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:frontend.py

示例3: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def __init__(self, *opts, **attrs):
        optparse.Option.__init__(self, *opts, **attrs)
        if hasattr(self, "hide") and self.hide:
            self.help = optparse.SUPPRESS_HELP 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:6,代码来源:config.py

示例4: reset_parsers

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def reset_parsers(self, usage='', version=None):
        # configuration file parser
        self.cfgfile_parser = configparser.ConfigParser(inline_comment_prefixes=('#', ';'))
        # command line parser
        self.cmdline_parser = OptionParser(Option, usage=usage, version=version)
        self.cmdline_parser.options_manager = self
        self._optik_option_attrs = set(self.cmdline_parser.option_class.ATTRS) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:9,代码来源:config.py

示例5: exists_action

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def exists_action():
    return Option(
        # Option when path already exist
        '--exists-action',
        dest='exists_action',
        type='choice',
        choices=['s', 'i', 'w', 'b', 'a'],
        default=[],
        action='append',
        metavar='action',
        help="Default action when a path already exists: "
        "(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:cmdoptions.py

示例6: extra_index_url

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def extra_index_url():
    return Option(
        '--extra-index-url',
        dest='extra_index_urls',
        metavar='URL',
        action='append',
        default=[],
        help="Extra URLs of package indexes to use in addition to "
             "--index-url. Should follow the same rules as "
             "--index-url."
    ) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:cmdoptions.py

示例7: find_links

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def find_links():
    return Option(
        '-f', '--find-links',
        dest='find_links',
        action='append',
        default=[],
        metavar='url',
        help="If a url or path to an html file, then parse for links to "
             "archives. If a local path or file:// url that's a directory, "
             "then look for archives in the directory listing.") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:cmdoptions.py

示例8: allow_external

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def allow_external():
    return Option(
        "--allow-external",
        dest="allow_external",
        action="append",
        default=[],
        metavar="PACKAGE",
        help=SUPPRESS_HELP,
    ) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:cmdoptions.py

示例9: trusted_host

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def trusted_host():
    return Option(
        "--trusted-host",
        dest="trusted_hosts",
        action="append",
        metavar="HOSTNAME",
        default=[],
        help="Mark this host as trusted, even though it does not have valid "
             "or any HTTPS.",
    )


# Remove after 7.0 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:cmdoptions.py

示例10: constraints

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def constraints():
    return Option(
        '-c', '--constraint',
        dest='constraints',
        action='append',
        default=[],
        metavar='file',
        help='Constrain versions using the given constraints file. '
        'This option can be used multiple times.') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:cmdoptions.py

示例11: requirements

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def requirements():
    return Option(
        '-r', '--requirement',
        dest='requirements',
        action='append',
        default=[],
        metavar='file',
        help='Install from the given requirements file. '
        'This option can be used multiple times.') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:cmdoptions.py

示例12: editable

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def editable():
    return Option(
        '-e', '--editable',
        dest='editables',
        action='append',
        default=[],
        metavar='path/url',
        help=('Install a project in editable mode (i.e. setuptools '
              '"develop mode") from a local project path or a VCS url.'),
    ) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:cmdoptions.py

示例13: no_binary

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def no_binary():
    return Option(
        "--no-binary", dest="format_control", action="callback",
        callback=_handle_no_binary, type="str",
        default=FormatControl(set(), set()),
        help="Do not use binary packages. Can be supplied multiple times, and "
             "each time adds to the existing value. Accepts either :all: to "
             "disable all binary packages, :none: to empty the set, or one or "
             "more package names with commas between them. Note that some "
             "packages are tricky to compile and may fail to install when "
             "this option is used on them.") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:cmdoptions.py

示例14: only_binary

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def only_binary():
    return Option(
        "--only-binary", dest="format_control", action="callback",
        callback=_handle_only_binary, type="str",
        default=FormatControl(set(), set()),
        help="Do not use source packages. Can be supplied multiple times, and "
             "each time adds to the existing value. Accepts either :all: to "
             "disable all source packages, :none: to empty the set, or one or "
             "more package names with commas between them. Packages without "
             "binary distributions will fail to install when this option is "
             "used on them.") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:cmdoptions.py

示例15: exists_action

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Option [as 别名]
def exists_action():
    return Option(
        # Option when path already exist
        '--exists-action',
        dest='exists_action',
        type='choice',
        choices=['s', 'i', 'w', 'b'],
        default=[],
        action='append',
        metavar='action',
        help="Default action when a path already exists: "
        "(s)witch, (i)gnore, (w)ipe, (b)ackup.") 
开发者ID:jpush,项目名称:jbox,代码行数:14,代码来源:cmdoptions.py


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