Skip to content

Commit

Permalink
Add conditional to extract curie version if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
nanglo123 committed Aug 6, 2024
1 parent c2ec97a commit 03ea504
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/pyobo/api/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

def get_name_by_curie(curie: str, *, version: Optional[str] = None) -> Optional[str]:
"""Get the name for a CURIE, if possible."""
if version is None:
version = get_version(curie.split(":")[0])
prefix, identifier = normalize_curie(curie)
if prefix and identifier:
return get_name(prefix, identifier, version=version)
Expand Down
4 changes: 2 additions & 2 deletions src/pyobo/cli/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def ancestors(prefix: str, identifier: str, force: bool, version: Optional[str])
"""Look up ancestors."""
curies = get_ancestors(prefix=prefix, identifier=identifier, force=force, version=version)
for curie in sorted(curies or []):
click.echo(f"{curie}\t{get_name_by_curie(curie)}")
click.echo(f"{curie}\t{get_name_by_curie(curie, version)}")


@lookup.command()
Expand All @@ -295,7 +295,7 @@ def descendants(prefix: str, identifier: str, force: bool, version: Optional[str
"""Look up descendants."""
curies = get_descendants(prefix=prefix, identifier=identifier, force=force, version=version)
for curie in sorted(curies or []):
click.echo(f"{curie}\t{get_name_by_curie(curie)}")
click.echo(f"{curie}\t{get_name_by_curie(curie, version)}")


@lookup.command()
Expand Down

0 comments on commit 03ea504

Please sign in to comment.