Skip to content

Commit

Permalink
renamed from n3 to nt
Browse files Browse the repository at this point in the history
  • Loading branch information
nikokaoja committed Jul 28, 2024
1 parent 3fc7312 commit ce696c2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 deletions oxrdflib/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def rdflib_to_mime_type(rdflib_type: str) -> str:
"""Convert an rdflib type to a MIME type."""
if rdflib_type in ("ttl", "turtle"):
return "text/turtle"
if rdflib_type == "n3":
if rdflib_type in ("nt", "ntriples"):
return "application/n-triples"
if rdflib_type == "xml":
return "application/rdf+xml"
Expand All @@ -131,8 +131,8 @@ def ox_to_rdflib_type(ox_format: str) -> str:
"""Convert an Oxigraph format to a rdflib parser format."""
if ox_format in ("ox-turtle", "ox-ttl"):
return "turtle"
if ox_format == "ox-n3":
return "n3"
if ox_format in ("ox-nt", "ox-ntriples"):
return "nt"
if ox_format == "ox-xml":
return "xml"
raise ValueError(f"Unsupported Oxigraph type: {ox_format}")
2 changes: 1 addition & 1 deletion oxrdflib/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def parse(
self,
source: InputSource,
sink: Graph,
format: str = "ox-n3",
format: str = "ox-nt",
encoding: Optional[str] = None,
**kwargs: Any,
) -> None:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ OxSled = "oxrdflib.store:OxigraphStore"
[project.entry-points."rdf.plugins.parser"]
ox-turtle = "oxrdflib.parser:OxigraphTurtleParser"
ox-ttl = "oxrdflib.parser:OxigraphTurtleParser"
ox-n3 = "oxrdflib.parser:OxigraphNTriplesParser"
ox-ntriples = "oxrdflib.parser:OxigraphNTriplesParser"
ox-nt = "oxrdflib.parser:OxigraphNTriplesParser"
ox-xml = "oxrdflib.parser:OxigraphRdfXmlParser"


Expand Down
6 changes: 0 additions & 6 deletions tests/data/test.n3

This file was deleted.

16 changes: 8 additions & 8 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ def test_parsing_ox_url_turtle(self):
)
self.assertIsNotNone(graph)

def test_parsing_ox_n3_bulk_load(self):
def test_parsing_ox_ntriples_bulk_load(self):
graph = rdflib.Graph(store="Oxigraph")
graph.parse(_TEST_DIR / "data/test.n3", format="ox-n3", transactional=False)
graph.parse(_TEST_DIR / "data/test.nt", format="ox-ntriples", transactional=False)
self.assertEqual(len(graph), 6)

def test_parsing_ox_n3_load(self):
def test_parsing_ox_ntriples_load(self):
graph = rdflib.Graph(store="Oxigraph")
graph.parse(_TEST_DIR / "data/test.n3", format="ox-n3", transactional=True)
graph.parse(_TEST_DIR / "data/test.nt", format="ox-ntriples", transactional=True)

self.assertEqual(len(graph), 6)

def test_parsing_ox_n3_fallback(self):
def test_parsing_ox_ntriples_fallback(self):
graph = rdflib.Graph()
with warnings.catch_warnings(record=True) as warning:
graph.parse(_TEST_DIR / "data/test.n3", format="ox-n3", transactional=False)
graph.parse(_TEST_DIR / "data/test.nt", format="ox-ntriples", transactional=False)

self.assertEqual(
warning[0].message.args[0],
Expand All @@ -67,11 +67,11 @@ def test_parsing_ox_n3_fallback(self):
)
self.assertEqual(len(graph), 6)

def test_parsing_ox_url_n3(self):
def test_parsing_ox_url_ntriples(self):
graph = rdflib.Graph(store="Oxigraph")
graph.parse(
"https://i-adopt.github.io/ontology/ontology.nt",
format="ox-n3",
format="ox-ntriples",
transactional=True,
)
self.assertIsNotNone(graph)
Expand Down

0 comments on commit ce696c2

Please sign in to comment.