@classmethod<EOL><INDENT>def check(cls, cfg, key_name, path, parent_cfg=None):<DEDENT>
attr = getattr(cls, key_name, None)<EOL>if path != "<STR_LIT>":<EOL><INDENT>attr_full_name = "<STR_LIT>" % (path, key_name)<EOL><DEDENT>else:<EOL><INDENT>attr_full_name = key_name<EOL><DEDENT>if not attr:<EOL><INDENT>raise vodka.exceptions.ConfigErrorUnknown(attr_full_name)<EOL><DEDENT>if attr.deprecated:<EOL><INDENT>vodka.log.warn("<STR_LIT>" % (<EOL>attr_full_name,<EOL>attr.deprecated<EOL>))<EOL><DEDENT>for prepare in attr.prepare:<EOL><INDENT>cfg[key_name] = prepare(cfg[key_name])<EOL><DEDENT>if hasattr(cls, "<STR_LIT>" % key_name):<EOL><INDENT>prepare = getattr(cls, "<STR_LIT>" % key_name)<EOL>cfg[key_name] = prepare(cfg[key_name], config=cfg)<EOL><DEDENT>value = cfg.get(key_name)<EOL>if isinstance(attr.expected_type, types.FunctionType):<EOL><INDENT>p, reason = attr.expected_type(value)<EOL>if not p:<EOL><INDENT>raise vodka.exceptions.ConfigErrorValue(<EOL>attr_full_name,<EOL>attr,<EOL>value,<EOL>reason=reason<EOL>)<EOL><DEDENT><DEDENT>elif attr.expected_type != type(value):<EOL><INDENT>raise vodka.exceptions.ConfigErrorType(<EOL>attr_full_name,<EOL>attr<EOL>)<EOL><DEDENT>if attr.choices and value not in attr.choices:<EOL><INDENT>raise vodka.exceptions.ConfigErrorValue(<EOL>attr_full_name,<EOL>attr,<EOL>value<EOL>)<EOL><DEDENT>if hasattr(cls, "<STR_LIT>" % key_name):<EOL><INDENT>validator = getattr(cls, "<STR_LIT>" % key_name)<EOL>valid, reason = validator(value)<EOL>if not valid:<EOL><INDENT>raise vodka.exceptions.ConfigErrorValue(<EOL>attr_full_name,<EOL>attr,<EOL>value,<EOL>reason=reason<EOL>)<EOL><DEDENT><DEDENT>num_crit = <NUM_LIT:0><EOL>num_warn = <NUM_LIT:0><EOL>if is_config_container(value) and attr.handler:<EOL><INDENT>if type(value) == dict or issubclass(type(value), Config):<EOL><INDENT>keys = list(value.keys())<EOL><DEDENT>elif type(value) == list:<EOL><INDENT>keys = list(range(<NUM_LIT:0>, len(value)))<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT>for k in keys:<EOL><INDENT>if not is_config_container(value[k]):<EOL><INDENT>continue<EOL><DEDENT>handler = attr.handler(k, value[k])<EOL>if issubclass(handler, Handler):<EOL><INDENT>h = handler<EOL><DEDENT>else:<EOL><INDENT>h = getattr(handler, "<STR_LIT>", None)<EOL><DEDENT>if h:<EOL><INDENT>if type(k) == int and type(value[k]) == dict and value[k].get("<STR_LIT:name>"):<EOL><INDENT>_path = "<STR_LIT>" % (<EOL>attr_full_name, value[k].get("<STR_LIT:name>"))<EOL><DEDENT>else:<EOL><INDENT>_path = "<STR_LIT>" % (attr_full_name, k)<EOL><DEDENT>_num_crit, _num_warn = h.validate(value[k], path=_path, nested=attr.nested, parent_cfg=cfg)<EOL>h.finalize(<EOL>value,<EOL>k,<EOL>value[k],<EOL>attr=attr,<EOL>attr_name=key_name,<EOL>parent_cfg=cfg<EOL>)<EOL>num_crit += _num_crit<EOL>num_warn += _num_warn<EOL><DEDENT><DEDENT><DEDENT>attr.finalize(cfg, key_name, value, num_crit=num_crit)<EOL>return (num_crit, num_warn)<EOL>
Checks that the config values specified in key name is
sane according to config attributes defined as properties
on this class