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


Python tableschema.validate方法代码示例

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


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

示例1: validate

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def validate(self):
        super(XsdSchemaValidator, self).validate()
        self.check_file_exists("schemas.yml")

        try:
            with open(self.filepath("schemas.yml"), "r") as f:
                config = yaml.safe_load(f)
                self.schemas_config = config["schemas"]
                self.title = config["title"]
                self.description = config["description"]
                self.homepage = config["homepage"]
                for schema in config["schemas"]:
                    self.check_schema(schema["path"], schema["title"])
        except Exception as e:
            message = "`schemas.yml` has not the required format: " + repr(e)
            raise exceptions.InvalidSchemaException(self.repo, message) 
开发者ID:etalab,项目名称:schema.data.gouv.fr,代码行数:18,代码来源:validators.py

示例2: cli

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def cli():
    """Command-line interface

    ```
    Usage: tableschema [OPTIONS] COMMAND [ARGS]...

    Options:
      --help  Show this message and exit.

    Commands:
      infer     Infer a schema from data.
      info      Return info on this version of Table Schema
      validate  Validate that a supposed schema is in fact a Table Schema.
    ```

    """
    pass 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:19,代码来源:cli.py

示例3: create

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def create(self, bucket, descriptor, force=False):

        # Make lists
        buckets = bucket
        if isinstance(bucket, six.string_types):
            buckets = [bucket]
        descriptors = descriptor
        if isinstance(descriptor, dict):
            descriptors = [descriptor]

        # Check buckets for existence
        for bucket in buckets:
            if bucket in self.buckets:
                if not force:
                    message = 'Bucket "%s" already exists' % bucket
                    raise tableschema.exceptions.StorageError(message)
                self.delete(bucket)

        # Define dataframes
        for bucket, descriptor in zip(buckets, descriptors):
            tableschema.validate(descriptor)
            self.__descriptors[bucket] = descriptor
            self.__dataframes[bucket] = pd.DataFrame() 
开发者ID:frictionlessdata,项目名称:tableschema-pandas-py,代码行数:25,代码来源:storage.py

示例4: check_schema

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def check_schema(self, filename):
        try:
            tableschema.validate(self.filepath(filename))
        except tableschema.exceptions.ValidationError as e:
            errors = "; ".join([repr(e) for e in e.errors])
            message = "Schema %s is not a valid TableSchema schema. Errors: %s" % (
                filename,
                errors,
            )
            raise exceptions.InvalidSchemaException(self.repo, message) 
开发者ID:etalab,项目名称:schema.data.gouv.fr,代码行数:12,代码来源:validators.py

示例5: validate

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def validate(schema):
    """Validate that a supposed schema is in fact a Table Schema."""
    try:
        tableschema.validate(schema)
        click.echo("Schema is valid")
        sys.exit(0)
    except tableschema.exceptions.ValidationError as exception:
        click.echo("Schema is not valid")
        click.echo(exception.errors)
        sys.exit(1) 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:12,代码来源:cli.py

示例6: test_schema_valid_simple

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_valid_simple():
    valid = validate('data/schema_valid_simple.json')
    assert valid 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例7: test_schema_valid_full

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_valid_full():
    valid = validate('data/schema_valid_full.json')
    assert valid 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例8: test_schema_valid_pk_array

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_valid_pk_array():
    valid = validate('data/schema_valid_pk_array.json')
    assert valid 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例9: test_schema_invalid_wrong_type

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_invalid_wrong_type():
    with pytest.raises(exceptions.ValidationError):
        valid = validate([]) 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例10: test_schema_invalid_pk_string

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_invalid_pk_string():
    with pytest.raises(exceptions.ValidationError):
        valid = validate('data/schema_invalid_pk_string.json') 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例11: test_schema_invalid_pk_array

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_invalid_pk_array():
    with pytest.raises(exceptions.ValidationError):
        valid = validate('data/schema_invalid_pk_array.json') 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例12: test_schema_valid_fk_array

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_valid_fk_array():
    valid = validate('data/schema_valid_fk_array.json')
    assert valid 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例13: test_schema_invalid_fk_string

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_invalid_fk_string():
    with pytest.raises(exceptions.ValidationError):
        valid = validate('data/schema_invalid_fk_string.json') 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例14: test_schema_invalid_fk_array

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_invalid_fk_array():
    with pytest.raises(exceptions.ValidationError):
        valid = validate('data/schema_invalid_fk_array.json') 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py

示例15: test_schema_invalid_fk_ref_is_an_array_fields_is_a_string

# 需要导入模块: import tableschema [as 别名]
# 或者: from tableschema import validate [as 别名]
def test_schema_invalid_fk_ref_is_an_array_fields_is_a_string():
    with pytest.raises(exceptions.ValidationError):
        valid = validate('data/schema_invalid_fk_string_array_ref.json') 
开发者ID:frictionlessdata,项目名称:tableschema-py,代码行数:5,代码来源:test_validate.py


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