From e51896b2cd6a68de73db688fb99906fcdbcc0c12 Mon Sep 17 00:00:00 2001 From: Hoang Tung Dinh Date: Thu, 22 Aug 2024 09:30:29 +0200 Subject: [PATCH] Use resource to access schema file (#51) Signed-off-by: hoangtungdinh <11166240+hoangtungdinh@users.noreply.github.com> --- qc_openscenario/checks/schema_checker/valid_schema.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qc_openscenario/checks/schema_checker/valid_schema.py b/qc_openscenario/checks/schema_checker/valid_schema.py index 727eb42..c5db90b 100644 --- a/qc_openscenario/checks/schema_checker/valid_schema.py +++ b/qc_openscenario/checks/schema_checker/valid_schema.py @@ -1,3 +1,4 @@ +import importlib.resources import os, logging from dataclasses import dataclass @@ -68,8 +69,9 @@ def check_rule(checker_data: models.CheckerData) -> None: schema_files_dict = schema_files.SCHEMA_FILES xsd_file = schema_files_dict[schema_version] - xsd_file_path = os.path.join("qc_openscenario", "schema", xsd_file) - + xsd_file_path = str( + importlib.resources.files("qc_openscenario.schema").joinpath(xsd_file) + ) schema_compliant, errors = _is_schema_compliant( checker_data.input_file_xml_root, xsd_file_path )