From 413c1ca49eaf62a9a3ca841264318189065fac53 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 6 Aug 2011 19:53:50 +0530 Subject: [PATCH] return stopnames with query --- best/smsmesn/handlers/fromto.py | 6 ++++-- best/smsmesn/handlers/stop.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/best/smsmesn/handlers/fromto.py b/best/smsmesn/handlers/fromto.py index dc01eb6..f81c8c9 100644 --- a/best/smsmesn/handlers/fromto.py +++ b/best/smsmesn/handlers/fromto.py @@ -53,12 +53,13 @@ def getBuses(frm, to): toArr = stopListTo.split(",") toArr = [val.split("|")[0] for val in toArr] intersectArr = [val for val in fromArr if val in toArr] + fromToStr = "from " + frm[1] + " to " + to[1] + ": " # return ",".join(fromArr) + ",".join(toArr) if (len(intersectArr) == 0): - return "no direct buses found." + return fromToStr + "no direct buses found." # return "from %s to %s" % (",".join(fromArr), ",".join(toArr),) else: - return ",".join(intersectArr) + return fromToStr + ",".join(intersectArr) class FromToHandler(KeywordHandler): keyword = "from" @@ -93,6 +94,7 @@ class FromToHandler(KeywordHandler): toString = "to %s" % (tos[0][1]) else: toString = "to %s" % (getOptions(tos)) + toString = "To location not found." self.respond(fromString + " " + toString) diff --git a/best/smsmesn/handlers/stop.py b/best/smsmesn/handlers/stop.py index a8f5927..245382b 100644 --- a/best/smsmesn/handlers/stop.py +++ b/best/smsmesn/handlers/stop.py @@ -17,6 +17,7 @@ class StopHandler(KeywordHandler): self.respond("Send stop to get buses that stop at a particular stop.") def handle(self, text): + print "STOP HANDLER" place = text.strip().lower() stopList = json.loads(open(join(JSON_PATH, "stoplist.json")).read().replace("\\", "/")) places = getStops(stopList, place) @@ -25,7 +26,7 @@ class StopHandler(KeywordHandler): elif len(places) == 1: data = json.loads(open(join(JSON_PATH, "stopbus.json")).read().replace("\\", "/").replace(",,,", ",").replace(",,", ",")) stop = getStop(data, places[0][1]) - stopStr = ",".join([val.split("|")[0] for val in stop[-1].split(",")]) + stopStr = stop[1] + ": " + ",".join([val.split("|")[0] for val in stop[-1].split(",")]) self.respond(stopStr) else: self.respond("try one of: %s" % getOptions(places))