Skip to content

Commit b448622

Browse files
authored
Merge pull request #50 from softwarepub/changes-for-hermes-interface
First changes to interface with HERMES plugin
2 parents 1f6ac6f + dc61073 commit b448622

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/software_card_policies/data_model.py

Lines changed: 19 additions & 3 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
@@ -275,4 +291,4 @@ def make_shacl_graph(config: Config) -> Graph:
275291
policy_graph = read_rdf_resource(policy.source)
276292
shacl_graph = parameterize_graph(policy_graph, policy.parameters)
277293
shacl_graphs.append(shacl_graph)
278-
return reduce(operator.add, shacl_graphs)
294+
return reduce(operator.add, shacl_graphs, Graph())

0 commit comments

Comments
 (0)