Skip to content

Commit

Permalink
allow both graph and types in ModelBase
Browse files Browse the repository at this point in the history
  • Loading branch information
minhnh committed Nov 22, 2024
1 parent 763acde commit 6302d3b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/rdf_utils/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ def __init__(
self, node_id: URIRef, graph: Optional[Graph] = None, types: Optional[set[URIRef]] = None
) -> None:
self.id = node_id
if graph is not None:
self.types = get_node_types(graph=graph, node_id=node_id)
assert (
types is None
), f"ModelBase.__init__: node '{node_id}': both 'graph' and 'types' args are not None"
elif types is not None:
if types is not None:
self.types = types
else:
raise RuntimeError(
f"ModelBase.__init__: node '{node_id}': neither 'graph' or 'types' specified"
)
assert (
graph is not None
), f"ModelBase.__init__: node '{node_id}': neither 'graph' or 'types' specified"
self.types = get_node_types(graph=graph, node_id=node_id)
assert len(self.types) > 0, f"node '{self.id}' has no type"

self._attributes = {}
Expand Down

0 comments on commit 6302d3b

Please sign in to comment.