Pep8 cleanups for ING module
This commit is contained in:
parent
dfb66a4fbd
commit
a0d81b0ae1
8 changed files with 106 additions and 89 deletions
|
|
@ -20,4 +20,5 @@
|
||||||
|
|
||||||
from .backend import INGBackend
|
from .backend import INGBackend
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['INGBackend']
|
__all__ = ['INGBackend']
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,16 @@ class INGBackend(BaseBackend, ICapBank):
|
||||||
VERSION = '0.b'
|
VERSION = '0.b'
|
||||||
LICENSE = 'AGPLv3+'
|
LICENSE = 'AGPLv3+'
|
||||||
DESCRIPTION = 'ING Direct French bank website'
|
DESCRIPTION = 'ING Direct French bank website'
|
||||||
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False),
|
CONFIG = BackendConfig(ValueBackendPassword('login',
|
||||||
ValueBackendPassword('password', label='Password', regexp='^(\d{6}|)$'),
|
label='Account ID',
|
||||||
ValueBackendPassword('birthday', label='Birthday', regexp='^(\d{8}|)$', masked=False)
|
masked=False),
|
||||||
|
ValueBackendPassword('password',
|
||||||
|
label='Password',
|
||||||
|
regexp='^(\d{6}|)$'),
|
||||||
|
ValueBackendPassword('birthday',
|
||||||
|
label='Birthday',
|
||||||
|
regexp='^(\d{8}|)$',
|
||||||
|
masked=False)
|
||||||
)
|
)
|
||||||
BROWSER = Ing
|
BROWSER = Ing
|
||||||
|
|
||||||
|
|
@ -72,4 +79,3 @@ class INGBackend(BaseBackend, ICapBank):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
for coming in self.browser.get_coming_operations(account.id):
|
for coming in self.browser.get_coming_operations(account.id):
|
||||||
yield coming
|
yield coming
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ class Ing(BaseBrowser):
|
||||||
assert self.birthday.isdigit()
|
assert self.birthday.isdigit()
|
||||||
|
|
||||||
if not self.is_on_page(LoginPage):
|
if not self.is_on_page(LoginPage):
|
||||||
self.location('https://secure.ingdirect.fr/public/displayLogin.jsf')
|
self.location('https://secure.ingdirect.fr/\
|
||||||
|
public/displayLogin.jsf')
|
||||||
|
|
||||||
self.page.prelogin(self.username, self.birthday)
|
self.page.prelogin(self.username, self.birthday)
|
||||||
self.page.login(self.password)
|
self.page.login(self.password)
|
||||||
|
|
@ -83,10 +84,14 @@ class Ing(BaseBrowser):
|
||||||
account = self.get_account(id)
|
account = self.get_account(id)
|
||||||
# The first and the second letter of the label are the account type
|
# The first and the second letter of the label are the account type
|
||||||
if account.label[0:2] == "CC":
|
if account.label[0:2] == "CC":
|
||||||
self.location('https://secure.ingdirect.fr/protected/pages/cc/accountDetail.jsf')
|
self.location('https://secure.ingdirect.fr/\
|
||||||
|
protected/pages/cc/accountDetail.jsf')
|
||||||
elif account.label[0:2] == "LA":
|
elif account.label[0:2] == "LA":
|
||||||
# we want "displayTRHistoriqueLA" but this fucking page is not directly available...
|
# we want "displayTRHistoriqueLA" but this fucking page
|
||||||
self.location('https://secure.ingdirect.fr/general?command=goToAccount&account=%d&zone=COMPTE' % int(id))
|
# is not directly available...
|
||||||
|
self.location('https://secure.ingdirect.fr/\
|
||||||
|
general?command=goToAccount&account=%d&zone=COMPTE'\
|
||||||
|
% int(id))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
return self.page.get_transactions()
|
return self.page.get_transactions()
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ from .accounts_list import AccountsList
|
||||||
from .account_history import AccountHistoryCC, AccountHistoryLA
|
from .account_history import AccountHistoryCC, AccountHistoryLA
|
||||||
from .login import LoginPage, LoginPage2, ConfirmPage, MessagePage
|
from .login import LoginPage, LoginPage2, ConfirmPage, MessagePage
|
||||||
|
|
||||||
class AccountPrelevement(AccountsList): pass
|
|
||||||
|
|
||||||
__all__ = ['AccountsList', 'AccountHistoryCC', 'AccountHistoryLA', 'LoginPage', 'LoginPage2',
|
class AccountPrelevement(AccountsList):
|
||||||
'ConfirmPage', 'MessagePage', 'AccountPrelevement']
|
pass
|
||||||
|
|
||||||
|
__all__ = ['AccountsList', 'AccountHistoryCC', 'AccountHistoryLA', 'LoginPage',
|
||||||
|
'LoginPage2', 'ConfirmPage', 'MessagePage', 'AccountPrelevement']
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@ from weboob.capabilities.base import NotAvailable
|
||||||
__all__ = ['AccountHistoryCC', 'AccountHistoryLA']
|
__all__ = ['AccountHistoryCC', 'AccountHistoryLA']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AccountHistoryCC(BasePage):
|
class AccountHistoryCC(BasePage):
|
||||||
types = {
|
types = {
|
||||||
'Carte achat': Transaction.TYPE_CARD,
|
'Carte achat': Transaction.TYPE_CARD,
|
||||||
|
|
@ -52,7 +50,8 @@ class AccountHistoryCC(BasePage):
|
||||||
op.category = texte[4]
|
op.category = texte[4]
|
||||||
op.type = self.types.get(texte[4], Transaction.TYPE_UNKNOWN)
|
op.type = self.types.get(texte[4], Transaction.TYPE_UNKNOWN)
|
||||||
|
|
||||||
amount = texte[5].replace('\t','').strip().replace(u'€', '').replace(',', '.').replace(u'\xa0', u'')
|
amount = texte[5].replace('\t', '').strip().replace(u'€', '').\
|
||||||
|
replace(',', '.').replace(u'\xa0', u'')
|
||||||
op.amount = float(amount)
|
op.amount = float(amount)
|
||||||
|
|
||||||
self.transactions.append(op)
|
self.transactions.append(op)
|
||||||
|
|
@ -61,6 +60,7 @@ class AccountHistoryCC(BasePage):
|
||||||
def get_transactions(self):
|
def get_transactions(self):
|
||||||
return self.transactions
|
return self.transactions
|
||||||
|
|
||||||
|
|
||||||
class AccountHistoryLA(BasePage):
|
class AccountHistoryLA(BasePage):
|
||||||
|
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
|
|
@ -78,14 +78,13 @@ class AccountHistoryLA(BasePage):
|
||||||
op.date = date(*reversed([int(x) for x in texte[0].split('/')]))
|
op.date = date(*reversed([int(x) for x in texte[0].split('/')]))
|
||||||
op.category = NotAvailable
|
op.category = NotAvailable
|
||||||
|
|
||||||
amount = texte[length - 1].replace('\t','').strip().replace('.', '').replace(u'€', '').replace(',', '.').replace(u'\xa0', u'')
|
amount = texte[length - 1].replace('\t', '').strip().\
|
||||||
|
replace('.', '').replace(u'€', '').\
|
||||||
|
replace(',', '.').replace(u'\xa0', u'')
|
||||||
op.amount = float(amount)
|
op.amount = float(amount)
|
||||||
|
|
||||||
|
|
||||||
self.transactions.append(op)
|
self.transactions.append(op)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def get_transactions(self):
|
def get_transactions(self):
|
||||||
return self.transactions
|
return self.transactions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ class AccountsList(BasePage):
|
||||||
linkbis = self.document.xpath(urltofind).pop()
|
linkbis = self.document.xpath(urltofind).pop()
|
||||||
if linkbis.text == link.text:
|
if linkbis.text == link.text:
|
||||||
linkbis = self.document.xpath(urltofind)[1]
|
linkbis = self.document.xpath(urltofind)[1]
|
||||||
account.balance = float( linkbis.text.replace('.','').replace(' ', '').replace(',','.') )
|
account.balance = float(linkbis.text.replace('.', '').\
|
||||||
|
replace(' ', '').replace(',', '.'))
|
||||||
account.coming = NotAvailable
|
account.coming = NotAvailable
|
||||||
l.append(account)
|
l.append(account)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@ from weboob.tools.browser import BasePage
|
||||||
from weboob.tools.captcha.virtkeyboard import VirtKeyboard, VirtKeyboardError
|
from weboob.tools.captcha.virtkeyboard import VirtKeyboard, VirtKeyboardError
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['LoginPage', 'LoginPage2', 'ConfirmPage', 'ChangePasswordPage']
|
__all__ = ['LoginPage', 'LoginPage2', 'ConfirmPage', 'ChangePasswordPage']
|
||||||
|
|
||||||
|
|
||||||
class INGVirtKeyboard(VirtKeyboard):
|
class INGVirtKeyboard(VirtKeyboard):
|
||||||
symbols = {'0': '327208d491507341908cf6920f26b586',
|
symbols = {'0': '327208d491507341908cf6920f26b586',
|
||||||
'1': '615ff37b15645da106cebc4605b399de',
|
'1': '615ff37b15645da106cebc4605b399de',
|
||||||
|
|
@ -42,7 +44,6 @@ class INGVirtKeyboard(VirtKeyboard):
|
||||||
}
|
}
|
||||||
color = 64
|
color = 64
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, basepage):
|
def __init__(self, basepage):
|
||||||
divkeyboard = basepage.document.find("//div[@id='clavierdisplayLogin']")
|
divkeyboard = basepage.document.find("//div[@id='clavierdisplayLogin']")
|
||||||
img = divkeyboard.xpath("img")[1]
|
img = divkeyboard.xpath("img")[1]
|
||||||
|
|
@ -77,7 +78,7 @@ class INGVirtKeyboard(VirtKeyboard):
|
||||||
else:
|
else:
|
||||||
first = False
|
first = False
|
||||||
codesymbol = self.get_symbol_code(self.symbols[c])
|
codesymbol = self.get_symbol_code(self.symbols[c])
|
||||||
x = (self.coords[codesymbol][0] + self.coords[codesymbol][2]) / 2 # In the middle
|
x = (self.coords[codesymbol][0] + self.coords[codesymbol][2]) / 2
|
||||||
y = (self.coords[codesymbol][1] + self.coords[codesymbol][3]) / 2
|
y = (self.coords[codesymbol][1] + self.coords[codesymbol][3]) / 2
|
||||||
code += str(x)
|
code += str(x)
|
||||||
code += ","
|
code += ","
|
||||||
|
|
@ -85,7 +86,6 @@ class INGVirtKeyboard(VirtKeyboard):
|
||||||
return code
|
return code
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LoginPage(BasePage):
|
class LoginPage(BasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -101,6 +101,7 @@ class LoginPage(BasePage):
|
||||||
self.browser['zone1Form:radioSaveClientNumber'] = False
|
self.browser['zone1Form:radioSaveClientNumber'] = False
|
||||||
self.browser.submit(nologin=True)
|
self.browser.submit(nologin=True)
|
||||||
|
|
||||||
|
|
||||||
class LoginPage2(BasePage):
|
class LoginPage2(BasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -144,11 +145,12 @@ class ConfirmPage(BasePage):
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
|
|
||||||
|
|
||||||
class MessagePage(BasePage):
|
class MessagePage(BasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ChangePasswordPage(BasePage):
|
class ChangePasswordPage(BasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
from weboob.tools.test import BackendTest
|
from weboob.tools.test import BackendTest
|
||||||
|
|
||||||
|
|
||||||
class INGTest(BackendTest):
|
class INGTest(BackendTest):
|
||||||
BACKEND = 'ing'
|
BACKEND = 'ing'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue