|
29 | 29 | import rdflib |
30 | 30 | from cachetools import LRUCache |
31 | 31 | from frozendict import frozendict |
32 | | -from rdflib import RDF, XSD, BNode, Dataset, Literal, URIRef |
| 32 | +from rdflib import RDF, XSD, BNode, Dataset, Literal, Node, URIRef |
33 | 33 | from rdflib.graph import DATASET_DEFAULT_GRAPH_ID |
34 | 34 | from rdflib.parser import StringInputSource |
35 | 35 | from rdflib.plugins.parsers.nquads import NQuadsParser |
@@ -1459,7 +1459,13 @@ def to_nquads(dataset: dict | Dataset): |
1459 | 1459 | return dataset.serialize(format='nquads') |
1460 | 1460 |
|
1461 | 1461 | @staticmethod |
1462 | | - def to_nquad(triple, graph_name=None): |
| 1462 | + def to_nquad(triple: dict | tuple[Node, Node, Node], graph_name=None): |
| 1463 | + """Converts an RDF triple to an N-Quad string. |
| 1464 | + :param triple: the RDF triple to convert, either as a dict with keys |
| 1465 | + 'subject', 'predicate', 'object' (legacy) or as a tuple of rdflib Nodes. |
| 1466 | + :param graph_name: the name of the graph, if any (default: None). |
| 1467 | + :return: the N-Quad string representation of the triple. |
| 1468 | + """ |
1463 | 1469 | if isinstance(triple, dict): |
1464 | 1470 | triple = from_legacy_triple(triple) |
1465 | 1471 | return _nq_row(triple, graph_name) |
|
0 commit comments