Skip to content

Commit

Permalink
validator: Fix loading of a single schema file
Browse files Browse the repository at this point in the history
Normally a single file is a processed schema, but sometimes for testing
we want to pass in a single schema to check the processed output.

Signed-off-by: Rob Herring <robh@kernel.org>
  • Loading branch information
robherring committed Dec 15, 2023
1 parent 22b6f90 commit 6774d38
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dtschema/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ class DTValidator:
def __init__(self, schema_files, filter=None):
self.schemas = {}
self.resolver = jsonschema.RefResolver('', None, handlers={'http': self.http_handler})
schema_cache = None

if len(schema_files) == 1 and os.path.isfile(schema_files[0]):
# a processed schema file
Expand All @@ -345,6 +346,11 @@ def __init__(self, schema_files, filter=None):
print("preprocessed schema file is not valid JSON or YAML\n", file=sys.stderr)
raise

# Ensure the cache is a processed schema and not just a single schema file
if '$id' in schema_cache:
schema_cache = None

if schema_cache:
# Convert old format to new
if isinstance(schema_cache, list):
d = {}
Expand Down

0 comments on commit 6774d38

Please sign in to comment.