本文整理汇总了Python中jsonschema.compat.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python compat.iteritems方法的具体用法?Python compat.iteritems怎么用?Python compat.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonschema.compat
的用法示例。
在下文中一共展示了compat.iteritems方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dependencies
# 需要导入模块: from jsonschema import compat [as 别名]
# 或者: from jsonschema.compat import iteritems [as 别名]
def dependencies(validator, dependencies, instance, schema):
if not validator.is_type(instance, "object"):
return
for property, dependency in iteritems(dependencies):
if property not in instance:
continue
if validator.is_type(dependency, "object"):
for error in validator.descend(
instance, dependency, schema_path=property,
):
yield error
else:
dependencies = _utils.ensure_list(dependency)
for dependency in dependencies:
if dependency not in instance:
yield ValidationError(
"%r is a dependency of %r" % (dependency, property)
)
示例2: properties_draft3
# 需要导入模块: from jsonschema import compat [as 别名]
# 或者: from jsonschema.compat import iteritems [as 别名]
def properties_draft3(validator, properties, instance, schema):
if not validator.is_type(instance, "object"):
return
for property, subschema in iteritems(properties):
if property in instance:
for error in validator.descend(
instance[property],
subschema,
path=property,
schema_path=property,
):
yield error
elif subschema.get("required", False):
error = ValidationError("%r is a required property" % property)
error._set(
validator="required",
validator_value=subschema["required"],
instance=instance,
schema=schema,
)
error.path.appendleft(property)
error.schema_path.extend([property, "required"])
yield error
示例3: _set
# 需要导入模块: from jsonschema import compat [as 别名]
# 或者: from jsonschema.compat import iteritems [as 别名]
def _set(self, **kwargs):
for k, v in iteritems(kwargs):
if getattr(self, k) is _unset:
setattr(self, k, v)
示例4: total_errors
# 需要导入模块: from jsonschema import compat [as 别名]
# 或者: from jsonschema.compat import iteritems [as 别名]
def total_errors(self):
"""
The total number of errors in the entire tree, including children.
"""
child_errors = sum(len(tree) for _, tree in iteritems(self._contents))
return len(self.errors) + child_errors
示例5: patternProperties
# 需要导入模块: from jsonschema import compat [as 别名]
# 或者: from jsonschema.compat import iteritems [as 别名]
def patternProperties(validator, patternProperties, instance, schema):
if not validator.is_type(instance, "object"):
return
for pattern, subschema in iteritems(patternProperties):
for k, v in iteritems(instance):
if re.search(pattern, k):
for error in validator.descend(
v, subschema, path=k, schema_path=pattern,
):
yield error