From 46bd54b41c72f8d13753cce6ed1aa4925dc60c44 Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 23 Oct 2014 15:32:26 +0200 Subject: [PATCH] Remove hack to convert decimal to int And better compliance with objects parameters --- modules/ing/pages/titre.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/ing/pages/titre.py b/modules/ing/pages/titre.py index c91baebc..c725cf2c 100644 --- a/modules/ing/pages/titre.py +++ b/modules/ing/pages/titre.py @@ -20,6 +20,7 @@ from decimal import Decimal +from weboob.capabilities.base import NotAvailable from weboob.capabilities.bank import Investment from weboob.browser.pages import RawPage, HTMLPage, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method @@ -35,19 +36,19 @@ class TitrePage(LoggedPage, RawPage): def iter_investments(self): # We did not get some html, but something like that (XX is a quantity, YY a price): # message='[...] - #popup=2{6{E:ALO{PAR{{reel{695{380{ALSTOM REGROUPT#XX#YY,YY €#YY,YY €#1 YYY,YY €#-YYY,YY €#-42,42%#-0,98 %#42,42 %#|1|AXA#cotationValeur.php?val=E:CS&pl=6&nc=1& - #popup=2{6{E:CS{PAR{{reel{695{380{AXA#XX#YY,YY €#YY,YYY €#YYY,YY €#YY,YY €#3,70%#42,42 %#42,42 %#|1|blablablab #cotationValeur.php?val=P:CODE&pl=6&nc=1& + # popup=2{6{E:ALO{PAR{{reel{695{380{ALSTOM REGROUPT#XX#YY,YY €#YY,YY €#1 YYY,YY €#-YYY,YY €#-42,42%#-0,98 %#42,42 %#|1|AXA#cotationValeur.php?val=E:CS&pl=6&nc=1& + # popup=2{6{E:CS{PAR{{reel{695{380{AXA#XX#YY,YY €#YY,YYY €#YYY,YY €#YY,YY €#3,70%#42,42 %#42,42 %#|1|blablablab #cotationValeur.php?val=P:CODE&pl=6&nc=1& # [...] lines = self.doc.split("popup=2") lines.pop(0) for line in lines: columns = line.split('#') - code = columns[0].split('{')[2] - invest = Investment(code) - invest.code = unicode(code) + _id = columns[0].split('{')[2] + invest = Investment(_id) invest.label = unicode(columns[0].split('{')[-1]) - # XXX sometimes there are decimal (!) quantities - invest.quantity = int(columns[1].split(',')[0].replace(' ', '')) + invest.code = NotAvailable + invest.description = unicode(_id.split(':')[1]) + invest.quantity = Decimal(FrenchTransaction.clean_amount(columns[1])) invest.unitprice = Decimal(FrenchTransaction.clean_amount(columns[2])) invest.unitvalue = Decimal(FrenchTransaction.clean_amount(columns[3])) invest.valuation = Decimal(FrenchTransaction.clean_amount(columns[4]))