Catch "Showers" as "Rainy" weather condition (#356)
* Catch "Showers" as "Rainy" weather condition Weather.com has a "Showers in the Vicinity" weather condition that I just happened to see this morning. This commit assigns this condition as "Rainy" so it is properly colorized. * Make "Clear / Windy" map to "Fair" weather condition Another odd weather condition from the weather.com API * Reverse icons for Fair and Sunny "Sunny" should have a filled-in sun icon as it implies a brighter weather condition than "Fair" does. * Properly detect "Sunny / Windy" as "Sunny" weather condition Also, do not check for similarly-named conditions if an exact match is found. * Properly detect "Fair / Windy" as "Fair"
This commit is contained in:
parent
ad2f08e89b
commit
01395c6b39
@ -84,12 +84,12 @@ class Weather(IntervalModule):
|
|||||||
|
|
||||||
colorize = False
|
colorize = False
|
||||||
color_icons = {
|
color_icons = {
|
||||||
'Fair': (u'\u2600', '#ffcc00'),
|
'Fair': (u'\u263c', '#ffcc00'),
|
||||||
'Cloudy': (u'\u2601', '#f8f8ff'),
|
'Cloudy': (u'\u2601', '#f8f8ff'),
|
||||||
'Partly Cloudy': (u'\u2601', '#f8f8ff'), # \u26c5 is not in many fonts
|
'Partly Cloudy': (u'\u2601', '#f8f8ff'), # \u26c5 is not in many fonts
|
||||||
'Rainy': (u'\u26c8', '#cbd2c0'),
|
'Rainy': (u'\u26c8', '#cbd2c0'),
|
||||||
'Thunderstorm': (u'\u03de', '#cbd2c0'),
|
'Thunderstorm': (u'\u03de', '#cbd2c0'),
|
||||||
'Sunny': (u'\u263c', '#ffff00'),
|
'Sunny': (u'\u2600', '#ffff00'),
|
||||||
'Snow': (u'\u2603', '#ffffff'),
|
'Snow': (u'\u2603', '#ffffff'),
|
||||||
'default': ('', None),
|
'default': ('', None),
|
||||||
}
|
}
|
||||||
@ -113,17 +113,24 @@ class Weather(IntervalModule):
|
|||||||
Disambiguate similarly-named weather conditions, and return the icon
|
Disambiguate similarly-named weather conditions, and return the icon
|
||||||
and color that match.
|
and color that match.
|
||||||
'''
|
'''
|
||||||
|
if condition not in self.color_icons:
|
||||||
|
# Check for similarly-named conditions if no exact match found
|
||||||
condition_lc = condition.lower()
|
condition_lc = condition.lower()
|
||||||
if condition_lc == 'clear':
|
|
||||||
condition = 'Fair'
|
|
||||||
if 'cloudy' in condition_lc:
|
if 'cloudy' in condition_lc:
|
||||||
|
if 'partly' in condition_lc:
|
||||||
|
condition = 'Partly Cloudy'
|
||||||
|
else:
|
||||||
condition = 'Cloudy'
|
condition = 'Cloudy'
|
||||||
elif 'rain' in condition_lc:
|
|
||||||
condition = 'Rainy'
|
|
||||||
elif 'thunder' in condition_lc:
|
elif 'thunder' in condition_lc:
|
||||||
condition = 'Thunderstorm'
|
condition = 'Thunderstorm'
|
||||||
elif 'snow' in condition_lc:
|
elif 'snow' in condition_lc:
|
||||||
condition = 'Snow'
|
condition = 'Snow'
|
||||||
|
elif 'rain' in condition_lc or 'showers' in condition_lc:
|
||||||
|
condition = 'Rainy'
|
||||||
|
elif 'sunny' in condition_lc:
|
||||||
|
condition = 'Sunny'
|
||||||
|
elif 'clear' in condition_lc or 'fair' in condition_lc:
|
||||||
|
condition = 'Fair'
|
||||||
|
|
||||||
return self.color_icons['default'] \
|
return self.color_icons['default'] \
|
||||||
if condition not in self.color_icons \
|
if condition not in self.color_icons \
|
||||||
|
Loading…
Reference in New Issue
Block a user