Skip to content

Commit

Permalink
Early detection of missing bblocks:// refs
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Mar 19, 2024
1 parent 3ab474f commit be330b7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ogc/bblocks/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,24 @@ def walk_schema(schema):
pass
elif ref.startswith('bblocks://'):
# Get id directly from bblocks:// URI
deps.add(ref[len('bblocks://'):])
bblock_ref = ref[len('bblocks://'):]
ref_bblock_has_schema = True
if bblock_ref in self.bblocks:
ref_bblock_has_schema = self.bblocks[bblock_ref].schema.exists
elif bblock_ref in self.imported_bblocks:
ref_bblock_has_schema = bool(self.imported_bblocks[bblock_ref].get('schema'))
else:
# Unknown bblock!
raise ValueError(f'Invalid reference to bblock schema {bblock_ref}'
f' from {bblock.identifier} ({bblock.schema}) - the bblock does not exist'
f' - perhaps an import is missing?')

if not ref_bblock_has_schema:
# Referenced bblock has no schema!
raise ValueError(f'Invalid reference to bblock schema {bblock_ref}'
f' from {bblock.identifier} ({bblock.schema}) - the bblock has no schema')

deps.add(bblock_ref)
elif ref in self.imported_bblock_schemas:
# Import bblock schema URL
deps.add(self.imported_bblock_schemas[ref])
Expand Down

0 comments on commit be330b7

Please sign in to comment.