Skip to content

Commit

Permalink
error handling fixed, all tests passed.
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Mittal <[email protected]>
  • Loading branch information
shashank-iitbhu committed Jan 21, 2024
1 parent a880b74 commit 2a5b295
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/scribe_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ def get_language_iso(language: str) -> str:
"""
try:
iso_code = str(langcodes.find(language).language)
return iso_code
except langcodes.LanguageTagError:
except LookupError:
raise ValueError(f"{language.capitalize()} is currently not a supported language for ISO conversion.")


return iso_code

def get_language_from_iso(iso: str) -> str:
"""
Expand All @@ -178,11 +176,12 @@ def get_language_from_iso(iso: str) -> str:
str
The name for the language which has an ISO value of iso.
"""
try:
language_name = str(Language.make(language=iso).display_name())
return language_name
except langcodes.LanguageTagError:
raise ValueError(f"{iso} is currently not a supported ISO language.")

language_name = str(Language.make(language=iso).display_name())
if "Unknown language" in str(language_name):
raise ValueError(f"{iso.upper()} is currently not a supported ISO language.")
return language_name


def get_language_words_to_remove(language: str) -> list[str]:
"""
Expand Down

0 comments on commit 2a5b295

Please sign in to comment.