Skip to content

Commit

Permalink
Bug Fix (#29)
Browse files Browse the repository at this point in the history
* Fall back to both US and UK if not found in one.

* add comment

---------

Co-authored-by: Rocktim Saikia <[email protected]>
  • Loading branch information
BioBox and rocktimsaikia authored Sep 12, 2023
1 parent 467cec2 commit 4852174
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cambd/cambd.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ def main(word: str, show_all: bool, verbose: bool, dictionary: str):
definitions,
)
)

# If no definition found in the selected dictionary, grab from all
if len(wanted_definitions) == 0:
spinner.warn(
f"No word found in the {dictionary} dictionary." " Grabbing from all."
)
wanted_definitions = list(
filter(
lambda want: want["DictionaryRegion"].lower() in ["us", "uk"],
definitions,
)
)

if not show_all:
print_definition(word_filtered, wanted_definitions[0], True, verbose)
else:
Expand Down

0 comments on commit 4852174

Please sign in to comment.