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


Python core.Core方法代码示例

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


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

示例1: validate_domain_yaml

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def validate_domain_yaml(cls, yaml):
        """Validate domain yaml."""
        from pykwalify.core import Core

        log = logging.getLogger('pykwalify')
        log.setLevel(logging.WARN)

        schema_file = pkg_resources.resource_filename(__name__,
                                                      "schemas/domain.yml")
        source_data = utils.read_yaml_string(yaml)
        c = Core(source_data=source_data,
                 schema_files=[schema_file])
        try:
            c.validate(raise_exception=True)
        except SchemaError:
            raise InvalidDomain("Failed to validate your domain yaml. "
                                "Make sure the file is correct, to do so"
                                "take a look at the errors logged during "
                                "validation previous to this exception. ") 
开发者ID:RasaHQ,项目名称:rasa_core,代码行数:21,代码来源:domain.py

示例2: ext_ostree

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def ext_ostree(value, rule_obj, path):
    if type(value) is str:
        if value != "latest":
            raise SchemaError("expected string 'latest'")
    elif type(value) is dict:
        schema = {'mapping':
                  {'remote': {'type': 'str'},
                   'branch': {'type': 'str'},
                   'revision': {'type': 'str'}
                   }
                  }
        c = Core(source_data=value, schema_data=schema)
        c.validate()
    else:
        raise SchemaError("expected str or map")
    return True 
开发者ID:projectatomic,项目名称:papr,代码行数:18,代码来源:ext_schema.py

示例3: validate

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def validate(f):
    logger.info('Validating {}'.format(f.name))
    c = Core(
        source_file=f.name,
        schema_files=[asset_helpers.resolve_from_site_packages('schema.yaml')],
        extensions=[asset_helpers.resolve_from_site_packages('puppet_schema_extensions.py')]
    )
    c.validate(raise_exception=True)
    click.echo("Finished validating: {}".format(f.name))
    click.echo("Finished validating: OK") 
开发者ID:awslabs,项目名称:aws-service-catalog-puppet,代码行数:12,代码来源:core.py

示例4: validate_config_format

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def validate_config_format(config_file, config_schema):
        schema = os.path.abspath(config_schema)
        c = PyKwalify(source_file=config_file, schema_files=[schema])
        c.validate(raise_exception=True) 
开发者ID:open-cloud,项目名称:xos,代码行数:6,代码来源:config.py

示例5: __init__

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def __init__(self, config_path, schema_path, config_changes):
        with open(config_path, 'rt') as src:
            config = read_config(src)
        make_config_changes(config, config_changes)

        self.multi_stage = 'stages' in config
        if self.multi_stage:
            stages = [(k, v) for k, v in config['stages'].items() if v]
            ordered_changes = OrderedDict(
                sorted(stages, key=lambda (k, v): v['number'],))
            self.ordered_stages = OrderedDict()
            for name, changes in ordered_changes.items():
                current_config = copy.deepcopy(config)
                del current_config['stages']
                del changes['number']
                merge_recursively(current_config, changes)
                self.ordered_stages[name] = current_config

        # Validate the configuration and the training stages
        if schema_path:
            with open(os.path.expandvars(schema_path)) as schema_file:
                schema = yaml.safe_load(schema_file)
                core = Core(source_data=config, schema_data=schema)
                core.validate(raise_exception=True)
                if self.multi_stage:
                    for stage in self.ordered_stages.values():
                        core = Core(source_data=stage, schema_data=schema)
                        core.validate(raise_exception=True)
        super(Configuration, self).__init__(config) 
开发者ID:rizar,项目名称:attention-lvcsr,代码行数:31,代码来源:config.py

示例6: _validate_yaml

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def _validate_yaml(schema, config):
    """Raises exception if config is invalid.

    :param schema: The schema to validate with (browbeat, rally...)
    :param config: Loaded yaml to validate
    """
    check = pykwalify_core.Core(
        source_data=config, schema_files=["{}/{}.yml".format(conf_schema_path, schema)])
    try:
        check.validate(raise_exception=True)
    except pykwalify_errors.SchemaError as e:
        _logger.error("Schema validation failed")
        raise Exception("File does not conform to {} schema: {}".format(schema, e)) 
开发者ID:cloud-bulldozer,项目名称:browbeat,代码行数:15,代码来源:config.py

示例7: validate

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def validate(p):
    for portfolio_file_name in os.listdir(p):
        portfolios_file_path = os.path.sep.join([p, portfolio_file_name])
        logger.info('Validating {}'.format(portfolios_file_path))
        core = Core(
            source_file=portfolios_file_path,
            schema_files=[resolve_from_site_packages('schema.yaml')]
        )
        core.validate(raise_exception=True)
        click.echo("Finished validating: {}".format(portfolios_file_path))
    click.echo("Finished validating: OK") 
开发者ID:awslabs,项目名称:aws-service-catalog-factory,代码行数:13,代码来源:core.py

示例8: verify_generic

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def verify_generic(to_verify, schema):
    """Verify a generic file against a given schema

    Args:
        to_verify (dict): Filename of source tests to check
        schema (dict): Schema to verify against

    Raises:
        BadSchemaError: Schema did not match
    """
    logger.debug("Verifying %s against %s", to_verify, schema)

    here = os.path.dirname(os.path.abspath(__file__))
    extension_module_filename = os.path.join(here, "extensions.py")

    verifier = core.Core(
        source_data=to_verify,
        schema_data=schema,
        extensions=[extension_module_filename],
    )

    try:
        verifier.validate()
    except pykwalify.errors.PyKwalifyException as e:
        logger.exception("Error validating %s", to_verify)
        raise BadSchemaError() from e 
开发者ID:taverntesting,项目名称:tavern,代码行数:28,代码来源:files.py

示例9: ext_build

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def ext_build(value, rule_obj, path):
    if type(value) not in [dict, bool]:
        raise SchemaError("expected bool or map")
    if type(value) is dict:
        schema = {'mapping':
                  {'config-opts': {'type': 'str'},
                   'build-opts': {'type': 'str'},
                   'install-opts': {'type': 'str'}
                   }
                  }
        c = Core(source_data=value, schema_data=schema)
        c.validate()
    return True 
开发者ID:projectatomic,项目名称:papr,代码行数:15,代码来源:ext_schema.py

示例10: validate_yaml

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def validate_yaml(config, _logger):
    _logger.info("Validating the configuration file passed by the user")
    stream = open("lib/validate.yaml", 'r')
    schema = yaml.load(stream)
    check = pykwalify_core.Core(source_data=config, schema_data=schema)
    try:
        check.validate(raise_exception=True)
        _logger.info("Validation successful")
    except pykwalify_errors.SchemaError as e:
        _logger.error("Schema Validation failed")
        raise Exception('File does not conform to schema: {}'.format(e)) 
开发者ID:jtaleric,项目名称:browbeat,代码行数:13,代码来源:browbeat.py

示例11: validate_yaml_schema

# 需要导入模块: from pykwalify import core [as 别名]
# 或者: from pykwalify.core import Core [as 别名]
def validate_yaml_schema(
    yaml_file_content: Text, schema_path: Text, show_validation_errors: bool = True
) -> None:
    """
    Validate yaml content.

    Args:
        yaml_file_content: the content of the yaml file to be validated
        schema_path: the schema of the yaml file
        show_validation_errors: if true, validation errors are shown
    """
    from pykwalify.core import Core
    from pykwalify.errors import SchemaError
    from ruamel.yaml import YAMLError
    import pkg_resources
    import rasa.utils.io
    import logging

    log = logging.getLogger("pykwalify")
    if show_validation_errors:
        log.setLevel(logging.WARN)
    else:
        log.setLevel(logging.CRITICAL)

    try:
        source_data = rasa.utils.io.read_yaml(yaml_file_content)
    except YAMLError:
        raise InvalidYamlFileError(
            "The provided yaml file is invalid. You can use "
            "http://www.yamllint.com/ to validate the yaml syntax "
            "of your file."
        )
    except DuplicateKeyError as e:
        raise InvalidYamlFileError(
            "The provided yaml file contains a duplicated key: '{}'. You can use "
            "http://www.yamllint.com/ to validate the yaml syntax "
            "of your file.".format(str(e))
        )

    try:
        schema_file = pkg_resources.resource_filename(PACKAGE_NAME, schema_path)

        c = Core(source_data=source_data, schema_files=[schema_file])
        c.validate(raise_exception=True)
    except SchemaError:
        raise InvalidYamlFileError(
            "Failed to validate yaml file. "
            "Please make sure the file is correct and all "
            "mandatory parameters are specified; to do so, "
            "take a look at the errors logged during "
            "validation previous to this exception."
        ) 
开发者ID:botfront,项目名称:rasa-for-botfront,代码行数:54,代码来源:validation.py


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