Skip to content

Commit

Permalink
Merge pull request #547 from simphony/backwards-compatibility-fixes
Browse files Browse the repository at this point in the history
Backwards compatibility fixes
  • Loading branch information
urbanmatthias authored Nov 10, 2020
2 parents 67123f4 + 744c993 commit 12ee3a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions osp/core/ontology/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ def _do_get(self, name, _case_sensitive, _force_by_iri):
iri = rdflib.URIRef(str(self._iri) + iri_suffix)
try:
return self._namespace_registry.from_iri(iri, _name=name)
except ValueError:
return self._get_case_insensitive(name)
return self._get_case_insensitive(name)
except KeyError as e:
if not _case_sensitive:
return self._get_case_insensitive(name)
raise e

def _get_case_insensitive(self, name):
"""Get by trying alternative naming convention of given name.
Expand Down
3 changes: 3 additions & 0 deletions tests/test_case_insensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_get_case_insensitive_alternative(self):
self.assertEqual(alt("some_entity", False), "SOME_ENTITY")
self.assertEqual(alt("SOME_ENTITY", False), "SOME_ENTITY")

from osp.core.namespaces import cuba
self.assertEqual(cuba.wrapper, cuba.Wrapper)


if __name__ == "__main__":
unittest.main()

0 comments on commit 12ee3a8

Please sign in to comment.