def check_choice(option, opt, value): if value in option.choices: return value else: choices = string.join(map(repr, option.choices), ", ") raise OptionValueError( "option %s: invalid choice: %s (choose from %s)" % (opt, repr(value), choices))
def check_builtin(option, opt, value): (cvt, what) = _builtin_cvt[option.type] try: return cvt(value) except ValueError: raise OptionValueError( #"%s: invalid %s argument %s" % (opt, what, repr(value))) "option %s: invalid %s value: %s" % (opt, what, repr(value)))