From d6de76377f62c86b64c849a9217fea22a7951dd4 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 20 Apr 2024 17:14:14 -0700 Subject: [PATCH] Set geoloc_city one level up so it's always set --- scl.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scl.py b/scl.py index d69be4a..2796837 100644 --- a/scl.py +++ b/scl.py @@ -182,15 +182,15 @@ def do_initial_post( print("JSON could not be loaded from nominatim API") raise - if geocode["features"][0]["properties"]["geocoding"]["city"] != "Seattle": - city_not_seattle_text = " of {}".format( - geocode["features"][0]["properties"]["geocoding"]["city"] - ) + city = geocode["features"][0]["properties"]["geocoding"]["city"] + street = geocode["features"][0]["properties"]["geocoding"]["name"] + event["geoloc_city"] = city + + if city != "Seattle": + city_not_seattle_text = " of {}".format(city) else: city_not_seattle_text = "" - street = geocode["features"][0]["properties"]["geocoding"]["name"] - if ( "locality" in geocode["features"][0]["properties"]["geocoding"] and event_class["size"] != "Large" @@ -219,13 +219,11 @@ def do_initial_post( ) event["neighborhood"] = district else: - city = geocode["features"][0]["properties"]["geocoding"]["city"] alt_text = "A map showing the location of the outage, centered around {} in {}.".format( street, city, ) area_text = city - event["geoloc_city"] = city except Exception: alt_text = "A map showing the location of the outage."