From 73a443f518be29a50981e7e137e2b4c2c37552dd Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 May 2022 16:52:14 +0200 Subject: improve loading of schema files --- src/hydrilla/builder/build.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/hydrilla/builder/build.py') diff --git a/src/hydrilla/builder/build.py b/src/hydrilla/builder/build.py index 33838f3..a3c55a7 100644 --- a/src/hydrilla/builder/build.py +++ b/src/hydrilla/builder/build.py @@ -51,15 +51,6 @@ here = Path(__file__).resolve().parent _ = util.translation(here / 'locales').gettext -def index_validator(major_schema_version): - """ - Create an index.json schema validator specific to the requested schema - version series. - """ - exact_version = {1: '1.0.1', 2: '2'}[major_schema_version] - - return util.validator_for(f'package_source-{exact_version}.schema.json') - schemas_root = 'https://hydrilla.koszko.org/schemas' generated_by = { @@ -365,7 +356,9 @@ class Build: files and computed definitions of the source package and items defined in it. """ - index_validator(major_schema_version).validate(index_obj) + schema_name = f'package_source-{major_schema_version}.schema.json'; + + util.validator_for(schema_name).validate(index_obj) match = re.match(r'.*-((([1-9][0-9]*|0)\.)+)schema\.json$', index_obj['$schema']) -- cgit v1.2.3