You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
adjectives = ["severe", "scattered", "partly", "mostly"]
|
|
clearWords = ["clear", "sunny"]
|
|
rainWords = ["rain", "showers"]
|
|
fogWords = ["fog", "mist", "smoke"]
|
|
windWords = ["wind", "windy", "gusts"]
|
|
|
|
|
|
def parseDescription(desc):
|
|
# Parse a weather description by returning the first
|
|
# "weather word" in a NWS description.
|
|
parsed = desc.split(" ")
|
|
|
|
for i in parsed:
|
|
if i in adjectives:
|
|
continue
|
|
elif i in clearWords:
|
|
return "clear"
|
|
elif i in rainWords:
|
|
return "rain"
|
|
elif i in fogWords:
|
|
return "fog"
|
|
elif i in windWords:
|
|
return "wind"
|
|
else:
|
|
return "clear"
|
|
|
|
return ""
|
|
|
|
|
|
def imageSelector(desc, timeOfDay):
|
|
match desc:
|
|
case "Clear":
|
|
return "./smallIcons/clear-day-small.png"
|
|
case "Cloudy":
|
|
return "./smallIcons/cloudy-small.png"
|
|
case "Wind":
|
|
return "./smallIcons/wind-small.png"
|
|
case "Thunderstorm":
|
|
return "./smallIcons/thunderstorms-day-small.png"
|
|
case "Rain":
|
|
return "./smallIcons/rain-small.png"
|
|
|
|
return ""
|
|
|