Add neighborhood hashtag (#26)
Initial implementation for #22 Reviewed-on: #26
This commit is contained in:
parent
4accc75c06
commit
5003ed04de
1 changed files with 25 additions and 6 deletions
31
scl.py
31
scl.py
|
@ -99,8 +99,22 @@ def classify_event_size(num_people: int) -> dict[str, str | bool]:
|
|||
|
||||
|
||||
def get_hashtag_string(event) -> str:
|
||||
hashtag_string = "#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format(
|
||||
event["identifier"]
|
||||
city = str()
|
||||
try:
|
||||
city = event["geoloc_city"]
|
||||
except KeyError:
|
||||
city = event["city"]
|
||||
|
||||
neighborhood_text = str()
|
||||
try:
|
||||
neighborhood = event["neighborhood"]
|
||||
if neighborhood != city:
|
||||
neighborhood_text = " #{}".format(neighborhood.title().replace(" ", ""))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
hashtag_string = "#SeattleCityLightOutage #SCLOutage{} #{}".format(
|
||||
neighborhood_text, city.title().replace(" ", "")
|
||||
)
|
||||
return hashtag_string
|
||||
|
||||
|
@ -191,22 +205,27 @@ def do_initial_post(
|
|||
city_not_seattle_text,
|
||||
)
|
||||
area_text = "the {} area{}".format(locality, city_not_seattle_text)
|
||||
event["neighborhood"] = locality
|
||||
elif "district" in geocode["features"][0]["properties"]["geocoding"]:
|
||||
district = geocode["features"][0]["properties"]["geocoding"]["district"]
|
||||
alt_text = "A map showing the location of the outage, centered around {} in the {} area{}.".format(
|
||||
street,
|
||||
geocode["features"][0]["properties"]["geocoding"]["district"],
|
||||
district,
|
||||
city_not_seattle_text,
|
||||
)
|
||||
area_text = "the {} area{}".format(
|
||||
geocode["features"][0]["properties"]["geocoding"]["district"],
|
||||
district,
|
||||
city_not_seattle_text,
|
||||
)
|
||||
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,
|
||||
geocode["features"][0]["properties"]["geocoding"]["city"],
|
||||
city,
|
||||
)
|
||||
area_text = geocode["features"][0]["properties"]["geocoding"]["city"]
|
||||
area_text = city
|
||||
event["geoloc_city"] = city
|
||||
except Exception:
|
||||
alt_text = "A map showing the location of the outage."
|
||||
|
||||
|
|
Loading…
Reference in a new issue