diff --git a/modules/bred/bred/browser.py b/modules/bred/bred/browser.py index e611202378a707ccb1b988e7c2d51bf75428b940..088e418b92e9f056b4acaa8c230ccb6c29bf1ec6 100644 --- a/modules/bred/bred/browser.py +++ b/modules/bred/bred/browser.py @@ -43,24 +43,24 @@ class BredBrowser(LoginBrowser): BASEURL = 'https://www.bred.fr' - home = URL('/$', HomePage) - login = URL('/transactionnel/Authentication', LoginPage) - error = URL('.*gestion-des-erreurs/erreur-pwd', - '.*gestion-des-erreurs/opposition', - '/pages-gestion-des-erreurs/erreur-technique', - '/pages-gestion-des-erreurs/message-tiers-oppose', ErrorPage) - universe = URL('/transactionnel/services/applications/menu/getMenuUnivers', UniversePage) - token = URL(r'/transactionnel/services/rest/User/nonce\?random=(?P.*)', TokenPage) - move_universe = URL('/transactionnel/services/applications/listes/(?P.*)/default', MoveUniversePage) - switch = URL('/transactionnel/services/rest/User/switch', SwitchPage) - loans = URL('/transactionnel/services/applications/prets/liste', LoansPage) - accounts = URL('/transactionnel/services/rest/Account/accounts', AccountsPage) - iban = URL('/transactionnel/services/rest/Account/account/(?P.*)/iban', IbanPage) - life_insurances = URL('/transactionnel/services/applications/avoirsPrepar/getAvoirs', LifeInsurancesPage) - search = URL('/transactionnel/services/applications/operations/getSearch/', SearchPage) - profile = URL('/transactionnel/services/rest/User/user', ProfilePage) - emails = URL('/transactionnel/services/applications/gestionEmail/getAdressesMails', EmailsPage) - error_code = URL('/.*\?errorCode=.*', ErrorCodePage) + home = URL(r'/$', HomePage) + login = URL(r'/transactionnel/Authentication', LoginPage) + error = URL(r'.*gestion-des-erreurs/erreur-pwd', + r'.*gestion-des-erreurs/opposition', + r'/pages-gestion-des-erreurs/erreur-technique', + r'/pages-gestion-des-erreurs/message-tiers-oppose', ErrorPage) + universe = URL(r'/transactionnel/services/applications/menu/getMenuUnivers', UniversePage) + token = URL(r'/transactionnel/services/rest/User/nonce\?random=(?P.*)', TokenPage) + move_universe = URL(r'/transactionnel/services/applications/listes/(?P.*)/default', MoveUniversePage) + switch = URL(r'/transactionnel/services/rest/User/switch', SwitchPage) + loans = URL(r'/transactionnel/services/applications/prets/liste', LoansPage) + accounts = URL(r'/transactionnel/services/rest/Account/accounts', AccountsPage) + iban = URL(r'/transactionnel/services/rest/Account/account/(?P.*)/iban', IbanPage) + life_insurances = URL(r'/transactionnel/services/applications/avoirsPrepar/getAvoirs', LifeInsurancesPage) + search = URL(r'/transactionnel/services/applications/operations/getSearch/', SearchPage) + profile = URL(r'/transactionnel/services/rest/User/user', ProfilePage) + emails = URL(r'/transactionnel/services/applications/gestionEmail/getAdressesMails', EmailsPage) + error_code = URL(r'/.*\?errorCode=.*', ErrorCodePage) def __init__(self, accnum, login, password, *args, **kwargs): kwargs['username'] = login diff --git a/modules/bred/bred/pages.py b/modules/bred/bred/pages.py index de474100ec10bb30861499271872258a397a431c..3ac794fd6156fa9138535869a6e5acbeee5a776e 100644 --- a/modules/bred/bred/pages.py +++ b/modules/bred/bred/pages.py @@ -38,21 +38,22 @@ class Transaction(FrenchTransaction): - PATTERNS = [(re.compile(r'^.*Virement (?P.*)'), FrenchTransaction.TYPE_TRANSFER), - (re.compile(r'PRELEV SEPA (?P.*)'), FrenchTransaction.TYPE_ORDER), - (re.compile(r'.*Prélèvement.*'), FrenchTransaction.TYPE_ORDER), - (re.compile(r'^(REGL|Rgt)(?P.*)'), FrenchTransaction.TYPE_ORDER), - (re.compile(r'^(?P.*) Carte \d+\s+ LE (?P
\d{2})/(?P\d{2})/(?P\d{2})'), - FrenchTransaction.TYPE_CARD), - (re.compile(r'^Débit mensuel.*'), FrenchTransaction.TYPE_CARD_SUMMARY), - (re.compile(r"^Retrait d'espèces à un DAB (?P.*) CARTE [X\d]+ LE (?P
\d{2})/(?P\d{2})/(?P\d{2})"), - FrenchTransaction.TYPE_WITHDRAWAL), - (re.compile(r'^Paiement de chèque (?P.*)'), FrenchTransaction.TYPE_CHECK), - (re.compile(r'^(Cotisation|Intérêts) (?P.*)'), FrenchTransaction.TYPE_BANK), - (re.compile(r'^(Remise Chèque|Remise de chèque)\s*(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), - (re.compile(r'^Versement (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), - (re.compile(r'^(?P.*)LE (?P
\d{2})/(?P\d{2})/(?P\d{2})\s*(?P.*)'), - FrenchTransaction.TYPE_UNKNOWN), + PATTERNS = [ + (re.compile(r'^.*Virement (?P.*)'), FrenchTransaction.TYPE_TRANSFER), + (re.compile(r'PRELEV SEPA (?P.*)'), FrenchTransaction.TYPE_ORDER), + (re.compile(r'.*Prélèvement.*'), FrenchTransaction.TYPE_ORDER), + (re.compile(r'^(REGL|Rgt)(?P.*)'), FrenchTransaction.TYPE_ORDER), + (re.compile(r'^(?P.*) Carte \d+\s+ LE (?P
\d{2})/(?P\d{2})/(?P\d{2})'), + FrenchTransaction.TYPE_CARD), + (re.compile(r'^Débit mensuel.*'), FrenchTransaction.TYPE_CARD_SUMMARY), + (re.compile(r"^Retrait d'espèces à un DAB (?P.*) CARTE [X\d]+ LE (?P
\d{2})/(?P\d{2})/(?P\d{2})"), + FrenchTransaction.TYPE_WITHDRAWAL), + (re.compile(r'^Paiement de chèque (?P.*)'), FrenchTransaction.TYPE_CHECK), + (re.compile(r'^(Cotisation|Intérêts) (?P.*)'), FrenchTransaction.TYPE_BANK), + (re.compile(r'^(Remise Chèque|Remise de chèque)\s*(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), + (re.compile(r'^Versement (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), + (re.compile(r'^(?P.*)LE (?P
\d{2})/(?P\d{2})/(?P\d{2})\s*(?P.*)'), + FrenchTransaction.TYPE_UNKNOWN), ] @@ -135,7 +136,7 @@ def iter_accounts(self, accnum, current_univers): accounts_list = [] - for content in self.get_content(): + for content in self.get_content(): if accnum != '00000000000' and content['numero'] != accnum: continue for poste in content['postes']: @@ -266,12 +267,12 @@ def iter_history(self, account, operation_list, seen, today, coming): raise ParseError('There are several transactions with the same ID, probably an infinite loop') seen.add(t.id) - d = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation'))/1000) + d = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation')) / 1000) op['details'] = [re.sub(r'\s+', ' ', i).replace('\x00', '') for i in op['details'] if i] # sometimes they put "null" elements... label = re.sub(r'\s+', ' ', op['libelle']).replace('\x00', '') raw = ' '.join([label] + op['details']) - t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit'))/1000) - vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation')))/1000) + t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit')) / 1000) + vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation'))) / 1000) t.parse(d, raw, vdate=vdate) t.amount = Decimal(str(op['montant'])) if 'categorie' in op: diff --git a/modules/bred/module.py b/modules/bred/module.py index 5c1a6db726149f77c623c10cd19fefcf7229a5d7..635ae4043666ce88e499cf4ff469b0480de5cda6 100644 --- a/modules/bred/module.py +++ b/modules/bred/module.py @@ -17,6 +17,7 @@ # 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 weboob.capabilities.bank import CapBankWealth, AccountNotFound, Account from weboob.capabilities.base import find_object @@ -38,21 +39,23 @@ class BredModule(Module, CapBankWealth, CapProfile): VERSION = '1.6' DESCRIPTION = u'Bred' LICENSE = 'LGPLv3+' - CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), - ValueBackendPassword('password', label='Mot de passe'), - Value('website', label=u"Site d'accès", default='bred', - choices={'bred': 'BRED', 'dispobank': 'DispoBank'}), - Value('accnum', label=u'Numéro du compte bancaire (optionnel)', default='', masked=False) - ) - - BROWSERS = {'bred': BredBrowser, - 'dispobank': DispoBankBrowser, - } + CONFIG = BackendConfig( + ValueBackendPassword('login', label='Identifiant', masked=False), + ValueBackendPassword('password', label='Mot de passe'), + Value('website', label="Site d'accès", default='bred', + choices={'bred': 'BRED', 'dispobank': 'DispoBank'}), + Value('accnum', label='Numéro du compte bancaire (optionnel)', default='', masked=False), + ) + + BROWSERS = { + 'bred': BredBrowser, + 'dispobank': DispoBankBrowser, + } def create_default_browser(self): self.BROWSER = self.BROWSERS[self.config['website'].get()] - return self.create_browser(self.config['accnum'].get().replace(' ','').zfill(11), + return self.create_browser(self.config['accnum'].get().replace(' ', '').zfill(11), self.config['login'].get(), self.config['password'].get())