예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
파일: main.py 프로젝트: Ronan-/confirm
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)
예제 #7
0
    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)
예제 #8
0
파일: main.py 프로젝트: fcharette/confirm
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)
예제 #9
0
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
예제 #10
0
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
예제 #11
0
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)
예제 #12
0
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)