Skip to content

Commit 598f967

Browse files
committed
minor changes:
* Changed the tests to use an in-module fixture instead of the `test_ontology.owl` graph and removed the `test_ontology.owl` file. The problem with arbitrary test data is that it is hard to evolve. If possible test data should be kept as terse as possible. In this case I just created a namespace manager with three namespaces added, of which only two will be effective because of <#2077>. * Added a warning to `NamespaceManager.curie` to warn users that it is not a pure function and explain the specific side effects.
1 parent 21d4151 commit 598f967

File tree

4 files changed

+135
-371
lines changed

4 files changed

+135
-371
lines changed

rdflib/namespace/__init__.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,27 @@ def qname(self, uri: str) -> str:
491491
return ":".join((prefix, name))
492492

493493
def curie(self, uri: str) -> str:
494-
"""From a URI, generate a valid CURIE.
494+
"""
495+
From a URI, generate a valid CURIE.
496+
497+
Result is guaranteed to contain a colon separating the prefix from the
498+
name, even if the prefix is an empty string.
499+
500+
.. warning::
501+
502+
If there is no matching namespace for the URI in the namespace
503+
manager then a new namespace will be added with prefix
504+
``ns{index}``.
505+
506+
Because of this side effect this is not a pure function.
507+
508+
This is the same behaviour as `NamespaceManager.qname`.
509+
510+
511+
512+
:param uri: URI to generate CURIE for.
513+
:return: CURIE for the URI.
495514
496-
Result is guaranteed to contain a colon separating the prefix from the name,
497-
even if the prefix is an empty string.
498515
"""
499516
prefix, namespace, name = self.compute_qname(uri)
500517
return ":".join((prefix, name))

test/data/owl/test_ontology.owl

-315
This file was deleted.

0 commit comments

Comments
 (0)