Skip to content

Commit 4d66223

Browse files
committed
Remove legacy nquads parser. Also add minor typing and legacy conversion
1 parent b4425fb commit 4d66223

2 files changed

Lines changed: 8 additions & 246 deletions

File tree

lib/pyld/jsonld.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import rdflib
3030
from cachetools import LRUCache
3131
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
3333
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID
3434
from rdflib.parser import StringInputSource
3535
from rdflib.plugins.parsers.nquads import NQuadsParser
@@ -1459,7 +1459,13 @@ def to_nquads(dataset: dict | Dataset):
14591459
return dataset.serialize(format='nquads')
14601460

14611461
@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+
"""
14631469
if isinstance(triple, dict):
14641470
triple = from_legacy_triple(triple)
14651471
return _nq_row(triple, graph_name)

lib/pyld/nquads.py

Lines changed: 0 additions & 244 deletions
This file was deleted.

0 commit comments

Comments
 (0)