2 # vi: set softtabstop=4 shiftwidth=4 tabstop=8 expandtab:
4 """Formats an Itinerary for terse display."""
9 def __init__(self
, itinentries
):
10 self
.entries
= itinentries
12 # A list of text strings to display.
18 for ie
in self
.entries
:
19 if ie
.type == Itinerary
.TYPE_WALK_TO_STOP
:
20 self
.formatWalkToStop(ie
)
21 elif ie
.type == Itinerary
.TYPE_TAKE_BUS
:
22 self
.formatTakeBus(ie
)
24 def formatWalkToStop(self
, ie
):
25 line
= "-%s walk to %s (%s)" \
26 % (ie
.startTime
, ie
.destination
, ie
.busStop
)
27 self
.lines
.append(line
)
29 def formatTakeBus(self
, ie
):
30 line
= "-%s %s %s to %s at %s" \
31 % (ie
.startTime
, ie
.route
, ie
.direction
,
32 ie
.destination
, ie
.endTime
)
33 self
.lines
.append(line
)
36 return "\n".join(self
.lines
)