From 6d86ef054f5a2ee25fc2a07e55344fe060f08c8c Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 5 Jun 2005 21:44:14 +0000 Subject: [PATCH] randomfixin --- Itinerary.py | 10 + Planner.py | 23 +- grabs/out.html | 662 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ grabs/wantout.txt | 6 + 4 files changed, 688 insertions(+), 13 deletions(-) create mode 100644 Itinerary.py create mode 100644 grabs/out.html create mode 100644 grabs/wantout.txt diff --git a/Itinerary.py b/Itinerary.py new file mode 100644 index 0000000..9d047b1 --- /dev/null +++ b/Itinerary.py @@ -0,0 +1,10 @@ +# +# vi: set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: + +"""mcPlan""" + +class Itinerary: + def __init__(self, start, end, html): + self.start = start + self.end = end + self.html = html diff --git a/Planner.py b/Planner.py index d625f71..5e0ef33 100644 --- a/Planner.py +++ b/Planner.py @@ -8,19 +8,22 @@ import urllib2 import urllib import sre +import Itinerary + def plan(start, end, time): """Plans a route between two Locations at a certain PlanTime.""" planner = TravelPlannerClient() planner.feedStartLocation(start) planner.feedEndLocation(end) - planner.feedTime(time) + html = planner.feedTime(time) + return Itinerary.Itinerary(start, end, time, html) class TravelPlannerException(Exception): """Generic parent exception for anything thrown by us, as opposed to things thrown by the network layer.""" - def _init_(self, value): - Exception._init_(self, value) + def __init__(self, value): + Exception.__init__(self, value) class InvalidLocationException(TravelPlannerException): """Thrown when a source or destination can't be found. @@ -28,10 +31,10 @@ class InvalidLocationException(TravelPlannerException): The "args" value of the exception is the original Location.""" def _init(self, location): - TravelPlannerException._init_(self, location) + TravelPlannerException.__init__(self, location) class TravelPlannerClient: - def _init_(self): + def __init__(self): # Set up a cookie-aware client. self.cj = cookielib.CookieJar() self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj)) @@ -52,21 +55,15 @@ class TravelPlannerClient: def feedTime(self, time): # name="tp_time" action="SelectTime.oci" - # dateSelect=" - # requestCode=3 for must leave after - # time - # timePeriod=am or pm r = self._sendRequest("SelectTime.oci", time.toPlannerParams()) - for line in r: - print line.rstrip() + return r def _sendRequest(self, page, params): url = self.URL_BASE + page if params is not None: url += "?" + urllib.urlencode(params) - print dir(self) response = self.opener.open(url) self._checkObviousBadness(response) @@ -99,7 +96,7 @@ class TravelPlannerClient: # Probably the best thing to put in your breakfast cereal. def _scanForError(self, text): - match = error_rx.search(text) + match = _error_rx.search(text) if match: raise TravelPlannerException(match.group("msg")) diff --git a/grabs/out.html b/grabs/out.html new file mode 100644 index 0000000..1dd18e6 --- /dev/null +++ b/grabs/out.html @@ -0,0 +1,662 @@ + + + + + + + + + +OC Travel Planner + + + + + + + + + + + + + + + + + + + + + + + + +
 
+ + + + + + + + + + +
  + + + + + + + + + + + + + + 18 AURIGA DR + + + + + + + + + + + + + + + + + + + + + 35 FLORENCE ST + + + + + +
+ +
Arriving at 7:03 PM +
  
+ + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + +
   +
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + +
Depart at 6:05 PM + + + + Regular fare + + + + + + + + 2 transfers + + +
Arrive at 7:03 PMDuration: 58 minutes.Total walking: 10 minutes
+
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
   6:05 PM  + DEPARTURE
Depart at 6:05 PM +
   + + 18 AURIGA DR + +
+
At 6:05 PM, walk to stop AURIGA / EPSILON (5 min.). + +
+
   + + + + + + + + + AURIGA / EPSILON + (6089) + + + + + + + +
+ At 6:10 PM, take Bus route 116 direction Baseline and get off at stop MERIVALE / COLONNADE, street MERIVALE following street COLONNADE.
Last intersections: WEST HUNT CLUB RD, ROYDON PL, COLONNADE RD. + Arrive at 6:20 PM. + + +
+
+
+
+ + + + + + + 116   + + + + + +
+
+
+ +
+ + + + + MERIVALE / COLONNADE + (1635) + + + +
Wait 9 minute(s).   
+ At 6:29 PM, take Bus route 3 direction Hurdman and get off at stop PRESTON / GLADSTONE, street PRESTON following street GLADSTONE.
Last intersections: ST. ANTHONY ST, LOUISA ST, GLADSTONE AVE. + Arrive at 6:47 PM. + + +
+
+
+
+ + + + + + + 3   + + + + + +
+
+
+ +
+ + + + + PRESTON / GLADSTONE + (6652) + + + +
Walk to stop GLADSTONE / PRESTON for transfer. + +
+
   + + + + + + + + + GLADSTONE / PRESTON + (6665) + + + + + + + +
Wait 7 minute(s).   
+ At 6:56 PM, take Bus route 14 direction St Laurent and get off at stop GLADSTONE / KENT, street GLADSTONE near street KENT.
Last intersections: PERCY ST, BAY ST, LYON ST. + Arrive at 7:00 PM. + + +
+
+
+
+ + + + + + + 14   + + + + + +
+
+
+ +
+ + + + + GLADSTONE / KENT + (6646) + + + +
Walk to 35 FLORENCE. +Arrive at 7:03 PM (3 min.). + + +    + + + + + + + + + + + + + + + 35 FLORENCE ST
+ + + + + + + +
+ + + + + + +   7:03 PM  + ARRIVAL +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click on a bus stop to see more passing times + +
+ + + + + + + + + +
   
+ + diff --git a/grabs/wantout.txt b/grabs/wantout.txt new file mode 100644 index 0000000..ab9a95e --- /dev/null +++ b/grabs/wantout.txt @@ -0,0 +1,6 @@ +-walk Auriga/Epsilon +-6:10 116 Baseline to MERIVALE/COLONNADE at 6:20 +-6:29 3 Hurdman to PRESTON/GLADSTONE at 6:47 +-walk GLADSTONE/PRESTON +-6:56 14 St L to GLADSTONE/KENT at 7:00 +-walk XX FLORENCE 7:03 -- 2.11.4.GIT