Esempio n. 1
0
 def _get_choice_lookup_data(self, schema):
     lookup_prop = schema['choice'].get('lookup')
     if self.locator and lookup_prop:
         locator_method_name = lookup_prop['path']
         file_type = schemas(self.plugins)[locator_method_name]['file_type']
         data = self._read_lookup_data_file(locator_method_name, file_type)
         return data[lookup_prop['sheet']][lookup_prop['column']].tolist() if data else None
     return None
Esempio n. 2
0
 def print_missing_input_files(self, config):
     schema_data = schemas(config.plugins)
     print()
     print("---------------------------")
     print("ERROR: Missing input files:")
     for method_name, path in self.missing_input_files(config):
         script_suggestions = (schema_data[method_name]['created_by']
                               if 'created_by' in schema_data[method_name]
                               else None)
         print('- {path}'.format(path=path))
         if script_suggestions:
             print('  (HINT: try running {scripts})'.format(path=path, scripts=', '.join(script_suggestions)))
Esempio n. 3
0
def main():
    import cea.config
    import cea.inputlocator
    from cea.utilities.schedule_reader import schedule_to_dataframe
    import pprint

    config = cea.config.Configuration()
    locator = cea.inputlocator.InputLocator(config.scenario)
    _schemas = schemas(plugins=[])
    validator = InputFileValidator(locator, plugins=config.plugins)
    locator_methods = [
        'get_database_construction_standards',
        'get_database_use_types_properties', 'get_database_supply_assemblies',
        'get_database_air_conditioning_systems',
        'get_database_envelope_systems', 'get_database_conversion_systems',
        'get_database_distribution_systems', 'get_database_feedstocks'
    ]

    for locator_method in locator_methods:
        db_path = locator.__getattribute__(locator_method)()
        df = pd.read_excel(db_path, sheet_name=None)
        print('Validating {}'.format(db_path))
        schema = _schemas[locator_method]
        errors = validator.validate(df, schema)
        if errors:
            pprint.pprint(errors)
        else:
            print("No errors found")

    for use_types in get_all_schedule_names(
            locator.get_database_use_types_folder()):
        db_path = locator.get_database_standard_schedules_use(use_types)
        df = schedule_to_dataframe(db_path)
        print('Validating {}'.format(db_path))
        schema = _schemas['get_database_standard_schedules_use']
        errors = validator.validate(df, schema)
        if errors:
            pprint.pprint(errors)
        else:
            print("No errors found")