Skip to content

Commit ae4267a

Browse files
authored
Update configure.py
Make program aware 'state' Geo API field may be not present.
1 parent bb4d1f1 commit ae4267a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

configure.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,15 @@ def on_search_click(self):
728728
cb_entries = []
729729
for entry in request.json():
730730
name = entry['name']
731-
state = entry['state']
731+
state = entry.get('state', None)
732732
lat = entry['lat']
733733
long = entry['lon']
734734
country_code = entry['country'].upper()
735735
country = babel.Locale(lang).territories[country_code]
736-
full_name = f"{name}, {state}, {country}"
736+
if state is not None:
737+
full_name = f"{name}, {state}, {country}"
738+
else:
739+
full_name = f"{name}, {country}"
737740
self._city_entries.append({"full_name": full_name, "lat": str(lat), "long": str(long)})
738741
cb_entries.append(full_name)
739742

0 commit comments

Comments
 (0)