support many kind of accounts
This commit is contained in:
parent
61f4e631dd
commit
66d68c50fb
3 changed files with 12 additions and 10 deletions
|
|
@ -51,8 +51,6 @@ class SocieteGeneraleBackend(BaseBackend, ICapBank):
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
def get_account(self, _id):
|
def get_account(self, _id):
|
||||||
if not _id.isdigit():
|
|
||||||
raise AccountNotFound()
|
|
||||||
with self.browser:
|
with self.browser:
|
||||||
account = self.browser.get_account(_id)
|
account = self.browser.get_account(_id)
|
||||||
if account:
|
if account:
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class SocieteGenerale(BaseBrowser):
|
||||||
'https://particuliers.societegenerale.fr/.*': LoginPage,
|
'https://particuliers.societegenerale.fr/.*': LoginPage,
|
||||||
'https://.*.societegenerale.fr//acces/authlgn.html': BadLoginPage,
|
'https://.*.societegenerale.fr//acces/authlgn.html': BadLoginPage,
|
||||||
'.*restitution/cns_listeprestation.html': AccountsList,
|
'.*restitution/cns_listeprestation.html': AccountsList,
|
||||||
'.*restitution/cns_detailCav.html.*': AccountHistory,
|
'.*restitution/cns_detail.*\.html.*': AccountHistory,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
@ -74,8 +74,7 @@ class SocieteGenerale(BaseBrowser):
|
||||||
if not self.is_on_page(AccountsList):
|
if not self.is_on_page(AccountsList):
|
||||||
self.location('/restitution/cns_listeprestation.html')
|
self.location('/restitution/cns_listeprestation.html')
|
||||||
|
|
||||||
l = self.page.get_list()
|
for a in self.page.get_list():
|
||||||
for a in l:
|
|
||||||
if a.id == id:
|
if a.id == id:
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
|
@ -86,6 +85,7 @@ class SocieteGenerale(BaseBrowser):
|
||||||
|
|
||||||
if not self.is_on_page(AccountHistory):
|
if not self.is_on_page(AccountHistory):
|
||||||
# TODO: support other kind of accounts
|
# TODO: support other kind of accounts
|
||||||
|
self.logger.warning('This account is not supported')
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
return self.page.iter_transactions()
|
return self.page.iter_transactions()
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import re
|
||||||
|
|
||||||
from weboob.capabilities.bank import Account
|
from weboob.capabilities.bank import Account
|
||||||
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||||
from weboob.tools.browser import BasePage, BrokenPageError
|
from weboob.tools.browser import BasePage
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AccountsList', 'AccountHistory']
|
__all__ = ['AccountsList', 'AccountHistory']
|
||||||
|
|
@ -39,7 +39,6 @@ class AccountsList(BasePage):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
l = []
|
|
||||||
for tr in self.document.getiterator('tr'):
|
for tr in self.document.getiterator('tr'):
|
||||||
if 'LGNTableRow' in tr.attrib.get('class', '').split():
|
if 'LGNTableRow' in tr.attrib.get('class', '').split():
|
||||||
account = Account()
|
account = Account()
|
||||||
|
|
@ -65,9 +64,10 @@ class AccountsList(BasePage):
|
||||||
else:
|
else:
|
||||||
account.balance = Decimal(0)
|
account.balance = Decimal(0)
|
||||||
|
|
||||||
l.append(account)
|
if 'CARTE_CB' in account._link_id:
|
||||||
|
continue
|
||||||
|
|
||||||
return l
|
yield account
|
||||||
|
|
||||||
class Transaction(FrenchTransaction):
|
class Transaction(FrenchTransaction):
|
||||||
PATTERNS = [(re.compile(r'^CARTE \w+ RETRAIT DAB.* (?P<dd>\d{2})/(?P<mm>\d{2}) (?P<HH>\d+)H(?P<MM>\d+) (?P<text>.*)'),
|
PATTERNS = [(re.compile(r'^CARTE \w+ RETRAIT DAB.* (?P<dd>\d{2})/(?P<mm>\d{2}) (?P<HH>\d+)H(?P<MM>\d+) (?P<text>.*)'),
|
||||||
|
|
@ -96,10 +96,14 @@ class AccountHistory(BasePage):
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
|
|
||||||
raise BrokenPageError('Unable to find link to history part')
|
return None
|
||||||
|
|
||||||
def iter_transactions(self):
|
def iter_transactions(self):
|
||||||
url = self.get_part_url()
|
url = self.get_part_url()
|
||||||
|
if url is None:
|
||||||
|
# There are no transactions in this kind of account
|
||||||
|
return iter([])
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
d = XML(self.browser.readurl(url))
|
d = XML(self.browser.readurl(url))
|
||||||
el = d.xpath('//dataBody')[0]
|
el = d.xpath('//dataBody')[0]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue