Skip to content

Commit

Permalink
[validate] Fix loading Graph from resource_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Mar 22, 2024
1 parent 74b3257 commit 460d205
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ogc/bblocks/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ def _validate_resource(bblock: BuildingBlock,
)
report = ValidationReportItem(source)

file_from = 'examples' if example_index else 'test resources'

def validate_inner():
json_doc = None
graph = None
Expand All @@ -319,13 +321,13 @@ def validate_inner():
using_fn = f"{output_filename.name} ({filename.stem})"
report.add_entry(ValidationReportEntry(
section=ValidationReportSection.FILES,
message=f'Using {using_fn} from examples',
message=f'Using {using_fn} from {file_from}',
))
else:
json_doc = load_yaml(filename=filename)
report.add_entry(ValidationReportEntry(
section=ValidationReportSection.FILES,
message=f'Using {filename.name} from test resources',
message=f'Using {filename.name} from {file_from}',
))
json_doc = jsonref.replace_refs(json_doc, base_uri=filename.as_uri(), merge_props=True, proxies=False)
except MarkedYAMLError as e:
Expand Down Expand Up @@ -451,17 +453,17 @@ def validate_inner():

elif filename.suffix == '.ttl':
try:
if example_index:
if resource_contents:
graph = Graph().parse(data=resource_contents, format='ttl')
report.add_entry(ValidationReportEntry(
section=ValidationReportSection.FILES,
message=f'Using {filename.name} from examples',
message=f'Using {filename.name} from {file_from}',
))
graph = Graph().parse(data=resource_contents, format='ttl')
else:
graph = Graph().parse(filename)
report.add_entry(ValidationReportEntry(
section=ValidationReportSection.FILES,
message=f'Using {filename.name} from test resources',
message=f'Using {filename.name} from {file_from}',
))
except (ValueError, SyntaxError) as e:
report.add_entry(ValidationReportEntry(
Expand Down

0 comments on commit 460d205

Please sign in to comment.