From 76c0feddb545be81becaeecf6d0177f55194326b Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sun, 4 Dec 2011 19:43:46 -0500 Subject: [PATCH] tfw: handle unknown locations properly --- modules/tfw.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/tfw.py b/modules/tfw.py index fde0f5d..f61ed94 100755 --- a/modules/tfw.py +++ b/modules/tfw.py @@ -30,12 +30,11 @@ def tfw(phenny, input, fahrenheit=False, celsius=False): doc = lxml.html.fromstring(req) - location = doc.find_class('small')[0].text_content() - - try: + try: + location = doc.find_class('small')[0].text_content() weather = doc.get_element_by_id('content') - except KeyError: - phenny.say("Unknown location") + except (IndexError, KeyError): + phenny.say("UNKNOWN FUCKING LOCATION. Try another?") return main = weather.find_class('large')