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


Python optparse.OptionValueError方法代码示例

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


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

示例1: _applyConfigurationToValues

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _applyConfigurationToValues(self, parser, config, values):
        for name, value, filename in config:
            if name in option_blacklist:
                continue
            try:
                self._processConfigValue(name, value, values, parser)
            except NoSuchOptionError, exc:
                self._file_error(
                    "Error reading config file %r: "
                    "no such option %r" % (filename, exc.name),
                    name=name, filename=filename)
            except optparse.OptionValueError, exc:
                msg = str(exc).replace('--' + name, repr(name), 1)
                self._file_error("Error reading config file %r: "
                                 "%s" % (filename, msg),
                                 name=name, filename=filename) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:18,代码来源:config.py

示例2: process

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [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

示例3: process

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [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

示例4: process

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [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))),
                           None, sys.exc_info()[2])
                setattr(values, setting, new_value)
            if self.overrides:
                setattr(values, self.overrides, None)
        return result 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:24,代码来源:frontend.py

示例5: _multiple_choice_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _multiple_choice_validator(choices, name, value):
    values = utils._check_csv(value)
    for csv_value in values:
        if csv_value not in choices:
            msg = "option %s: invalid value: %r, should be in %s"
            raise optparse.OptionValueError(msg % (name, csv_value, choices))
    return values 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:9,代码来源:config.py

示例6: _choice_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _choice_validator(choices, name, value):
    if value not in choices:
        msg = "option %s: invalid value: %r, should be in %s"
        raise optparse.OptionValueError(msg % (name, value, choices))
    return value

# pylint: disable=unused-argument 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:9,代码来源:config.py

示例7: _yn_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _yn_validator(opt, _, value):
    if isinstance(value, int):
        return bool(value)
    if value in ('y', 'yes'):
        return True
    if value in ('n', 'no'):
        return False
    msg = "option %s: invalid yn value %r, should be in (y, yes, n, no)"
    raise optparse.OptionValueError(msg % (opt, value)) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:11,代码来源:config.py

示例8: _non_empty_string_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _non_empty_string_validator(opt, _, value):
    if not value:
        msg = "indent string can't be empty."
        raise optparse.OptionValueError(msg)
    return utils._unquote(value) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:7,代码来源:config.py

示例9: _call_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _call_validator(opttype, optdict, option, value):
    if opttype not in VALIDATORS:
        raise Exception('Unsupported type "%s"' % opttype)
    try:
        return VALIDATORS[opttype](optdict, option, value)
    except TypeError:
        try:
            return VALIDATORS[opttype](value)
        except Exception:
            raise optparse.OptionValueError('%s value (%r) should be of type %s' %
                                            (option, value, opttype)) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:13,代码来源:config.py

示例10: check_default

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def check_default(self, option, key, val):
        try:
            return option.check_value(key, val)
        except optparse.OptionValueError as exc:
            print("An error occurred during configuration: %s" % exc)
            sys.exit(3) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:baseparser.py

示例11: _choice_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _choice_validator(choices, name, value):
    if value not in choices:
        msg = "option %s: invalid value: %r, should be in %s"
        raise optparse.OptionValueError(msg % (name, value, choices))
    return value


# pylint: disable=unused-argument 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:10,代码来源:config.py

示例12: _yn_validator

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _yn_validator(opt, _, value):
    if isinstance(value, int):
        return bool(value)
    if value in ("y", "yes"):
        return True
    if value in ("n", "no"):
        return False
    msg = "option %s: invalid yn value %r, should be in (y, yes, n, no)"
    raise optparse.OptionValueError(msg % (opt, value)) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:11,代码来源:config.py

示例13: error

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def error(self, msg):
        # overridden OptionValueError exception handler
        self.print_usage(sys.stderr)
        sys.stderr.write("SCons Error: %s\n" % msg)
        sys.exit(2) 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:7,代码来源:SConsOptions.py

示例14: _process_args

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import OptionValueError [as 别名]
def _process_args(self, largs, rargs, values):
        try:
            return optparse.OptionParser._process_args(self, largs, rargs, values)
        except (optparse.BadOptionError, optparse.OptionValueError), err:
            if self.final:
                raise err 
开发者ID:virtualrealitysystems,项目名称:aumfor,代码行数:8,代码来源:conf.py


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