本文整理匯總了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')