includehandler: Derive validator from schema

No need to hard-code this, validator_for() can find the right one as
well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka 2023-05-26 17:33:12 +02:00
parent 3aea34cab6
commit a1f38f9979

View File

@ -32,7 +32,7 @@ from collections.abc import Mapping
import functools import functools
import logging import logging
from jsonschema.validators import Draft4Validator from jsonschema.validators import validator_for
from .kasusererror import KasUserError from .kasusererror import KasUserError
from . import __file_version__, __compatible_file_version__ from . import __file_version__, __compatible_file_version__
@ -68,7 +68,8 @@ def load_config(filename):
raise LoadConfigException('Config file extension not recognized', raise LoadConfigException('Config file extension not recognized',
filename) filename)
validator = Draft4Validator(CONFIGSCHEMA) validator_class = validator_for(CONFIGSCHEMA)
validator = validator_class(CONFIGSCHEMA)
validation_error = False validation_error = False
for error in validator.iter_errors(config): for error in validator.iter_errors(config):