2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
19 LOADER = yaml.CSafeLoader if yaml.__with_libyaml__ else yaml.SafeLoader
23 """Parse arguments and verify YAML"""
24 logging.basicConfig(level=logging.INFO)
26 parser = argparse.ArgumentParser()
27 parser.add_argument('--yaml', '-y', type=str, required=True)
28 parser.add_argument('--schema', '-s', type=str, required=True)
30 args = parser.parse_args()
32 with open(args.yaml) as _:
33 yaml_file = yaml.load(_, Loader=LOADER)
35 with open(args.schema) as _:
36 schema_file = yaml.load(_, Loader=LOADER)
38 validation = jsonschema.Draft4Validator(
40 format_checker=jsonschema.FormatChecker()
44 for error in validation.iter_errors(yaml_file):
48 raise RuntimeError("%d issues invalidate the schema" % errors)
51 if __name__ == "__main__":