Merge branch 'master' of /var/git/pub/romain/weboob
This commit is contained in:
commit
b67050cab8
10 changed files with 164 additions and 73 deletions
|
|
@ -20,64 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import sys
|
||||
|
||||
import weboob
|
||||
from weboob.capabilities.bank import ICapBank, AccountNotFound
|
||||
from weboob.tools.application import ConsoleApplication
|
||||
|
||||
class Boobank(ConsoleApplication):
|
||||
APPNAME = 'boobank'
|
||||
|
||||
def main(self, argv):
|
||||
self.weboob.load_backends(ICapBank)
|
||||
|
||||
return self.process_command(*argv[1:])
|
||||
|
||||
@ConsoleApplication.command('List every available accounts')
|
||||
def command_list(self):
|
||||
accounts = []
|
||||
for name, backend, in self.weboob.iter_backends():
|
||||
try:
|
||||
for account in backend.iter_accounts():
|
||||
accounts.append('%17s %-20s %11.2f %11.2f' % (
|
||||
account.id, account.label, account.balance, account.coming))
|
||||
except weboob.tools.browser.BrowserIncorrectPassword:
|
||||
print >>sys.stderr, 'Error: Incorrect password for backend %s' % name
|
||||
return 1
|
||||
if len(accounts):
|
||||
print ' ID Account Balance Coming '
|
||||
print '+-----------------+---------------------+--------------+-------------+'
|
||||
print '\n'.join(accounts)
|
||||
else:
|
||||
print 'No accounts found'
|
||||
|
||||
@ConsoleApplication.command('Display all future operations')
|
||||
def command_coming(self, id):
|
||||
operations = []
|
||||
found = 0
|
||||
for name, backend in self.weboob.iter_backends():
|
||||
try:
|
||||
account = backend.get_account(id)
|
||||
except AccountNotFound:
|
||||
if found == 0:
|
||||
found = -1
|
||||
else:
|
||||
found = 1
|
||||
for operation in backend.iter_operations(account):
|
||||
operations.append(' %8s %-50s %11.2f' % (operation.date, operation.label, operation.amount))
|
||||
if found < 0:
|
||||
print >>sys.stderr, "Error: account %s not found" % id
|
||||
return 1
|
||||
else:
|
||||
if operations:
|
||||
print ' Date Label Amount '
|
||||
print '+----------+----------------------------------------------------+-------------+'
|
||||
print '\n'.join(operations)
|
||||
else:
|
||||
print 'No coming operations for ID=%s' % id
|
||||
from weboob.frontends.boobank import Boobank
|
||||
|
||||
if __name__ == '__main__':
|
||||
Boobank.run()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
"""
|
||||
|
||||
from weboob.frontends.boobank.monfric import MonFric
|
||||
from weboob.frontends.boobank import MonFric
|
||||
|
||||
if __name__ == '__main__':
|
||||
MonFric.run()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2010 Christophe Benz
|
||||
|
||||
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
|
||||
the Free Software Foundation, version 3 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
"""
|
||||
|
||||
from .boobank import Boobank
|
||||
from .monfric import MonFric
|
||||
83
weboob/frontends/boobank/boobank.py
Normal file
83
weboob/frontends/boobank/boobank.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
||||
|
||||
"""
|
||||
Copyright(C) 2009-2010 Romain Bignon
|
||||
|
||||
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
|
||||
the Free Software Foundation, version 3 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import sys
|
||||
|
||||
import weboob
|
||||
from weboob.capabilities.bank import ICapBank, AccountNotFound
|
||||
from weboob.tools.application import ConsoleApplication
|
||||
|
||||
class Boobank(ConsoleApplication):
|
||||
APPNAME = 'boobank'
|
||||
|
||||
def main(self, argv):
|
||||
self.weboob.load_backends(ICapBank)
|
||||
|
||||
return self.process_command(*argv[1:])
|
||||
|
||||
@ConsoleApplication.command('List every available accounts')
|
||||
def command_list(self):
|
||||
accounts = []
|
||||
for name, backend, in self.weboob.iter_backends():
|
||||
try:
|
||||
for account in backend.iter_accounts():
|
||||
accounts.append('%17s %-20s %11.2f %11.2f' % (
|
||||
account.id, account.label, account.balance, account.coming))
|
||||
except weboob.tools.browser.BrowserIncorrectPassword:
|
||||
print >>sys.stderr, 'Error: Incorrect password for backend %s' % name
|
||||
return 1
|
||||
if len(accounts):
|
||||
print ' ID Account Balance Coming '
|
||||
print '+-----------------+---------------------+--------------+-------------+'
|
||||
print '\n'.join(accounts)
|
||||
else:
|
||||
print 'No accounts found'
|
||||
|
||||
@ConsoleApplication.command('Display all future operations')
|
||||
def command_coming(self, id):
|
||||
operations = []
|
||||
found = 0
|
||||
for name, backend in self.weboob.iter_backends():
|
||||
try:
|
||||
account = backend.get_account(id)
|
||||
except AccountNotFound:
|
||||
if found == 0:
|
||||
found = -1
|
||||
else:
|
||||
found = 1
|
||||
for operation in backend.iter_operations(account):
|
||||
operations.append(' %8s %-50s %11.2f' % (operation.date, operation.label, operation.amount))
|
||||
if found < 0:
|
||||
print >>sys.stderr, "Error: account %s not found" % id
|
||||
return 1
|
||||
else:
|
||||
if operations:
|
||||
print ' Date Label Amount '
|
||||
print '+----------+----------------------------------------------------+-------------+'
|
||||
print '\n'.join(operations)
|
||||
else:
|
||||
print 'No coming operations for ID=%s' % id
|
||||
|
||||
if __name__ == '__main__':
|
||||
Boobank.run()
|
||||
21
weboob/frontends/dummy/__init__.py
Normal file
21
weboob/frontends/dummy/__init__.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2010 Christophe Benz
|
||||
|
||||
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
|
||||
the Free Software Foundation, version 3 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
"""
|
||||
|
||||
from .application import Dummy
|
||||
7
scripts/dummy → weboob/frontends/dummy/application.py
Executable file → Normal file
7
scripts/dummy → weboob/frontends/dummy/application.py
Executable file → Normal file
|
|
@ -3,7 +3,7 @@
|
|||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
||||
|
||||
"""
|
||||
Copyright(C) 2010 Romain Bignon
|
||||
Copyright(C) 2010 Romain Bignon, Christophe Benz
|
||||
|
||||
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
|
||||
|
|
@ -25,7 +25,7 @@ from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
|||
from weboob.capabilities.travel import ICapTravel
|
||||
from weboob.tools.application import BaseApplication
|
||||
|
||||
class Application(BaseApplication):
|
||||
class Dummy(BaseApplication):
|
||||
APPNAME = 'dummy'
|
||||
|
||||
def main(self, argv):
|
||||
|
|
@ -54,6 +54,3 @@ class Application(BaseApplication):
|
|||
for account in backend.iter_accounts():
|
||||
print '| |- [%s] label=%s balance=%s coming=%s' % (
|
||||
account.id, account.label, account.balance, account.coming)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Application.run()
|
||||
26
weboob/frontends/dummy/dummy
Executable file
26
weboob/frontends/dummy/dummy
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
||||
|
||||
"""
|
||||
Copyright(C) 2010 Christophe Benz
|
||||
|
||||
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
|
||||
the Free Software Foundation, version 3 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
"""
|
||||
|
||||
from weboob.frontends.dummy import Dummy
|
||||
|
||||
if __name__ == '__main__':
|
||||
Dummy.run()
|
||||
|
|
@ -53,6 +53,7 @@ class TransilienUI():
|
|||
self.treestore = gtk.TreeStore(str, str, str, str)
|
||||
self.treeview = gtk.TreeView(self.treestore)
|
||||
|
||||
|
||||
self.treeview.append_column(
|
||||
gtk.TreeViewColumn(
|
||||
'Train',
|
||||
|
|
@ -90,9 +91,7 @@ class TransilienUI():
|
|||
for station in backend.iter_station_search(""):
|
||||
liste.append(station)
|
||||
|
||||
liste.sort()
|
||||
for station in liste:
|
||||
print station
|
||||
self.combo_source.append_text(station.name.capitalize())
|
||||
self.combo_dest.append_text(station.name.capitalize())
|
||||
|
||||
|
|
@ -127,7 +126,6 @@ class TransilienUI():
|
|||
"exit application at the window close"
|
||||
gtk.main_quit()
|
||||
|
||||
|
||||
def on_retour_button_clicked(self, widget):
|
||||
"the button is clicked"
|
||||
col_source = self.combo_source.get_active(0)
|
||||
|
|
@ -142,13 +140,14 @@ class TransilienUI():
|
|||
|
||||
def refresh(self):
|
||||
"update departures"
|
||||
self.treestore.clear()
|
||||
for name, backend in self.weboob.iter_backends():
|
||||
for station in backend.iter_station_search(self.combo_source.get_current_text()):
|
||||
for name, backend in self.weboob.iter_backends():
|
||||
for arrival in backend.iter_station_search(self.combo_dest.get_current_text()):
|
||||
for name, backend, in self.weboob.iter_backends():
|
||||
for departure in backend.iter_station_departures(station.id, arrival.id):
|
||||
print departure.id, departure.type, departure.time, departure.arrival_station, departure.late, departure.information
|
||||
self.treestore.append(None, [departure.type, departure.time, departure.arrival_station, departure.information])
|
||||
|
||||
class Travel(BaseApplication):
|
||||
APPNAME = 'travel'
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ class Videoob(ConsoleApplication):
|
|||
return self.process_command(*argv[1:])
|
||||
|
||||
@ConsoleApplication.command('Get video file URL from page URL')
|
||||
def command_file_url(self, page_url):
|
||||
def command_file_url(self, url):
|
||||
for name, backend in self.weboob.iter_backends(ICapVideoProvider):
|
||||
print backend.get_video_url(page_url)
|
||||
print backend.get_video_url(url)
|
||||
|
||||
@ConsoleApplication.command('Get video title from page URL')
|
||||
def command_title(self, page_url):
|
||||
def command_title(self, url):
|
||||
for name, backend in self.weboob.iter_backends(ICapVideoProvider):
|
||||
print backend.get_video_title(page_url)
|
||||
print backend.get_video_title(url)
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class BaseApplication(object):
|
|||
level = logging.ERROR
|
||||
else:
|
||||
level = logging.WARNING
|
||||
log_format = '%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d %(message)s'
|
||||
log_format = '%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(funcName)s %(message)s'
|
||||
logging.basicConfig(stream=sys.stdout, level=level, format=log_format)
|
||||
try:
|
||||
sys.exit(app.main(args))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue