From ac5049ae07e026b89053a7321fac1d11e939be58 Mon Sep 17 00:00:00 2001 From: Juke Date: Tue, 13 Apr 2010 18:26:25 +0200 Subject: [PATCH 1/4] remove arg_parse error when len(args) > nb_args --- weboob/tools/application/console.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/weboob/tools/application/console.py b/weboob/tools/application/console.py index 78be4b8d..593b1e26 100644 --- a/weboob/tools/application/console.py +++ b/weboob/tools/application/console.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -Copyright(C) 2010 Romain Bignon +Copyright(C) 2010 Romain Bignon, Julien Hébert This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,7 +85,8 @@ class ConsoleApplication(BaseApplication): nb_args = len(_args) - 1 if defaults: nb_args -= len(defaults) - if len(args) < nb_args or len(args) > nb_args and not varargs: + + if len(args) < nb_args and not varargs: if varargs: sys.stderr.write("Command '%s' takes at least %d arguments.\n" % (command, nb_args)) else: From 9363333b3432bd3f6b68fe2daec50db3b1d4847f Mon Sep 17 00:00:00 2001 From: Juke Date: Tue, 13 Apr 2010 19:17:01 +0200 Subject: [PATCH 2/4] ADD plateform to disting late_reason and plateform --- weboob/backends/transilien/backend.py | 1 + weboob/backends/transilien/browser.py | 20 ++++++++++++++------ weboob/capabilities/travel.py | 1 + weboob/frontends/travel/application.py | 11 ++++++----- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/weboob/backends/transilien/backend.py b/weboob/backends/transilien/backend.py index d3d0fa1f..71e8a60c 100644 --- a/weboob/backends/transilien/backend.py +++ b/weboob/backends/transilien/backend.py @@ -46,4 +46,5 @@ class TransilienBackend(Backend, ICapTravel): departure.arrival_station = d['arrival'] departure.late = d['late'] departure.information = d['late_reason'] + departure.plateform = d['plateform'] yield departure diff --git a/weboob/backends/transilien/browser.py b/weboob/backends/transilien/browser.py index 4f82c907..e6451b16 100644 --- a/weboob/backends/transilien/browser.py +++ b/weboob/backends/transilien/browser.py @@ -133,12 +133,20 @@ class Transilien(Browser): else: self.location('http://www.transilien.com/web/ITProchainsTrains.do?tr3a=%s&urlModule=/site/pid/184' % station_id) for route in self.page.document.list_route: - yield {'type': toUnicode(route.code_mission), - 'time': datetime.combine(date.today(), time(*[int(x) for x in route.time.split(':')])), - 'departure': toUnicode(station_id), - 'arrival': toUnicode(route.destination), - 'late': time(), - 'late_reason': toUnicode(route.platform)} + _late_reason = None + try : + _time = datetime.combine(date.today(), time(*[int(x) for x in route.time.split(':')])) + except ValueError: + _time = None + _late_reason = route.time + else: + yield {'type': toUnicode(route.code_mission), + 'time': _time, + 'departure': toUnicode(station_id), + 'arrival': toUnicode(route.destination), + 'late': time(), + 'late_reason': _late_reason, + 'plateform': toUnicode(route.platform)} def home(self): pass diff --git a/weboob/capabilities/travel.py b/weboob/capabilities/travel.py index 9103da38..138efc78 100644 --- a/weboob/capabilities/travel.py +++ b/weboob/capabilities/travel.py @@ -59,6 +59,7 @@ class Departure(object): self.arrival_station = u'' self.late = time() self.information = u'' + self.plateform = u'' def __repr__(self): return "" % (self.id, diff --git a/weboob/frontends/travel/application.py b/weboob/frontends/travel/application.py index 40bb395d..adddf8a5 100644 --- a/weboob/frontends/travel/application.py +++ b/weboob/frontends/travel/application.py @@ -45,18 +45,19 @@ class Travel(ConsoleApplication): @ConsoleApplication.command('List all departures on a special station') def command_departures(self, station, arrival=None): - print ".-----.-----------.-------.-----------------------.-------.--------------------." - print "| ID | Type | Time | Arrival | Late | Info |" - print "+-----+-----------+-------+-----------------------+-------+--------------------+" + print ".-----.-----------.-------.-----------------------.-------.--------------------.------------" + print "| ID | Type | Time | Arrival | Late | Info | Plateform |" + print "+-----+-----------+-------+-----------------------+-------+--------------------+-----------+" count = 0 for name, backend, in self.weboob.iter_backends(): for departure in backend.iter_station_departures(station, arrival): - print u"|%4d | %-10s|%6s | %-22s|%6s | %-19s|" % (departure.id, + print u"|%4d | %-10s|%6s | %-22s|%6s | %-19s| %-10s|" % (departure.id, departure.type, departure.time.strftime("%H:%M"), departure.arrival_station, departure.late and departure.late.strftime("%H:%M") or '', - departure.information) + departure.information, + departure.plateform) count += 1 print "+-----'-----------'-------'-----------------------'-------'--------------------+" print "| %3d departures listed |" % count From 6df41d2219b842f65d4ddbd46e6ecbd9dce913b6 Mon Sep 17 00:00:00 2001 From: Juke Date: Tue, 13 Apr 2010 19:19:46 +0200 Subject: [PATCH 3/4] add copyright information --- weboob/capabilities/travel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weboob/capabilities/travel.py b/weboob/capabilities/travel.py index 138efc78..072375f4 100644 --- a/weboob/capabilities/travel.py +++ b/weboob/capabilities/travel.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -Copyright(C) 2010 Romain Bignon +Copyright(C) 2010 Romain Bignon, Julien Hebert This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 8ac4dd104f822241b3de6c70762747a5ee0f8c04 Mon Sep 17 00:00:00 2001 From: Juke Date: Tue, 13 Apr 2010 19:20:55 +0200 Subject: [PATCH 4/4] ADD copyright information --- weboob/frontends/travel/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weboob/frontends/travel/application.py b/weboob/frontends/travel/application.py index adddf8a5..f28a7f63 100644 --- a/weboob/frontends/travel/application.py +++ b/weboob/frontends/travel/application.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -Copyright(C) 2010 Romain Bignon +Copyright(C) 2010 Romain Bignon, Julien Hébert This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by