Skip to content

Commit 88cc2f3

Browse files
committed
Allow text as RDF resource
1 parent 1f6ac6f commit 88cc2f3

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/software_card_policies/data_model.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,25 @@ def from_graph(cls, reference: URIRef, graph: Graph):
162162
)
163163

164164

165-
def read_rdf_resource(source: Path | str) -> Graph:
165+
def read_rdf_resource(
166+
source: Path | None = None,
167+
format: str | None = None,
168+
data: str | bytes | None = None,
169+
) -> Graph:
170+
"""Read in an RDF resource.
171+
172+
Either ``source``, or ``format`` and ``data`` must be given.
173+
"""
174+
assert (
175+
source is not None
176+
and format is None
177+
and data is None
178+
or source is None
179+
and format is not None
180+
and data is not None
181+
)
166182
graph = Graph()
167-
graph.parse(source)
183+
graph.parse(source=source, format=format, data=data)
168184
for prefix, iri in PREFIXES.items():
169185
graph.bind(prefix, iri, replace=True)
170186
return graph

0 commit comments

Comments
 (0)