# Path: datapackage_pipelines/specs/errors.py
# class SpecError(NamedTuple):
#     short_msg: str
#     long_msg: str
# 
#     def __str__(self):
#         return '{}: {}'.format(self.short_msg, self.long_msg)


import os
import json
import jsonschema
from ..errors import SpecError



schema_filename = 'pipeline-spec.schema.json'
schema_filename = os.path.join(os.path.dirname(__file__),
                               schema_filename)
schema = json.load(open(schema_filename))
validator = jsonschema.validators.validator_for(schema)
schema = validator(schema)


def validate_pipeline(pipeline_details, errors):
    try:
        schema.validate(pipeline_details)
    except jsonschema.ValidationError as e:

# Path: datapackage_pipelines/specs/errors.py
# class SpecError(NamedTuple):
#     short_msg: str
#     long_msg: str
# 
#     def __str__(self):
#         return '{}: {}'.format(self.short_msg, self.long_msg)


# Path: datapackage_pipelines/specs/schemas/validator.py
import os
import json
import jsonschema
from ..errors import SpecError




schema_filename = 'pipeline-spec.schema.json'
schema_filename = os.path.join(os.path.dirname(__file__),
                               schema_filename)
schema = json.load(open(schema_filename))
validator = jsonschema.validators.validator_for(schema)
schema = validator(schema)


def validate_pipeline(pipeline_details, errors):
    try:
        schema.validate(pipeline_details)
    except jsonschema.ValidationError as e:

        errors.append(SpecError('Invalid Pipeline', str(e)))