Set replace_dots everywhere

The goal is to change the default value in CleanDecimal
This commit is contained in:
Florent 2014-08-21 10:21:53 +02:00
commit a434f33a61
10 changed files with 16 additions and 17 deletions

View file

@ -49,9 +49,9 @@ class AccountsPage(LoggedPage, HTMLPage):
obj_id = '0' obj_id = '0'
obj_label = u'Compte miams' obj_label = u'Compte miams'
obj_balance = CleanDecimal('//div[@class="compteur"]//strong') obj_balance = CleanDecimal('//div[@class="compteur"]//strong', replace_dots=True)
obj_currency = u'MIAM' obj_currency = u'MIAM'
obj_coming = CleanDecimal('//table[@id="solde_acquisition_lignes"]//th[@class="col_montant"]', default=Decimal('0')) obj_coming = CleanDecimal('//table[@id="solde_acquisition_lignes"]//th[@class="col_montant"]', default=Decimal('0'), replace_dots=True)
class MyDate(Filter): class MyDate(Filter):
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'] 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']

View file

@ -53,7 +53,7 @@ class HomePage(LoggedPage, HTMLPage):
obj_id = Regexp(CleanText('./div[@class="carte_col_leftcol"]/p'), r'(\d+)') obj_id = Regexp(CleanText('./div[@class="carte_col_leftcol"]/p'), r'(\d+)')
obj_label = CleanText('./div[@class="carte_col_leftcol"]/h2') obj_label = CleanText('./div[@class="carte_col_leftcol"]/h2')
obj_balance = CleanDecimal(Format('-%s', CleanText('.//div[@class="catre_col_one"]/h2'))) obj_balance = CleanDecimal(Format('-%s', CleanText('.//div[@class="catre_col_one"]/h2')), replace_dots=True)
obj_currency = FrenchTransaction.Currency('.//div[@class="catre_col_one"]/h2') obj_currency = FrenchTransaction.Currency('.//div[@class="catre_col_one"]/h2')
obj__link = Link('.//a[contains(@href, "solde-dernieres-operations")]') obj__link = Link('.//a[contains(@href, "solde-dernieres-operations")]')

View file

@ -123,7 +123,7 @@ class AccountsPage(LoggedPage, HTMLPage):
if not 'rib' in p: if not 'rib' in p:
raise SkipItem() raise SkipItem()
balance = CleanDecimal('./td[2] | ./td[3]')(self) balance = CleanDecimal('./td[2] | ./td[3]', replace_dots=True)(self)
id = p['rib'][0] id = p['rib'][0]
# Handle cards # Handle cards

View file

@ -84,7 +84,7 @@ class DetailsPage(LoggedPage, BadUTF8Page):
detail.label = detail.label + u" (international)" detail.label = detail.label + u" (international)"
detail.id = detail.id + "-inter" detail.id = detail.id + "-inter"
detail.infos = CleanText('div[@class="conso"]/p')(div) detail.infos = CleanText('div[@class="conso"]/p')(div)
detail.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0))(div) detail.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div)
self.details[num].append(detail) self.details[num].append(detail)
@ -96,7 +96,7 @@ class DetailsPage(LoggedPage, BadUTF8Page):
if inter: if inter:
voice.label = voice.label + " (international)" voice.label = voice.label + " (international)"
voice.id = voice.id + "-inter" voice.id = voice.id + "-inter"
voice.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=0)(div) voice.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div)
voice1 = CleanText('.//span[@class="actif"][1]')(voicediv) voice1 = CleanText('.//span[@class="actif"][1]')(voicediv)
voice2 = CleanText('.//span[@class="actif"][2]')(voicediv) voice2 = CleanText('.//span[@class="actif"][2]')(voicediv)
voice.infos = unicode(string) % (voice1, voice2) voice.infos = unicode(string) % (voice1, voice2)
@ -155,4 +155,4 @@ class HistoryPage(LoggedPage, BadUTF8Page):
obj_datetime = DateTime(CleanText('td[1]', symbols=u'à'), dayfirst=True) obj_datetime = DateTime(CleanText('td[1]', symbols=u'à'), dayfirst=True)
obj_label = Format(u'%s %s %s', CleanText('td[2]'), CleanText('td[3]'), obj_label = Format(u'%s %s %s', CleanText('td[2]'), CleanText('td[3]'),
CleanText('td[4]')) CleanText('td[4]'))
obj_price = CleanDecimal('td[5]', default=Decimal(0)) obj_price = CleanDecimal('td[5]', default=Decimal(0), replace_dots=True)

View file

@ -53,8 +53,7 @@ class AvoirPage(LoggedPage, HTMLPage):
obj_id = CleanText(TableCell('name')) obj_id = CleanText(TableCell('name'))
obj_label = CleanText(TableCell('name')) obj_label = CleanText(TableCell('name'))
#obj_coming = CleanDecimal(TableCell('value')) obj_balance = CleanDecimal(TableCell('value'), replace_dots=True)
obj_balance = CleanDecimal(TableCell('value'))
obj_currency = CleanText(u'//table[@summary="Liste des échéances"]/thead/tr/th/small/text()') obj_currency = CleanText(u'//table[@summary="Liste des échéances"]/thead/tr/th/small/text()')
obj_type = Account.TYPE_UNKNOWN obj_type = Account.TYPE_UNKNOWN
@ -80,7 +79,7 @@ class OperationsFuturesPage(LoggedPage, HTMLPage):
obj_date = Date(CleanText(TableCell('date')), LinearDateGuesser()) obj_date = Date(CleanText(TableCell('date')), LinearDateGuesser())
obj_type = Transaction.TYPE_UNKNOWN obj_type = Transaction.TYPE_UNKNOWN
obj_label = CleanText(TableCell('operation')) obj_label = CleanText(TableCell('operation'))
obj_amount = CleanDecimal(TableCell('montant')) obj_amount = CleanDecimal(TableCell('montant'), replace_dots=True)
class OperationsTraiteesPage(LoggedPage, HTMLPage): class OperationsTraiteesPage(LoggedPage, HTMLPage):
@ -102,4 +101,4 @@ class OperationsTraiteesPage(LoggedPage, HTMLPage):
obj_date = Date(CleanText(TableCell('date')), LinearDateGuesser()) obj_date = Date(CleanText(TableCell('date')), LinearDateGuesser())
obj_type = Transaction.TYPE_UNKNOWN obj_type = Transaction.TYPE_UNKNOWN
obj_label = CleanText(TableCell('operation')) obj_label = CleanText(TableCell('operation'))
obj_amount = CleanDecimal(TableCell('montant')) obj_amount = CleanDecimal(TableCell('montant'), replace_dots=True)

View file

@ -92,7 +92,7 @@ class AccountsPage(LoggedPage, HTMLPage):
else: else:
raise SkipItem() raise SkipItem()
balance = CleanDecimal('./td[3]')(self) balance = CleanDecimal('./td[3]', replace_dots=True)(self)
self.env['id'] = id self.env['id'] = id
self.env['balance'] = balance self.env['balance'] = balance

View file

@ -127,7 +127,7 @@ class AccountsList(LoggedPage, HTMLPage):
obj_label = CleanText('span[@class="title"]') obj_label = CleanText('span[@class="title"]')
obj_id = AddPref(Field('_id'), Field('label')) obj_id = AddPref(Field('_id'), Field('label'))
obj_type = AddType(Field('label')) obj_type = AddType(Field('label'))
obj_balance = CleanDecimal('span[@class="solde"]/label') obj_balance = CleanDecimal('span[@class="solde"]/label', replace_dots=True)
obj_coming = NotAvailable obj_coming = NotAvailable
obj__jid = Attr('//input[@name="javax.faces.ViewState"]', 'value') obj__jid = Attr('//input[@name="javax.faces.ViewState"]', 'value')
@ -141,7 +141,7 @@ class AccountsList(LoggedPage, HTMLPage):
obj_id = None # will be overwrited by the browser obj_id = None # will be overwrited by the browser
# we use lower for compatibility with the old website # we use lower for compatibility with the old website
obj_raw = Transaction.Raw(Lower('.//td[@class="lbl"]')) obj_raw = Transaction.Raw(Lower('.//td[@class="lbl"]'))
obj_amount = CleanDecimal('.//td[starts-with(@class, "amount")]') obj_amount = CleanDecimal('.//td[starts-with(@class, "amount")]', replace_dots=True)
obj_date = INGDate(CleanText('.//td[@class="date"]'), dayfirst=True) obj_date = INGDate(CleanText('.//td[@class="date"]'), dayfirst=True)
obj_rdate = Field('date') obj_rdate = Field('date')
obj__hash = PreHashmd5(Field('date'), Field('raw'), Field('amount')) obj__hash = PreHashmd5(Field('date'), Field('raw'), Field('amount'))

View file

@ -70,4 +70,4 @@ class TitreHistory(HTMLPage):
obj_raw = Transaction.Raw('td[4] | td[3]/a') obj_raw = Transaction.Raw('td[4] | td[3]/a')
obj_date = Date(CleanText('td[2]'), dayfirst=True) obj_date = Date(CleanText('td[2]'), dayfirst=True)
obj_amount = CleanDecimal('td[7]') obj_amount = CleanDecimal('td[7]', replace_dots=True)

View file

@ -144,7 +144,7 @@ class TransferConfirmPage(HTMLPage):
class item(ItemElement): class item(ItemElement):
klass = Transfer klass = Transfer
obj_amount = CleanDecimal('.//label[@id="confirmtransferAmount"]') obj_amount = CleanDecimal('.//label[@id="confirmtransferAmount"]', replace_dots=True)
obj_origin = CleanText('.//span[@id="confirmfromAccount"]') obj_origin = CleanText('.//span[@id="confirmfromAccount"]')
obj_recipient = CleanText('.//span[@id="confirmtoAccount"]') obj_recipient = CleanText('.//span[@id="confirmtoAccount"]')
obj_reason = CleanText('.//span[@id="confirmtransferMotive"]') obj_reason = CleanText('.//span[@id="confirmtransferMotive"]')

View file

@ -116,7 +116,7 @@ class IndexPage(LoggedPage, HTMLPage):
is_here = "//div[@id='situation']" is_here = "//div[@id='situation']"
def get_balance(self): def get_balance(self):
return -CleanDecimal('.')(self.doc.xpath('//div[@id = "total-sommes-dues"]/p[contains(text(), "sommes dues")]/span[@class = "montant"]')[0]) return -CleanDecimal('.', replace_dots=True)(self.doc.xpath('//div[@id = "total-sommes-dues"]/p[contains(text(), "sommes dues")]/span[@class = "montant"]')[0])
class OperationsPage(LoggedPage, HTMLPage): class OperationsPage(LoggedPage, HTMLPage):
is_here = "//div[@id='releve-reserve-credit'] | //div[@id='operations-recentes']" is_here = "//div[@id='releve-reserve-credit'] | //div[@id='operations-recentes']"