Skip to content

Commit

Permalink
Use passthrough from curies v0.6.6 (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt authored Oct 17, 2023
1 parent 75940bf commit 02ece78
Show file tree
Hide file tree
Showing 8 changed files with 1,140 additions and 978 deletions.
2,085 changes: 1,133 additions & 952 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.9,<4.0.0"
curies = ">=0.5.5"
curies = ">=0.6.6"
pronto = ">=2.5.0"
SPARQLWrapper = "*"
SQLAlchemy = ">=1.4.32"
Expand Down
3 changes: 1 addition & 2 deletions src/oaklib/converters/logical_definition_flattener.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def convert(
return obj

def _curie(self, iri: str) -> CURIE:
curie = self.curie_converter.compress(iri)
return curie if curie else iri
return self.curie_converter.compress(iri, passthrough=True)

@lru_cache
def _property_label(self, predicate: CURIE) -> str:
Expand Down
6 changes: 1 addition & 5 deletions src/oaklib/converters/obo_graph_to_cx_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,4 @@ def convert(self, source: Union[GraphDocument, Graph], target: Dict = None, **kw
def _id(self, uri: CURIE) -> CURIE:
if not self.curie_converter:
return uri
curie = self.curie_converter.compress(uri)
if curie is None:
return uri
else:
return curie
return self.curie_converter.compress(uri, passthrough=True)
6 changes: 1 addition & 5 deletions src/oaklib/converters/obo_graph_to_fhir_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ def code(self, uri: CURIE) -> str:
"""
if not self.curie_converter:
return uri
curie = self.curie_converter.compress(uri)
if curie is None:
return uri
else:
return curie
return self.curie_converter.compress(uri, passthrough=True)

def _convert_graph(
self,
Expand Down
6 changes: 1 addition & 5 deletions src/oaklib/converters/obo_graph_to_obo_format_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ def convert(self, source: GraphDocument, target: OboDocument = None, **kwargs) -
def _id(self, uri_or_curie: CURIE) -> CURIE:
if not self.curie_converter:
return uri_or_curie
curie = self.curie_converter.compress(uri_or_curie)
if curie is None:
return uri_or_curie
else:
return curie
return self.curie_converter.compress(uri_or_curie, passthrough=True)

def _predicate_id(self, uri_or_curie: CURIE, target: OboDocument) -> CURIE:
curie = self._id(uri_or_curie)
Expand Down
4 changes: 1 addition & 3 deletions src/oaklib/converters/obo_graph_to_rdf_owl_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,5 @@ def _add_reified(
def _uri_ref(self, curie: CURIE) -> rdflib.URIRef:
if self.curie_converter is None:
self.curie_converter = BasicOntologyInterface().converter
uri = self.curie_converter.expand(curie)
if uri is None:
uri = curie
uri = self.curie_converter.expand(curie, passthrough=True)
return rdflib.URIRef(uri)
6 changes: 1 addition & 5 deletions src/oaklib/interfaces/basic_ontology_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ def uri_to_curie(
:param use_uri_fallback: if cannot be contracted, use the URI as a CURIE proxy [default: True]
:return: contracted URI, or original URI if no contraction possible
"""
rv = self.converter.compress(uri)
if use_uri_fallback:
strict = False
rv = self.converter.compress(uri, passthrough=use_uri_fallback)
if rv is None and strict:
prefix_map_text = "\n".join(
f" {prefix} -> {uri_prefix}"
Expand All @@ -279,8 +277,6 @@ def uri_to_curie(
f"{self.__class__.__name__}.prefix_map() does not support compressing {uri}.\n"
f"This ontology interface contains {len(self.prefix_map()):,} prefixes:\n{prefix_map_text}"
)
if rv is None and use_uri_fallback:
return uri
return rv

@property
Expand Down

0 comments on commit 02ece78

Please sign in to comment.