The account listing is now more robust

Hello,

actually I didn't write this patch. The new contributor is
David Jeanneteau.

Regards,

Florent.

Signed-off-by: Florent <weboob@flo.fourcot.fr>
Signed-off-by: Romain Bignon <romain@peerfuse.org>
This commit is contained in:
Florent 2012-02-13 10:34:15 +01:00 committed by Romain Bignon
commit 3fb8706d61

View file

@ -34,16 +34,20 @@ class AccountsList(BasePage):
def get_list(self): def get_list(self):
l = [] l = []
ids = []
for td in self.document.xpath('.//td[@nowrap="nowrap"]'): for td in self.document.xpath('.//td[@nowrap="nowrap"]'):
account = Account() account = Account()
link = td.xpath('.//a')[0] link = td.xpath('.//a')[0]
account.id = re.search('\d', link.attrib['href']).group(0) account.id = re.search('\d', link.attrib['href']).group(0)
if not ( account.id in ids ) :
ids.append( account.id )
account.label = link.text account.label = link.text
urltofind = './/a[@href="' + link.attrib['href'] + '"]' urltofind = './/a[@href="' + link.attrib['href'] + '"]'
linkbis = self.document.xpath(urltofind).pop() linkbis = self.document.xpath(urltofind).pop()
account.balance = float(linkbis.text.replace('.', '').replace(',','.')) if linkbis.text == link.text :
linkbis=self.document.xpath(urltofind)[1]
account.balance = float( linkbis.text.replace('.','').replace(' ', '').replace(',','.') )
account.coming = NotAvailable account.coming = NotAvailable
l.append(account) l.append(account)
return l return l