Skip to content

Commit

Permalink
docstrings + formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas authored and jgonggrijp committed Dec 12, 2024
1 parent 9618451 commit 860349c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/collect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def get_graph(self, request: Request, collection: str, **kwargs) -> Graph:
g += collection_obj._class_triples()
g += EDPOPCollection.records._stored_triples(collection_obj)

return g
return g
7 changes: 7 additions & 0 deletions backend/collect/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def list_to_graph_collection(items: List[Node], items_node: IdentifiedNode) -> G


def collection_triples(graph: Graph, list_node: IdentifiedNode) -> Triples:
'''
Select all triples that make up an RDF collection in a graph.
This collects the chain of `rdf:first` / `rdf:rest` relations that make up the
collection.
'''

triples = list(graph.triples((list_node, RDF.first, None)))
triples += list(graph.triples((list_node, RDF.rest, None)))

Expand Down
4 changes: 4 additions & 0 deletions backend/collect/rdf_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
)

class CollectionMembersField(RDFField):
'''
Field for the records that are contained in an EDPOP collection.
'''

def get(self, instance: RDFModel):
g = self.get_graph(instance)
items = next(g.objects(instance.uri, AS.items), None)
Expand Down

0 comments on commit 860349c

Please sign in to comment.