當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。