本文整理汇总了Python中pyasn1.type.error.ValueConstraintError方法的典型用法代码示例。如果您正苦于以下问题:Python error.ValueConstraintError方法的具体用法?Python error.ValueConstraintError怎么用?Python error.ValueConstraintError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasn1.type.error
的用法示例。
在下文中一共展示了error.ValueConstraintError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _testValue
# 需要导入模块: from pyasn1.type import error [as 别名]
# 或者: from pyasn1.type.error import ValueConstraintError [as 别名]
def _testValue(self, value, idx):
for constraint in self._values:
try:
constraint(value, idx)
except error.ValueConstraintError:
pass
else:
return
raise error.ValueConstraintError(
'all of %s failed for "%s"' % (self._values, value)
)
# TODO:
# refactor InnerTypeConstraint
# add tests for type check
# implement other constraint types
# make constraint validation easy to skip
示例2: __call__
# 需要导入模块: from pyasn1.type import error [as 别名]
# 或者: from pyasn1.type.error import ValueConstraintError [as 别名]
def __call__(self, value, idx=None):
try:
self._testValue(value, idx)
except error.ValueConstraintError:
raise error.ValueConstraintError(
'%s failed at: \"%s\"' % (self, sys.exc_info()[1])
)
示例3: _testValue
# 需要导入模块: from pyasn1.type import error [as 别名]
# 或者: from pyasn1.type.error import ValueConstraintError [as 别名]
def _testValue(self, value, idx):
raise error.ValueConstraintError(value)
# Constraints derivation logic
示例4: __call__
# 需要导入模块: from pyasn1.type import error [as 别名]
# 或者: from pyasn1.type.error import ValueConstraintError [as 别名]
def __call__(self, value, idx=None):
try:
self._testValue(value, idx)
except error.ValueConstraintError:
raise error.ValueConstraintError(
'%s failed at: %r' % (self, sys.exc_info()[1])
)
示例5: __call__
# 需要导入模块: from pyasn1.type import error [as 别名]
# 或者: from pyasn1.type.error import ValueConstraintError [as 别名]
def __call__(self, value, idx=None):
if not self._values:
return
try:
self._testValue(value, idx)
except error.ValueConstraintError:
raise error.ValueConstraintError(
'%s failed at: %r' % (self, sys.exc_info()[1])
)