The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit b673880f authored by Edouard Lambert's avatar Edouard Lambert Committed by Romain Bignon

adding CapProfile to cragr

parent ff9f9e17
......@@ -22,6 +22,7 @@
from weboob.capabilities.bank import Account, AccountNotFound, CapBankTransfer
from weboob.capabilities.contact import CapContact
from weboob.capabilities.profile import CapProfile
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value
......@@ -31,7 +32,7 @@
__all__ = ['CragrModule']
class CragrModule(Module, CapBankTransfer, CapContact):
class CragrModule(Module, CapBankTransfer, CapContact, CapProfile):
NAME = 'cragr'
MAINTAINER = u'Romain Bignon'
EMAIL = 'romain@weboob.org'
......@@ -115,6 +116,11 @@ def iter_investment(self, account):
def iter_contacts(self):
return self.browser.iter_advisor()
def get_profile(self):
if not hasattr(self.browser, 'get_profile'):
raise NotImplementedError()
return self.browser.get_profile()
def iter_transfer_recipients(self, account):
if not isinstance(account, Account):
account = self.get_account(account)
......
......@@ -36,7 +36,7 @@
SavingsPage, TransactionsPage, AdvisorPage, UselessPage,
CardsPage, LifeInsurancePage, MarketPage, LoansPage, PerimeterPage,
ChgPerimeterPage, MarketHomePage, FirstVisitPage, BGPIPage,
TransferInit, TransferPage,
TransferInit, TransferPage, ProfilePage,
)
......@@ -81,6 +81,7 @@ class Cragr(LoginBrowser):
advisor = URL(r'/stb/entreeBam\?.*act=Contact',
r'https://.*/vitrine/tracking/t/', AdvisorPage)
profile = URL(r'/stb/entreeBam\?.*act=Coordonnees', ProfilePage)
login_error = URL(r'/stb/.*/erreur/.*', LoginErrorPage)
cards = URL(r'/stb/collecteNI\?.*fwkaction=Cartes.*',
r'/stb/collecteNI\?.*sessionAPP=Cartes.*',
......@@ -207,6 +208,7 @@ def do_login(self):
self.savings_url = re.sub('act=([^&=]+)', 'act=Synthepargnes', self.accounts_url, 1)
self.loans_url = re.sub('act=([^&=]+)', 'act=Synthcredits', self.accounts_url, 1)
self.advisor_url = re.sub('act=([^&=]+)', 'act=Contact', self.accounts_url, 1)
self.profile_url = re.sub('act=([^&=]+)', 'act=Coordonnees', self.accounts_url, 1)
if self.page.check_perimeters() and not self.broken_perimeters:
self.perimeter_url = re.sub('act=([^&=]+)', 'act=Perimetre', self.accounts_url, 1)
......@@ -415,6 +417,13 @@ def iter_advisor(self):
for adv in self.page.iter_numbers():
yield adv
@need_login
def get_profile(self):
if not self.profile.is_here():
self.location(self.profile_url.format(self.sag))
return self.page.get_profile()
@need_login
def moveto_market_website(self, account, home=False):
response = self.open(account._link % self.sag).text
......
......@@ -29,11 +29,12 @@
from weboob.capabilities.base import Currency
from weboob.capabilities.bank import Account, Investment, Recipient, Transfer, TransferError
from weboob.capabilities.contact import Advisor
from weboob.capabilities.profile import Profile
from weboob.exceptions import BrowserIncorrectPassword, ActionNeeded
from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction
from weboob.tools.date import parse_french_date, LinearDateGuesser
from weboob.browser.elements import ItemElement, method
from weboob.browser.filters.standard import Date, CleanText, CleanDecimal, Currency as CleanCurrency, Regexp
from weboob.browser.filters.standard import Date, CleanText, CleanDecimal, Currency as CleanCurrency, Regexp, Format
class MyLoggedPage(object):
......@@ -788,6 +789,27 @@ def iter_numbers(self):
yield adv
class ProfilePage(MyLoggedPage, BasePage):
@method
class get_profile(ItemElement):
klass = Profile
obj_email = Regexp(CleanText('//font/b/script[contains(text(), "Mail")]', default=""), '\'([^\']+)', default=NotAvailable)
def obj_address(self):
address = ""
for tr in self.page.doc.xpath('//tr[td[contains(text(), "Adresse")]]/following-sibling::tr[position() < 4]'):
address += " " + CleanText('./td[last()]')(tr).strip()
return ' '.join(address.split()) or NotAvailable
def obj_name(self):
name = CleanText('//span[contains(text(), "Espace Titulaire")]', default=None)(self)
if name and not "particuliers" in name:
return ''.join(name.split(':')[1:]).strip()
pattern = u'//td[contains(text(), "%s")]/following-sibling::td[1]'
return Format('%s %s', CleanText(pattern % "Nom"), CleanText(pattern % "Prénom"))(self)
class BGPIPage(MarketPage):
COL_ID = 0
COL_QUANTITY = 1
......
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