def getgraphcontent(self, graphuri):
"""Get the serialized content of a named graph.
Args:
graphuri: The URI of a named graph.
Returns:
content: A list of strings where each string is a quad.
"""
data = []
context = self.store.get_context(URIRef(graphuri))
triplestring = context.serialize(format='nt').decode('UTF-8')
# Since we have triples here, we transform them to quads by adding the graphuri
# TODO This might cause problems if ' .\n' will be part of a literal.
# Maybe a regex would be a better solution
triplestring = triplestring.replace(' .\n', ' <' + graphuri + '> .\n')
data = triplestring.splitlines()
data.remove('')
return data
评论列表
文章目录