From 50c702e381017b568acd0c58206a88c901572855 Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Tue, 28 Feb 2012 12:40:48 -0800 Subject: [PATCH] change style to semicolons; take areas out of name search --- smsBEST/mumbai/app.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/smsBEST/mumbai/app.py b/smsBEST/mumbai/app.py index 637bdb9..95cc4f0 100644 --- a/smsBEST/mumbai/app.py +++ b/smsBEST/mumbai/app.py @@ -5,11 +5,15 @@ import arrest MAX_MSG_LEN = 160 DIGIT = re.compile(r"\d{1,3}") PUNCT = re.compile(r"[^\w\s]") +""" STYLE = { "start": "-* ", "repeat": " -*- ", "end": " *-" } +""" + +STYLE = {"start": "", "repeat": "; ", "end": ""} ChaloBest = arrest.Client("http://chalobest.in/1.0") @@ -23,11 +27,11 @@ class App(AppBase): if not stops: msg.respond("Sorry, we found no route marked '%s'." % msg.text) return - origin, destination = 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_area, dest_area = PUNCT.sub('', origin['area']), PUNCT.sub('', dest['area']) msg.respond("%s: %s (%s) to %s (%s)" % ( - ",".join(routes), - origin['display_name'], origin['area'], - destination['display_name'], destination['area'])) + ",".join(routes), origin_name, origin_area, dest_name, dest_area)) else: stops = ChaloBest.stops(q=msg.text)['features'] if not stops: @@ -36,8 +40,7 @@ class App(AppBase): response = STYLE["start"] for feature in stops: stop = feature['properties'] - area = PUNCT.sub('', stop['area']) - match = "%s (%s): %s" % (stop['official_name'], area, stop['routes']) + match = "%s: %s" % (stop['official_name'], stop['routes']) if len(response) > len(STYLE["repeat"]): response += STYLE["repeat"] response += match if len(response) > MAX_MSG_LEN: break