From 1ee9cd4989129980804b1058d9a6348f3d74dd23 Mon Sep 17 00:00:00 2001 From: FireRogue Date: Tue, 2 Sep 2014 15:54:43 -0400 Subject: [PATCH 1/3] [weather] Add humidity data after temperature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit patch adds humidity data to weather output. sample output: `Yahoo! Weather - Newton, MA: Mostly Cloudy, 31°C (87°F) - 55%, 29in (1008mb), Moderate breeze 6.3m/s (↓)` --- weather.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/weather.py b/weather.py index 3929ea5f75..15fe309006 100644 --- a/weather.py +++ b/weather.py @@ -59,6 +59,14 @@ def get_temp(parsed): return (u'%d\u00B0C (%d\u00B0F)' % (temp, f)) +def get_humidity(parsed): + try: + humidity = parsed['feed']['yweather_atmosphere']['humidity'] + except (KeyError, ValueError): + return 'unknown' + return humidity + + def get_pressure(parsed): try: pressure = parsed['feed']['yweather_atmosphere']['pressure'] @@ -158,9 +166,10 @@ def weather(bot, trigger): cover = get_cover(parsed) temp = get_temp(parsed) + humidity = get_humidity(parsed) pressure = get_pressure(parsed) wind = get_wind(parsed) - bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, pressure, wind)) + bot.say(u'%s: %s, %s - %s%%, %s, %s' % (location, cover, temp, humidity, pressure, wind)) @commands('setlocation', 'setwoeid') From 503bdf1321b5234a7463587b9479452ef7143f0f Mon Sep 17 00:00:00 2001 From: FireRogue Date: Thu, 4 Sep 2014 20:43:03 -0400 Subject: [PATCH 2/3] [weather] Remove pressure and label humidity --- weather.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/weather.py b/weather.py index 15fe309006..b02f8e63b1 100644 --- a/weather.py +++ b/weather.py @@ -64,17 +64,7 @@ def get_humidity(parsed): humidity = parsed['feed']['yweather_atmosphere']['humidity'] except (KeyError, ValueError): return 'unknown' - return humidity - - -def get_pressure(parsed): - try: - pressure = parsed['feed']['yweather_atmosphere']['pressure'] - millibar = float(pressure) - inches = int(millibar / 33.7685) - except (KeyError, ValueError): - return 'unknown' - return ('%din (%dmb)' % (inches, int(millibar))) + return "humidity: %s%%" % humidity def get_wind(parsed): @@ -167,9 +157,8 @@ def weather(bot, trigger): cover = get_cover(parsed) temp = get_temp(parsed) humidity = get_humidity(parsed) - pressure = get_pressure(parsed) wind = get_wind(parsed) - bot.say(u'%s: %s, %s - %s%%, %s, %s' % (location, cover, temp, humidity, pressure, wind)) + bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, humidity, wind)) @commands('setlocation', 'setwoeid') From 2d8b2b1f2412eb494ca50276d04c07327a123d72 Mon Sep 17 00:00:00 2001 From: Lior Ramati Date: Thu, 4 Sep 2014 20:47:24 -0400 Subject: [PATCH 3/3] [weather] capitalize humidity in output --- weather.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weather.py b/weather.py index b02f8e63b1..682effe244 100644 --- a/weather.py +++ b/weather.py @@ -64,7 +64,7 @@ def get_humidity(parsed): humidity = parsed['feed']['yweather_atmosphere']['humidity'] except (KeyError, ValueError): return 'unknown' - return "humidity: %s%%" % humidity + return "Humidity: %s%%" % humidity def get_wind(parsed):