2018-11-05 16:50:06 +01:00

22 lines
546 B
Python

import configparser
from voluptuous import Schema
from voluptuous.humanize import validate_with_humanized_errors
from carom.const import CONFIG_FILES, DEFAULT_CONFIG
_parser = configparser.ConfigParser()
_parser.read_string(DEFAULT_CONFIG)
_parser.read(CONFIG_FILES)
# Convert the ConfigParser object to a real dict now:
_parser_dict = {s: dict(_parser.items(s)) for s in _parser.sections()}
_schema = Schema({
'test': {
'foo': str,
},
})
config = validate_with_humanized_errors(_parser_dict, _schema)
__all__ = ('config', )