Skip to content

Commit

Permalink
feat: add get_full_title util
Browse files Browse the repository at this point in the history
  • Loading branch information
simontaurus committed Oct 29, 2023
1 parent 7edd4ed commit 7a5aaf9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/osw/utils/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ def get_title(entity: model.Entity) -> Union[str, None]:
return title


def get_full_title(entity: model.Entity) -> Union[str, None]:
"""determines the wiki full title (namespace:title) based on the entity's data
Parameters
----------
entity
the entity to determine the full title for
Returns
-------
the full title as a string or None if the title could not be determined
"""
namespace = get_namespace(entity)
title = get_title(entity)
if namespace is not None and title is not None:
return namespace + ":" + title
else:
return title


def namespace_from_full_title(full_title: str) -> str:
"""extracts the namespace from a full title (namespace:title)
Expand Down

0 comments on commit 7a5aaf9

Please sign in to comment.