From c4b64727a42d4208bc6a06fecd34d92e8f719840 Mon Sep 17 00:00:00 2001 From: Dorian Roly Date: Thu, 5 Sep 2019 11:22:04 +0200 Subject: [PATCH] [axa] Formatted pages/bank.py for from future import unicode_litterals to work --- modules/axabanque/pages/bank.py | 54 +++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/modules/axabanque/pages/bank.py b/modules/axabanque/pages/bank.py index 0784c304fa..5de5df62d8 100644 --- a/modules/axabanque/pages/bank.py +++ b/modules/axabanque/pages/bank.py @@ -17,6 +17,8 @@ # You should have received a copy of the GNU Lesser General Public License # along with this weboob module. If not, see . +from __future__ import unicode_literals + from collections import OrderedDict import re from decimal import Decimal, InvalidOperation @@ -120,7 +122,7 @@ def get_list(self): for table in self.has_accounts(): tds = table.xpath('./tbody/tr')[0].findall('td') if len(tds) < 3: - if tds[0].text_content() == u'Pr\xeat Personnel': + if tds[0].text_content() == 'Prêt Personnel': account = Account() args = self.js2args(table.xpath('.//a')[0].attrib['onclick']) @@ -152,7 +154,7 @@ def get_list(self): if len(box.xpath('.//a')) != 0 and 'onclick' in box.xpath('.//a')[0].attrib: args = self.js2args(box.xpath('.//a')[0].attrib['onclick']) - account.label = u'{0} {1}'.format(unicode(table.xpath('./caption')[0].text.strip()), unicode(box.xpath('.//a')[0].text.strip())) + account.label = '%s %s' % (table.xpath('./caption')[0].text.strip(), box.xpath('.//a')[0].text.strip()) elif len(foot[0].xpath('.//a')) != 0 and 'onclick' in foot[0].xpath('.//a')[0].attrib: args = self.js2args(foot[0].xpath('.//a')[0].attrib['onclick']) account.label = table.xpath('./caption')[0].text.strip() @@ -207,8 +209,8 @@ def get_list(self): account.number = Regexp(CleanText('./td[contains(@class,"libelle")]', replace=[(' ', ''), ('x', 'X')]), r'(X{12}\d{4})')(box) account.id += Regexp(CleanText('./td[contains(@class,"libelle")]'), r'(\d+)')(box) - if u'Valorisation' in account.label or u'Liquidités' in account.label: - account.id += args[next(k for k in args.keys() if "_idcl" in k)].split('Jsp')[-1] + if 'Valorisation' in account.label or 'Liquidités' in account.label: + account.id += args[next(k for k in args.keys() if '_idcl' in k)].split('Jsp')[-1] # get accounts balance try: @@ -216,7 +218,7 @@ def get_list(self): # skip debit card # some cards don't have information in balance tab, skip them - if balance_value == u'Débit immédiat' or balance_value == '': + if balance_value == 'Débit immédiat' or balance_value == '': account._is_debit_card = True else: account._is_debit_card = False @@ -254,7 +256,7 @@ def get_profile_name(self): class IbanPage(PDFPage): def get_iban(self): - iban = u'' + iban = '' # according to re module doc, list returned by re.findall always # be in the same order as they are in the source text @@ -333,12 +335,12 @@ class iter_investment(TableElement): item_xpath = '//table[contains(@id, "titres") or contains(@id, "OPCVM")]/tbody/tr' head_xpath = '//table[contains(@id, "titres") or contains(@id, "OPCVM")]/thead/tr/th[not(caption)]' - col_label = u'Intitulé' - col_quantity = u'NB' - col_unitprice = re.compile(u'Prix de revient') - col_unitvalue = u'Dernier cours' - col_diff = re.compile(u'\+/\- Values latentes') - col_valuation = re.compile(u'Montant') + col_label = 'Intitulé' + col_quantity = 'NB' + col_unitprice = re.compile('Prix de revient') + col_unitvalue = 'Dernier cours' + col_diff = re.compile('\+/- Values latentes') + col_valuation = re.compile('Montant') class item(ItemElement): klass = Investment @@ -435,10 +437,10 @@ def get_history(self): continue t = BankTransaction() - date = u''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()]) - raw = u''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()]) - debit = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_DEBIT].itertext()])) - credit = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_CREDIT].itertext()])) + date = ''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()]) + raw = ''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()]) + debit = self.parse_number(''.join([txt.strip() for txt in tds[self.COL_DEBIT].itertext()])) + credit = self.parse_number(''.join([txt.strip() for txt in tds[self.COL_CREDIT].itertext()])) t.parse(date, re.sub(r'[ ]+', ' ', raw), vdate=date) t.set_amount(credit, debit) @@ -460,9 +462,9 @@ def get_summary(self): continue t = BankTransaction() - date = u''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()]) - raw = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()])) - credit = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_CB_CREDIT].itertext()])) + date = ''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()]) + raw = self.parse_number(''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()])) + credit = self.parse_number(''.join([txt.strip() for txt in tds[self.COL_CB_CREDIT].itertext()])) debit = "" t.parse(date, re.sub(r'[ ]+', ' ', raw)) @@ -529,8 +531,8 @@ class iter_history(TableElement): head_xpath = '//table[@id="ctl00_ContentPlaceHolderMain_PaymentListing_gvInfos"]/tr[@class="Header"]/th' col_date = 'Date' - col_label = re.compile(u'^Nature') - col_amount = re.compile(u'^Montant net de frais') + col_label = re.compile('^Nature') + col_amount = re.compile('^Montant net de frais') class item(ItemElement): klass = BankTransaction @@ -550,11 +552,11 @@ class iter_transaction_investments(TableElement): item_xpath = '//table[@id="ctl00_ContentPlaceHolderPopin_UcDetailMouvement_UcInvestissement_gvInfos"]/tr[not(contains(@class, "Header"))]' head_xpath = '//table[@id="ctl00_ContentPlaceHolderPopin_UcDetailMouvement_UcInvestissement_gvInfos"]/tr[@class="Header"]/th' - col_label = u'Support' - col_vdate = u'Date de valeur' - col_unitprice = u"Valeur de l'UC" - col_quantity = u"Nombre d'UC" - col_valuation = u'Montant' + col_label = 'Support' + col_vdate = 'Date de valeur' + col_unitprice = "Valeur de l'UC" + col_quantity = "Nombre d'UC" + col_valuation = 'Montant' class item(ItemElement): klass = Investment -- GitLab