validator.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:cti-stix-validator 作者: oasis-open 项目源码 文件源码
def load_validator(schema_path, schema):
    """Create a JSON schema validator for the given schema.

    Args:
        schema_path: The filename of the JSON schema.
        schema: A Python object representation of the same schema.

    Returns:
        An instance of Draft4Validator.

    """
    # Get correct prefix based on OS
    if os.name == 'nt':
        file_prefix = 'file:///'
    else:
        file_prefix = 'file:'

    resolver = RefResolver(file_prefix + schema_path.replace("\\", "/"), schema)
    validator = Draft4Validator(schema, resolver=resolver)

    return validator
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号