Skip to content

Commit

Permalink
Merge pull request #63 from Jk40git/patch-1
Browse files Browse the repository at this point in the history
Update utils.py
  • Loading branch information
andrewtavis authored Feb 22, 2024
2 parents 1059ca8 + 04e478f commit 9a87f25
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/scribe_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Utility functions for data extraction, formatting and loading.
Contents:
_load_json,
_find,
get_scribe_languages,
get_language_qid,
get_language_iso,
Expand Down Expand Up @@ -87,18 +89,28 @@ def _find(source_key: str, source_value: str, target_key: str, error_msg: str):
"ignore-words": [...]
}
Given a key/value pair, the 'source', and the 'target' key, get the 'target' value.
Given a key/value pair, the 'source' and the 'target' key get the 'target' value.
Args:
source_value (str): e.g. 'english'.
source_key (str): e.g. 'language'.
target_key (str): e.g. 'iso'.
error_msg (str): for when a value cannot be found.
Parameters
----------
source_value : str
The source value to find equivalents for (e.g. 'english').
source_key : str
The source key to reference (e.g. 'language').
target_key : str
The key to target (e.g. 'iso').
Raises:
ValueError: when a source_value is not supported.
error_msg : str
The message displayed when a value cannot be found.
Returns:
Raises
------
ValueError : when a source_value is not supported.
Returns
-------
The 'target' value given the passed arguments.
"""
norm_source_value = source_value.lower()
Expand Down

0 comments on commit 9a87f25

Please sign in to comment.