Skip to content

Commit

Permalink
update doc string, try except KeyError
Browse files Browse the repository at this point in the history
  • Loading branch information
maaikelimper committed Nov 27, 2023
1 parent 6efda8c commit a04f401
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions wis2box-create-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
def get_country_name(country_code: str) -> str:
"""
provide the country name for the wis2box
using the country's 2-letter ISO code
using the country's TLD code
using the data from config-templates/bounding_box_lookup.json
:param country_code: `str` 2-letter ISO code for the country
:param country_code: `str` of TLD code of the country
:returns: `str` of country name
"""
Expand All @@ -51,22 +51,24 @@ def get_country_name(country_code: str) -> str:
# load the data
data = json.load(fh)
# get the bounding box for the country
if country_code in data['countries'] and 'name' in data['countries'][country_code]: # noqa
try:
country_name = data['countries'][country_code]['name']
except KeyError:
pass

return country_name


def get_bounding_box(country_code: str) -> Tuple[str, str]:
"""
provide the initial bounding box for the wis2box
using the country's 2-letter ISO code
using the country's TLD code
using the data from config-templates/bounding_box_lookup.json
use bounding box for the whole world if no value is found in
the config-templates/bounding_box_lookup.json file
:param country_code: `str` 2-letter ISO code for the country
:param country_code: `str` of TLD code of the country
:returns: `tuple` of (country_name, bbox)
"""
Expand Down

0 comments on commit a04f401

Please sign in to comment.