Commit 9ab5b3c9 authored by Lucas Ficheux's avatar Lucas Ficheux Committed by ntome

[bnpcards] Port to Python 3

Ported to Python 3 while assuring Python 2
compatibility
parent 72cb5ec7
......@@ -22,6 +22,7 @@ from weboob.exceptions import BrowserIncorrectPassword, BrowserPasswordExpired
from weboob.browser import LoginBrowser, URL, need_login
from weboob.browser.switch import SiteSwitch
from weboob.tools.capabilities.bank.transactions import sorted_transactions
from weboob.tools.compat import basestring
from .pages import LoginPage, ErrorPage, AccountsPage, TransactionsPage, \
TiCardPage, TiHistoPage, ComingPage, HistoPage, HomePage
......@@ -30,35 +31,35 @@ from .pages import LoginPage, ErrorPage, AccountsPage, TransactionsPage, \
class BnpcartesentrepriseBrowser(LoginBrowser):
BASEURL = 'https://www.cartesentreprise.bnpparibas.com'
login = URL('/ce_internet_public/seConnecter.builder.do', LoginPage)
error = URL('.*.seConnecter.event.do',
'.*.compteGestChgPWD.builder.do',
'/ce_internet_prive_ti/compteTituChgPWD.builder.do',
login = URL(r'/ce_internet_public/seConnecter.builder.do', LoginPage)
error = URL(r'.*.seConnecter.event.do',
r'.*.compteGestChgPWD.builder.do',
r'/ce_internet_prive_ti/compteTituChgPWD.builder.do',
r'/ce_internet_corporate_ti/compteTituChgPWDCorporate.builder.do',
ErrorPage)
home = URL('/ce_internet_prive_ge/accueilInternetGe.builder.do',
'/ce_internet_(prive|corporate)_ti/accueilInternetTi(Corporate)?.builder.do', HomePage)
accounts = URL('/ce_internet_prive_ge/carteAffaireParc.builder.do',
'/ce_internet_prive_ge/carteAffaireParcChange.event.do',
'/ce_internet_prive_ge/pageParcCarteAffaire.event.do', AccountsPage)
coming = URL('/ce_internet_prive_ge/operationEnCours.builder.do',
'/ce_internet_prive_ge/operationEnCours.event.do', ComingPage)
history = URL('/ce_internet_prive_ge/operationHisto.builder.do',
'/ce_internet_prive_ge/operationHisto.event.do', HistoPage)
transactions = URL('ce_internet_prive_ge/operationEnCoursDetail.builder.do.*',
'ce_internet_prive_ge/pageOperationEnCoursDetail.event.do.*',
'ce_internet_prive_ge/operationHistoDetail.builder.do.*',
'ce_internet_prive_ge/pageOperationHistoDetail.event.do.*',
home = URL(r'/ce_internet_prive_ge/accueilInternetGe.builder.do',
r'/ce_internet_(prive|corporate)_ti/accueilInternetTi(Corporate)?.builder.do', HomePage)
accounts = URL(r'/ce_internet_prive_ge/carteAffaireParc.builder.do',
r'/ce_internet_prive_ge/carteAffaireParcChange.event.do',
r'/ce_internet_prive_ge/pageParcCarteAffaire.event.do', AccountsPage)
coming = URL(r'/ce_internet_prive_ge/operationEnCours.builder.do',
r'/ce_internet_prive_ge/operationEnCours.event.do', ComingPage)
history = URL(r'/ce_internet_prive_ge/operationHisto.builder.do',
r'/ce_internet_prive_ge/operationHisto.event.do', HistoPage)
transactions = URL(r'ce_internet_prive_ge/operationEnCoursDetail.builder.do.*',
r'ce_internet_prive_ge/pageOperationEnCoursDetail.event.do.*',
r'ce_internet_prive_ge/operationHistoDetail.builder.do.*',
r'ce_internet_prive_ge/pageOperationHistoDetail.event.do.*',
TransactionsPage)
ti_card = URL('/ce_internet_prive_ti/operationEnCoursDetail.builder.do',
'/ce_internet_(prive|corporate)_ti/operation(Corporate)?EnCoursDetail(Afficher|Appliquer)?.event.do.*',
'/ce_internet_prive_ti/pageOperationEnCoursDetail.event.do.*', TiCardPage)
ti_corporate_card = URL('/ce_internet_corporate_ti/operationCorporateEnCoursDetail.builder.do', TiCardPage)
ti_histo = URL('/ce_internet_prive_ti/operationHistoDetail.builder.do',
'/ce_internet_(prive|corporate)_ti/operation(Corporate)?HistoDetail(Afficher|Appliquer)?.event.do.*',
'/ce_internet_prive_ti/pageOperationHistoDetail.event.do.*', TiHistoPage)
ti_corporate_histo = URL('/ce_internet_corporate_ti/operationCorporateHistoDetail.builder.do', TiHistoPage)
ti_card = URL(r'/ce_internet_prive_ti/operationEnCoursDetail.builder.do',
r'/ce_internet_(prive|corporate)_ti/operation(Corporate)?EnCoursDetail(Afficher|Appliquer)?.event.do.*',
r'/ce_internet_prive_ti/pageOperationEnCoursDetail.event.do.*', TiCardPage)
ti_corporate_card = URL(r'/ce_internet_corporate_ti/operationCorporateEnCoursDetail.builder.do', TiCardPage)
ti_histo = URL(r'/ce_internet_prive_ti/operationHistoDetail.builder.do',
r'/ce_internet_(prive|corporate)_ti/operation(Corporate)?HistoDetail(Afficher|Appliquer)?.event.do.*',
r'/ce_internet_prive_ti/pageOperationHistoDetail.event.do.*', TiHistoPage)
ti_corporate_histo = URL(r'/ce_internet_corporate_ti/operationCorporateHistoDetail.builder.do', TiHistoPage)
TIMEOUT = 60.0
def __init__(self, type, *args, **kwargs):
......
......@@ -21,6 +21,7 @@
from weboob.exceptions import BrowserIncorrectPassword, BrowserPasswordExpired
from weboob.browser import LoginBrowser, URL, need_login
from weboob.tools.capabilities.bank.transactions import sorted_transactions
from weboob.tools.compat import basestring
from .pages import LoginPage, ErrorPage, AccountsPage, TransactionsPage
......
......@@ -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 <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import re
from datetime import date
from dateutil.relativedelta import relativedelta
......@@ -60,7 +62,7 @@ class AccountsPage(LoggedPage, HTMLPage):
obj_label = CleanText('./td[1]')
obj_type = Account.TYPE_CARD
obj__status = CleanText('./td[5]')
obj_currency = u'EUR'
obj_currency = 'EUR'
obj_url = Link('./td[2]/a')
obj__company = Env('company', default=None) # this field is something used to make the module work, not something meant to be displayed to end users
......@@ -145,7 +147,7 @@ class TransactionsPage(LoggedPage, HTMLPage):
url = Attr('//table[@id="tgDecorationFoot"]//a[contains(text(), "1")]', 'href', default=None)(self.doc)
if url is None:
# at page=4, there is "<Première page> ... <2> <3> 4"
url = Attr(u'//table[@id="tgDecorationFoot"]//a[contains(text(), "Première page")]', 'href')(self.doc)
url = Attr('//table[@id="tgDecorationFoot"]//a[contains(text(), "Première page")]', 'href')(self.doc)
self.browser.location(url)
......
......@@ -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 <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.tools.backend import Module, BackendConfig
from weboob.capabilities.bank import CapBank, AccountNotFound
......@@ -31,16 +32,24 @@ __all__ = ['BnpcartesentrepriseModule']
class BnpcartesentrepriseModule(Module, CapBank):
NAME = 'bnpcards'
DESCRIPTION = u'BNP Cartes Entreprises'
MAINTAINER = u'Baptiste Delpey'
DESCRIPTION = 'BNP Cartes Entreprises'
MAINTAINER = 'Baptiste Delpey'
EMAIL = 'bdelpey@budget-insight.fr'
LICENSE = 'LGPLv3+'
VERSION = '1.6'
CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Code personnel'),
Value('type', label='Profil de connexion', default='1',
choices={'1': 'Titulaire',
'2': 'Gestionnaire'}))
CONFIG = BackendConfig(
ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Code personnel'),
Value(
'type',
label='Profil de connexion',
default='1',
choices={
'1': 'Titulaire',
'2': 'Gestionnaire',
}
)
)
BROWSER = ProxyBrowser
......
......@@ -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 <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import re
from datetime import date
from decimal import Decimal
......@@ -119,7 +121,7 @@ class AccountsPage(ExpandablePage, GetableLinksPage):
obj_type = Account.TYPE_CARD
obj__rib = Env('rib')
obj__company = Env('company', default=None) # this field is something used to make the module work, not something meant to be displayed to end users
obj_currency = u'EUR'
obj_currency = 'EUR'
obj_number = CleanText('./td[2]', replace=[(' ', '')])
obj_url = AbsoluteLink('./td[2]/a')
......@@ -203,7 +205,7 @@ class TiCardPage(ExpandablePage, TransactionsPage):
obj_label = Format('%s %s', CleanText('//table[@class="params"]/tr/td[1]/b[2]'), Field('id'))
obj_type = Account.TYPE_CARD
obj__nav_num = Attr('.', 'value')
obj_currency = u'EUR'
obj_currency = 'EUR'
obj__company = Env('company', default=None) # this field is something used to make the module work, not something meant to be displayed to end users
def get_balance(self):
......
......@@ -29,6 +29,7 @@ binck
biplan
blablacar
blogspot
bnpcards
bnporc
bnppere
bolden
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment