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


Python _utils.ensure_list方法代码示例

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


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

示例1: dependencies

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [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)
                    ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:22,代码来源:_validators.py

示例2: type_draft3

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [as 别名]
def type_draft3(validator, types, instance, schema):
    types = _utils.ensure_list(types)

    all_errors = []
    for index, type in enumerate(types):
        if type == "any":
            return
        if validator.is_type(type, "object"):
            errors = list(validator.descend(instance, type, schema_path=index))
            if not errors:
                return
            all_errors.extend(errors)
        else:
            if validator.is_type(instance, type):
                return
    else:
        yield ValidationError(
            _utils.types_msg(instance, types), context=all_errors,
        ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:21,代码来源:_validators.py

示例3: type_draft3

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [as 别名]
def type_draft3(validator, types, instance, schema):
    types = _utils.ensure_list(types)

    # NOTE(kiall): A datetime object is not a string, but is still valid.
    if ('format' in schema and schema['format'] == 'date-time' and
            isinstance(instance, datetime.datetime)):
        return

    all_errors = []
    for index, type in enumerate(types):
        if type == "any":
            return
        if validator.is_type(type, "object"):
            errors = list(validator.descend(instance, type, schema_path=index))
            if not errors:
                return
            all_errors.extend(errors)
        else:
            if validator.is_type(instance, type):
                return
    else:
        yield jsonschema.ValidationError(
            _utils.types_msg(instance, types), context=all_errors,
        ) 
开发者ID:openstack,项目名称:designate,代码行数:26,代码来源:_validators.py

示例4: disallow_draft3

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [as 别名]
def disallow_draft3(validator, disallow, instance, schema):
    for disallowed in _utils.ensure_list(disallow):
        if validator.is_valid(instance, {"type": [disallowed]}):
            yield ValidationError(
                "%r is disallowed for %r" % (disallowed, instance)
            ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:8,代码来源:_validators.py

示例5: type_draft4

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [as 别名]
def type_draft4(validator, types, instance, schema):
    types = _utils.ensure_list(types)

    if not any(validator.is_type(instance, type) for type in types):
        yield ValidationError(_utils.types_msg(instance, types)) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:_validators.py

示例6: type_draft4

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [as 别名]
def type_draft4(validator, types, instance, schema):
    types = _utils.ensure_list(types)

    # NOTE(kiall): A datetime object is not a string, but is still valid.
    if ('format' in schema and schema['format'] == 'date-time' and
            isinstance(instance, datetime.datetime)):
        return

    if not any(validator.is_type(instance, type) for type in types):
        yield jsonschema.ValidationError(_utils.types_msg(instance, types)) 
开发者ID:openstack,项目名称:designate,代码行数:12,代码来源:_validators.py

示例7: disallow_draft3

# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import ensure_list [as 别名]
def disallow_draft3(validator, disallow, instance, schema):
    for disallowed in _utils.ensure_list(disallow):
        if validator.is_valid(instance, {"type" : [disallowed]}):
            yield ValidationError(
                "%r is disallowed for %r" % (disallowed, instance)
            ) 
开发者ID:splunk,项目名称:SA-ctf_scoreboard,代码行数:8,代码来源:_validators.py


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