|
@@ -108,7 +108,7 @@ class Weather(Command): |
|
|
data = res["current_observation"] |
|
|
data = res["current_observation"] |
|
|
place = data["display_location"]["full"] |
|
|
place = data["display_location"]["full"] |
|
|
icon = self.get_icon(data["icon"], data["local_time_rfc822"], |
|
|
icon = self.get_icon(data["icon"], data["local_time_rfc822"], |
|
|
res["sun_phase"]) |
|
|
|
|
|
|
|
|
res["sun_phase"]).encode("utf8") |
|
|
weather = data["weather"] |
|
|
weather = data["weather"] |
|
|
temp_f, temp_c = data["temp_f"], data["temp_c"] |
|
|
temp_f, temp_c = data["temp_f"], data["temp_c"] |
|
|
humidity = data["relative_humidity"] |
|
|
humidity = data["relative_humidity"] |
|
@@ -130,25 +130,25 @@ class Weather(Command): |
|
|
def get_icon(self, condition, local_time, sun_phase): |
|
|
def get_icon(self, condition, local_time, sun_phase): |
|
|
"""Return a unicode icon to describe the given weather condition.""" |
|
|
"""Return a unicode icon to describe the given weather condition.""" |
|
|
icons = { |
|
|
icons = { |
|
|
"chanceflurries" : "☃", |
|
|
|
|
|
"chancerain" : "☂", |
|
|
|
|
|
"chancesleet" : "☃", |
|
|
|
|
|
"chancesnow" : "☃", |
|
|
|
|
|
"chancetstorms" : "☂", |
|
|
|
|
|
"clear" : "☽☀", |
|
|
|
|
|
"cloudy" : "☁", |
|
|
|
|
|
"flurries" : "☃", |
|
|
|
|
|
"fog" : "☁", |
|
|
|
|
|
"hazy" : "☁", |
|
|
|
|
|
"mostlycloudy" : "☁", |
|
|
|
|
|
"mostlysunny" : "☽☀", |
|
|
|
|
|
"partlycloudy" : "☁", |
|
|
|
|
|
"partlysunny" : "☽☀", |
|
|
|
|
|
"rain" : "☂", |
|
|
|
|
|
"sleet" : "☃", |
|
|
|
|
|
"snow" : "☃", |
|
|
|
|
|
"sunny" : "☽☀", |
|
|
|
|
|
"tstorms" : "☂", |
|
|
|
|
|
|
|
|
"chanceflurries": u"☃", |
|
|
|
|
|
"chancerain": u"☂", |
|
|
|
|
|
"chancesleet": u"☃", |
|
|
|
|
|
"chancesnow": u"☃", |
|
|
|
|
|
"chancetstorms": u"☂", |
|
|
|
|
|
"clear": u"☽☀", |
|
|
|
|
|
"cloudy": u"☁", |
|
|
|
|
|
"flurries": u"☃", |
|
|
|
|
|
"fog": u"☁", |
|
|
|
|
|
"hazy": u"☁", |
|
|
|
|
|
"mostlycloudy": u"☁", |
|
|
|
|
|
"mostlysunny": u"☽☀", |
|
|
|
|
|
"partlycloudy": u"☁", |
|
|
|
|
|
"partlysunny": u"☽☀", |
|
|
|
|
|
"rain": u"☂", |
|
|
|
|
|
"sleet": u"☃", |
|
|
|
|
|
"snow": u"☃", |
|
|
|
|
|
"sunny": u"☽☀", |
|
|
|
|
|
"tstorms": u"☂", |
|
|
} |
|
|
} |
|
|
try: |
|
|
try: |
|
|
icon = icons[condition] |
|
|
icon = icons[condition] |
|
@@ -164,7 +164,7 @@ class Weather(Command): |
|
|
return icon[int(srise < dt < sset)] |
|
|
return icon[int(srise < dt < sset)] |
|
|
return icon |
|
|
return icon |
|
|
except KeyError: |
|
|
except KeyError: |
|
|
return "?" |
|
|
|
|
|
|
|
|
return u"?" |
|
|
|
|
|
|
|
|
def format_ambiguous_result(self, res): |
|
|
def format_ambiguous_result(self, res): |
|
|
"""Format a message when there are multiple possible results.""" |
|
|
"""Format a message when there are multiple possible results.""" |
|
|