def test_extension_case_insensitive(self): config_file = """ section: option=value """ config_file_path = 'schema.yaml' loaded_config = utils.load_config_file(config_file_path, config_file) self.assertIn('section', loaded_config) config_file_path = 'schema.YAML' loaded_config = utils.load_config_file(config_file_path, config_file) self.assertIn('section', loaded_config) config_file = """[section]\noption=value""" config_file_path = 'schema.CONF' loaded_config = utils.load_config_file(config_file_path, config_file) self.assertIn('section', loaded_config) config_file_path = 'schema.conf' loaded_config = utils.load_config_file(config_file_path, config_file) self.assertIn('section', loaded_config)
def test_yaml_interpolation_compatible(self): config_file = """ section: option=%(value)s %()s %s """ config_file_path = 'schema.yaml' loaded_config = utils.load_config_file(config_file_path, config_file) self.assertIn('section', loaded_config)
def test_yaml(self): config_file = """ section: option=value """ config_file_path = 'schema.yaml' loaded_config = utils.load_config_file(config_file_path, config_file) self.assertIn('section', loaded_config)
def migrate(schema_file, config_file): '''Migrates a configuration file using a confirm schema.''' schema = load_schema_file(open(schema_file, 'r')) config = load_config_file(config_file, open(config_file, 'r').read()) config = append_existing_values(schema, config) migrated_config = generate_config_parser(config) migrated_config.write(sys.stdout)
def _call_validate(config_string, schema_string, **kwargs): """ Small wrapper to use the standard interface. """ config_parser = SafeConfigParser() config_parser.readfp(StringIO(config_string)) schema = yaml.load(StringIO(schema_string)) config = load_config_file('.ini', config_string) validation = validator.Validation(config, schema) validation.validate(**kwargs) return validation
def load_validation_from_files(schema_file_path, config_file_path): schema = load_schema_file(open(schema_file_path, 'r')) config = load_config_file(config_file_path, open(config_file_path, 'r').read()) return Validation(config, schema)
def validator_from_config_file(config_file_path, schema_file_path): schema = load_schema_file(open(schema_file_path, 'r')) config = load_config_file(config_file_path, open(config_file_path, 'r').read()) return Validation(config, schema)