[weboob] [PATCH 2/3] LCL: implement account listing

Pierre Mazière pierre.maziere at gmail.com
Sun Mar 6 23:47:53 CET 2011


Signed-off-by: Pierre Mazière <pierre.maziere at gmail.com>
---
 weboob/backends/lcl/backend.py |    5 ++---
 weboob/backends/lcl/pages.py   |   18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/weboob/backends/lcl/backend.py b/weboob/backends/lcl/backend.py
index f3ece68..be339a0 100644
--- a/weboob/backends/lcl/backend.py
+++ b/weboob/backends/lcl/backend.py
@@ -46,9 +46,8 @@ class LCLBackend(BaseBackend, ICapBank):
             yield account
 
     def get_account(self, _id):
-        if not _id.isdigit():
-            raise AccountNotFound()
-        account = self.browser.get_account(_id)
+        with self.browser:
+            account = self.browser.get_account(_id)
         if account:
             return account
         else:
diff --git a/weboob/backends/lcl/pages.py b/weboob/backends/lcl/pages.py
index f644643..de3f9a5 100644
--- a/weboob/backends/lcl/pages.py
+++ b/weboob/backends/lcl/pages.py
@@ -16,6 +16,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
+from weboob.capabilities.bank import Account
 from weboob.tools.browser import BasePage
 
 class LoginPage(BasePage):
@@ -35,4 +36,19 @@ class FramePage(BasePage):
 
 class AccountsPage(BasePage):
     def get_list(self):
-        raise NotImplementedError()
+      l = []
+      for div in self.document.getiterator('div'):
+        if div.attrib.get('class')=="unCompte-CC" :
+          account = Account()
+          account.id = div.attrib.get('id').replace('-','')
+          for td in div.getiterator('td'):
+            if td.find("div") is not None and td.find("div").attrib.get('class') == 'libelleCompte':
+              account.label = td.find("div").text
+            elif td.find('a') is not None and td.find('a').attrib.get('class') is None:
+              balance = td.find('a').text.replace(u"\u00A0",'').replace('.','').replace('+','').replace(',','.')
+              account.balance = float(balance)
+              account.link_id = td.find('a').attrib.get('href')
+
+          l.append(account)
+
+      return l
-- 
1.7.2.3




More information about the weboob mailing list