本文整理汇总了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)
示例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
示例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()
示例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)
示例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)
示例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
示例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
示例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
示例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([])
示例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')
示例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')
示例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
示例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')
示例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')
示例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')