Add support for both jsonschema v3 and old v2 (#459).

Reviewed-on: https://projects.torsion.org/borgmatic-collective/borgmatic/pulls/459
This commit is contained in:
Dan Helfman 2021-10-23 16:47:53 +00:00
commit 745a8f9b8a

View file

@ -110,7 +110,10 @@ def parse_configuration(config_filename, schema_filename, overrides=None):
override.apply_overrides(config, overrides) override.apply_overrides(config, overrides)
normalize.normalize(config) normalize.normalize(config)
validator = jsonschema.Draft7Validator(schema) try:
validator = jsonschema.Draft7Validator(schema)
except AttributeError:
validator = jsonschema.Draft4Validator(schema)
validation_errors = tuple(validator.iter_errors(config)) validation_errors = tuple(validator.iter_errors(config))
if validation_errors: if validation_errors: