@@ -0,0 +1,2610 @@
+#!/usr/bin/env python%0A#    Copyright 2017 Cargill Incorporated%0A#%0A#    Licensed under the Apache License, Version 2.0 (the %22License%22);%0A#    you may not use this file except in compliance with the License.%0A#    You may obtain a copy of the License at%0A#%0A#      http://www.apache.org/licenses/LICENSE-2.0%0A#%0A#    Unless required by applicable law or agreed to in writing, software%0A#    distributed under the License is distributed on an %22AS IS%22 BASIS,%0A#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A#    See the License for the specific language governing permissions and%0A#    limitations under the License.%0Aimport argparse%0Afrom pipewrench import merge%0Afrom marshmallow import Schema, fields%0Aimport yaml%0A# This script will validate required metatada properties are filled in a given configuration.%0A%0Aclass Column(Schema):%0A    comment = fields.String(required=True)%0A%0Aclass Table(Schema):%0A    META_CONTACT_INFO = fields.String(required=True)%0A    META_LOAD_FREQUENCY = fields.String(required=True)%0A    META_SECURITY_CLASSIFICATION = fields.String(required=True)%0A    META_SOURCE = fields.String(required=True)%0A    id = fields.String(required=True)%0A    columns = fields.Nested(Column, many=True)%0A%0A%0Aclass Conf(Schema):%0A    tables = fields.Nested(Column, many=True)%0A%0A%0Adef main(conf_path, env_path):%0A    has_errors = False%0A%0A    env = merge.get_env(env_path)%0A    conf = merge.get_conf(conf_path, env)%0A%0A    for table in conf%5B'tables'%5D:%0A        result = Table().load(table)%0A        if table%5B'id'%5D:%0A            print('results for: ' + table%5B'id'%5D)%0A            print()%0A        if (result.errors):%0A            print(yaml.dump(%7B table%5B'id'%5D: result.errors%7D))%0A        else:%0A            print('ok')%0A        has_errors = True%0A%0A    exit(not has_errors)%0A%0A%0Aif __name__ == %22__main__%22:%0A%0A    parser = argparse.ArgumentParser(description='yaml schema validator'%0A                                                 'Usage: ./script.py --env=/path/to/env'%0A                                                 ' --conf=/path/to/conf')%0A%0A    parser.add_argument('--conf',%0A                        dest='conf',%0A                        help='Yaml format configuration file.'%0A                             ' This file can be used as a template to be filled by '%0A                             '%5C'env.yml%5C'')%0A    parser.add_argument('--env',%0A                        dest='env',%0A                        help='Yaml format environment file.'%0A                             ' Key-value pairs in this file that are templated in '%0A                             '%5C'conf.yml%5C'')%0A%0A    args = parser.parse_args()%0A    main(args.conf, args.env)%0A

Add script to validate table metadata values exist