display price information
This commit is contained in:
parent
faf54b6262
commit
d8ccc81f93
2 changed files with 13 additions and 1 deletions
|
|
@ -79,8 +79,16 @@ class VoyagesSNCFBackend(BaseBackend, ICapTravel):
|
|||
self._populate_stations()
|
||||
|
||||
pattern = pattern.lower()
|
||||
already = set()
|
||||
|
||||
# First stations whose name starts with pattern...
|
||||
for _id, name in enumerate(self.STATIONS):
|
||||
if name.lower().startswith(pattern):
|
||||
already.add(_id)
|
||||
yield Station(_id, unicode(name))
|
||||
# ...then ones whose name contains pattern.
|
||||
for _id, name in enumerate(self.STATIONS):
|
||||
if pattern in name.lower() and not _id in already:
|
||||
yield Station(_id, unicode(name))
|
||||
|
||||
def iter_station_departures(self, station_id, arrival_id=None, date=None):
|
||||
|
|
@ -105,4 +113,5 @@ class VoyagesSNCFBackend(BaseBackend, ICapTravel):
|
|||
departure.arrival_time = d['arrival_time']
|
||||
departure.price = d['price']
|
||||
departure.currency = d['currency']
|
||||
departure.information = d['price_info']
|
||||
yield departure
|
||||
|
|
|
|||
|
|
@ -88,14 +88,16 @@ class ResultsPage(BasePage):
|
|||
|
||||
def iter_results(self):
|
||||
for div in self.document.getroot().cssselect('div.train_info'):
|
||||
info = None
|
||||
price = None
|
||||
currency = None
|
||||
for td in div.cssselect('td.price'):
|
||||
txt = self.parser.tocleanstring(td)
|
||||
p = Decimal(re.sub('([^\d\.]+)', '', txt))
|
||||
currency = Currency.get_currency(txt)
|
||||
if price is None or p < price:
|
||||
info = list(div.cssselect('strong.price_label')[0].itertext())[-1].strip().strip(':')
|
||||
price = p
|
||||
currency = Currency.get_currency(txt)
|
||||
|
||||
yield {'type': self.get_value(div, 'div.transporteur-txt'),
|
||||
'time': self.parse_hour(div, 'div.departure div.hour'),
|
||||
|
|
@ -104,4 +106,5 @@ class ResultsPage(BasePage):
|
|||
'arrival_time': self.parse_hour(div, 'div.arrival div.hour', last=True),
|
||||
'price': price,
|
||||
'currency': currency,
|
||||
'price_info': info,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue