enhancement of formatter output
This commit is contained in:
parent
ae7a28ae04
commit
a6df6c0f61
1 changed files with 13 additions and 8 deletions
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
import sys
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
|
||||
from weboob.capabilities.base import Currency, empty
|
||||
from weboob.capabilities.travel import ICapTravel, RoadmapFilters
|
||||
|
|
@ -37,14 +37,19 @@ class DeparturesFormatter(PrettyFormatter):
|
|||
s = obj.type
|
||||
if hasattr(obj, 'price') and not empty(obj.price):
|
||||
s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored('%6.2f %s' % (obj.price, Currency.currency2txt(obj.currency)), 'green'))
|
||||
if hasattr(obj, 'late') and not empty(obj.late) and obj.late > datetime.time():
|
||||
s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored('Late: %s' % obj.late, 'red', 'bold'))
|
||||
if hasattr(obj, 'information') and not empty(obj.information) and obj.information.strip() != '':
|
||||
s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored(obj.information, 'red'))
|
||||
return s
|
||||
|
||||
def get_description(self, obj):
|
||||
if hasattr(obj, 'arrival_time') and not empty(obj.arrival_time):
|
||||
s = '(%s) %s\n\t(%s) %s' % (self.colored(obj.time.strftime('%H:%M'), 'cyan'),
|
||||
obj.departure_station,
|
||||
self.colored(obj.arrival_time.strftime('%H:%M'), 'cyan'),
|
||||
obj.arrival_station)
|
||||
s = '(%s) %s%s\n\t(%s) %s' % (self.colored(obj.time.strftime('%H:%M'), 'cyan'),
|
||||
obj.departure_station,
|
||||
self.colored(' [Platform: %s]' % obj.platform, 'yellow') if (hasattr(obj, 'platform') and not empty(obj.platform)) else '',
|
||||
self.colored(obj.arrival_time.strftime('%H:%M'), 'cyan'),
|
||||
obj.arrival_station)
|
||||
else:
|
||||
s = '(%s) %20s -> %s' % (self.colored(obj.time.strftime('%H:%M'), 'cyan'),
|
||||
obj.departure_station, obj.arrival_station)
|
||||
|
|
@ -156,12 +161,12 @@ class Traveloob(ReplApplication):
|
|||
return None
|
||||
|
||||
try:
|
||||
date = datetime.strptime(text, '%Y-%m-%d %H:%M')
|
||||
date = datetime.datetime.strptime(text, '%Y-%m-%d %H:%M')
|
||||
except ValueError:
|
||||
try:
|
||||
date = datetime.strptime(text, '%H:%M')
|
||||
date = datetime.datetime.strptime(text, '%H:%M')
|
||||
except ValueError:
|
||||
raise ValueError(text)
|
||||
date = datetime.now().replace(hour=date.hour, minute=date.minute)
|
||||
date = datetime.datetime.now().replace(hour=date.hour, minute=date.minute)
|
||||
|
||||
return date
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue