[transilien] fix #938 and adapt to brower2
This commit is contained in:
parent
158d3fb627
commit
f4576b5921
8 changed files with 218 additions and 607 deletions
|
|
@ -17,14 +17,10 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
|
||||
from weboob.capabilities.travel import CapTravel, Station, Departure, RoadStep
|
||||
from weboob.capabilities.travel import CapTravel
|
||||
from weboob.tools.backend import BaseBackend
|
||||
|
||||
from .browser import Transilien
|
||||
from .stations import STATIONS
|
||||
|
||||
|
||||
class TransilienBackend(BaseBackend, CapTravel):
|
||||
|
|
@ -37,32 +33,10 @@ class TransilienBackend(BaseBackend, CapTravel):
|
|||
BROWSER = Transilien
|
||||
|
||||
def iter_station_search(self, pattern):
|
||||
pattern = pattern.lower()
|
||||
for _id, name in STATIONS.iteritems():
|
||||
if name.lower().find(pattern) >= 0:
|
||||
yield Station(_id, name)
|
||||
return self.browser.get_stations(pattern)
|
||||
|
||||
def iter_station_departures(self, station_id, arrival_id=None, date=None):
|
||||
with self.browser:
|
||||
for i, d in enumerate(self.browser.iter_station_departures(station_id, arrival_id)):
|
||||
departure = Departure(i, d['type'], d['time'])
|
||||
departure.departure_station = d['departure']
|
||||
departure.arrival_station = d['arrival']
|
||||
departure.late = d['late']
|
||||
departure.information = d['late_reason']
|
||||
departure.plateform = d['plateform']
|
||||
yield departure
|
||||
return self.browser.get_station_departues(station_id.replace('-', ' '), arrival_id, date)
|
||||
|
||||
def iter_roadmap(self, departure, arrival, filters):
|
||||
with self.browser:
|
||||
roadmap = self.browser.get_roadmap(departure, arrival, filters)
|
||||
|
||||
for s in roadmap['steps']:
|
||||
step = RoadStep(s['id'])
|
||||
step.line = s['line']
|
||||
step.start_time = s['start_time']
|
||||
step.end_time = s['end_time']
|
||||
step.departure = s['departure']
|
||||
step.arrival = s['arrival']
|
||||
step.duration = s['duration']
|
||||
yield step
|
||||
return self.browser.get_roadmap(departure, arrival, filters)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue