Actually report missing routes.

This commit is contained in:
Schuyler Erle 2012-02-28 13:08:53 -08:00
parent f43fdf5004
commit 194a08c11c

View File

@ -22,11 +22,11 @@ class App(AppBase):
def handle(self, msg): def handle(self, msg):
if DIGIT.search(msg.text): if DIGIT.search(msg.text):
routes = ChaloBest.routes(q=msg.text.replace(" ", "")) routes = ChaloBest.routes(q=msg.text.replace(" ", ""))
detail = ChaloBest.route[routes[0]] if not routes:
stops = detail['stops']['features']
if not stops:
msg.respond("Sorry, we found no route marked '%s'." % msg.text) msg.respond("Sorry, we found no route marked '%s'." % msg.text)
return return
detail = ChaloBest.route[routes[0]]
stops = detail['stops']['features']
origin, dest = stops[0]['properties'], stops[-1]['properties'] origin, dest = stops[0]['properties'], stops[-1]['properties']
origin_name, dest_name = origin['display_name'], dest['display_name'] origin_name, dest_name = origin['display_name'], dest['display_name']
origin_area, dest_area = PUNCT.sub('', origin['area']), PUNCT.sub('', dest['area']) origin_area, dest_area = PUNCT.sub('', origin['area']), PUNCT.sub('', dest['area'])