adjectives = ["severe", "scattered", "partly", "mostly", "light", "heavy"] clearWords = ["clear", "sunny"] rainWords = ["rain", "showers"] fogWords = ["fog", "mist", "smoke"] windWords = ["wind", "windy", "gusts"] cloudWords = ["cloudy", "overcast"] def parseDescription(desc): # Parse a weather description by returning the first # "weather word" in a NWS description. # parsed = ((desc.lower()).split("/")).split(" ") parsed = ((desc.lower()).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" elif i in cloudWords: return "cloudy" else: return "clear" return "" def imageSelector(desc, timeOfDay): match desc: case "clear": if timeOfDay == "day": return "/smallIcons/clear-day-small.png" else: return "/smallIcons/clear-night-small.png" case "cloudy": if timeOfDay == "day": return "/smallIcons/overcast-day-small.png" else: return "/smallIcons/overcast-night-small.png" case "wind": return "/smallIcons/wind-small.png" case "thunderstorm": return "/smallIcons/thunderstorms-rain-small.png" case "rain": return "/smallIcons/rain-small.png" return "/smallIcons/code-red-small.png"