diff --git a/modules/alloresto/__init__.py b/modules/alloresto/__init__.py
new file mode 100644
index 00000000..93d8a07f
--- /dev/null
+++ b/modules/alloresto/__init__.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Romain Bignon
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+from .backend import AlloRestoBackend
+
+__all__ = ['AlloRestoBackend']
diff --git a/modules/alloresto/backend.py b/modules/alloresto/backend.py
new file mode 100644
index 00000000..00c7be85
--- /dev/null
+++ b/modules/alloresto/backend.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Romain Bignon
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+
+from weboob.capabilities.bank import ICapBank, AccountNotFound
+from weboob.tools.backend import BaseBackend, BackendConfig
+from weboob.tools.value import ValueBackendPassword
+
+from .browser import AlloRestoBrowser
+
+
+__all__ = ['AlloRestoBackend']
+
+
+class AlloRestoBackend(BaseBackend, ICapBank):
+ NAME = 'alloresto'
+ MAINTAINER = u'Romain Bignon'
+ EMAIL = 'romain@weboob.org'
+ VERSION = '0.i'
+ DESCRIPTION = u'Allo Resto'
+ LICENSE = 'AGPLv3+'
+ CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False),
+ ValueBackendPassword('password', label='Mot de passe'))
+ BROWSER = AlloRestoBrowser
+
+ def create_default_browser(self):
+ return self.create_browser(self.config['login'].get(),
+ self.config['password'].get())
+
+ def iter_accounts(self):
+ with self.browser:
+ for account in self.browser.get_accounts_list():
+ yield account
+
+ def get_account(self, _id):
+ with self.browser:
+ account = self.browser.get_account(_id)
+
+ if account:
+ return account
+ else:
+ raise AccountNotFound()
+
+ def iter_history(self, account):
+ with self.browser:
+ return self.browser.get_history(account)
+
+ def iter_coming(self, account):
+ with self.browser:
+ return self.browser.get_coming(account)
+
diff --git a/modules/alloresto/browser.py b/modules/alloresto/browser.py
new file mode 100644
index 00000000..3b610a8e
--- /dev/null
+++ b/modules/alloresto/browser.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Romain Bignon
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
+
+from .pages import LoginPage, AccountsPage
+
+
+__all__ = ['AlloRestoBrowser']
+
+
+class AlloRestoBrowser(BaseBrowser):
+ DOMAIN = 'www.alloresto.fr'
+ PROTOCOL = 'http'
+ ENCODING = 'utf-8'
+ PAGES = {'http://www.alloresto.fr/identification-requise.*': LoginPage,
+ 'http://www.alloresto.fr/chez-moi/releve-compte-miams': AccountsPage,
+ }
+
+ def is_logged(self):
+ return self.page is not None and not self.is_on_page(LoginPage)
+
+ def home(self):
+ self.go_on_accounts_list()
+
+ def login(self):
+ assert isinstance(self.username, basestring)
+ assert isinstance(self.password, basestring)
+
+ if not self.is_on_page(LoginPage):
+ self.location('http://www.alloresto.fr/identification-requise', no_login=True)
+
+ self.page.login(self.username, self.password)
+
+ if not self.is_logged():
+ raise BrowserIncorrectPassword()
+
+ def go_on_accounts_list(self):
+ self.location('http://www.alloresto.fr/chez-moi/releve-compte-miams')
+
+ def get_accounts_list(self):
+ if not self.is_on_page(AccountsPage):
+ self.go_on_accounts_list()
+ return self.page.get_list()
+
+ def get_account(self, id):
+ assert isinstance(id, basestring)
+
+ l = self.get_accounts_list()
+ for a in l:
+ if a.id == id:
+ return a
+
+ return None
+
+ def get_history(self, account):
+ if not self.is_on_page(AccountsPage):
+ self.go_on_accounts_list()
+
+ return self.page.get_transactions()
+
+ def get_coming(self, account):
+ if not self.is_on_page(AccountsPage):
+ self.go_on_accounts_list()
+
+ return self.page.get_transactions('acquisition')
diff --git a/modules/alloresto/favicon.png b/modules/alloresto/favicon.png
new file mode 100644
index 00000000..b1b365c6
Binary files /dev/null and b/modules/alloresto/favicon.png differ
diff --git a/modules/alloresto/pages.py b/modules/alloresto/pages.py
new file mode 100644
index 00000000..b3015222
--- /dev/null
+++ b/modules/alloresto/pages.py
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Romain Bignon
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+import datetime
+from decimal import Decimal
+
+from weboob.tools.browser import BasePage, BrokenPageError
+from weboob.capabilities.bank import Account
+from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction
+
+
+__all__ = ['LoginPage', 'AccountsPage']
+
+
+class LoginPage(BasePage):
+ def login(self, username, password):
+ self.browser.select_form(nr=0)
+ self.browser['uname'] = username.encode(self.browser.ENCODING)
+ self.browser['pass'] = password.encode(self.browser.ENCODING)
+ self.browser.submit(nologin=True)
+
+
+class AccountsPage(BasePage):
+ def get_list(self):
+ a = Account()
+ a.id = '0'
+ a.label = u'Compte miams'
+ a.balance = Decimal(self.parser.tocleanstring(self.document.xpath('//div[@class="compteur"]//strong')[0]))
+ a.currency = u'MIAM'
+ try:
+ a.coming = Decimal(Transaction.clean_amount(self.document.xpath('//table[@id="solde_acquisition_lignes"]//th[@class="col_montant"]')[0].text))
+ except BrokenPageError:
+ a.coming = Decimal('0')
+ yield a
+
+ COL_DATE = 0
+ COL_LABEL = 1
+ COL_AMOUNT = 2
+
+ MONTHS = ['janv', u'févr', u'mars', u'avr', u'mai', u'juin', u'juil', u'août', u'sept', u'oct', u'nov', u'déc']
+ def get_transactions(self, _type='consommable'):
+ for tr in self.document.xpath('//table[@id="solde_%s_lignes"]/tbody/tr' % _type):
+ cols = tr.findall('td')
+
+ t = Transaction(0)
+
+ day, month, year = self.parser.tocleanstring(cols[self.COL_DATE]).split(' ')
+ day = int(day)
+ year = int(year)
+ month = self.MONTHS.index(month.rstrip('.')) + 1
+ date = datetime.date(year, month, day)
+
+ label = self.parser.tocleanstring(cols[self.COL_LABEL])
+ t.parse(date, label)
+ t.set_amount(self.parser.tocleanstring(cols[self.COL_AMOUNT]))
+
+ yield t
diff --git a/modules/alloresto/test.py b/modules/alloresto/test.py
new file mode 100644
index 00000000..4fc0f837
--- /dev/null
+++ b/modules/alloresto/test.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Romain Bignon
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+from weboob.tools.test import BackendTest
+
+
+class AlloRestoTest(BackendTest):
+ BACKEND = 'alloresto'
+
+ def test_alloresto(self):
+ l = list(self.backend.iter_accounts())
+
+ a = l[0]
+ list(self.backend.iter_history(a))
+ list(self.backend.iter_coming(a))