<commit_before># -*- coding: utf-8 -*-

# Copyright(C) 2012 <NAME>
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#

# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.


from weboob.deprecated.browser import Browser, BrowserIncorrectPassword

from .pages.login import LoginPage
from .pages.accounts_list import GlobalAccountsList, AccountsList, AccountHistoryPage, InvestmentHistoryPage, PeaHistoryPage

__all__ = ['Fortuneo']


class Fortuneo(Browser):
    DOMAIN_LOGIN = 'www.fortuneo.fr'
    DOMAIN = 'www.fortuneo.fr'
    PROTOCOL = 'https'
    CERTHASH = ['4ff0301115f80f18c4e81a136ca28829b46d416d404174945b1ae48abd0634e2']
    ENCODING = None # refer to the HTML encoding
    PAGES = {
            '.*identification\.jsp.*' :                                                         LoginPage,

            '.*prive/default\.jsp.*' :                                                          AccountsList,
            '.*/prive/mes-comptes/synthese-mes-comptes\.jsp' :                                  AccountsList,
            '.*/prive/mes-comptes/synthese-globale/synthese-mes-comptes\.jsp' :                 GlobalAccountsList,

            '.*/prive/mes-comptes/livret/consulter-situation/consulter-solde\.jsp.*' :          AccountHistoryPage,
            '.*/prive/mes-comptes/compte-courant/consulter-situation/consulter-solde\.jsp.*' :  AccountHistoryPage,
            '.*/prive/mes-comptes/compte-titres-.*':                                            PeaHistoryPage,
            '.*/prive/mes-comptes/assurance-vie.*':                                             InvestmentHistoryPage,
            '.*/prive/mes-comptes/pea.*':                                                       PeaHistoryPage,
            '.*/prive/mes-comptes/compte-especes.*':                                            AccountHistoryPage,
            }

    def __init__(self, *args, **kwargs):
        Browser.__init__(self, *args, **kwargs)

    def home(self):
        """main page (login)"""

        self.login()

    def is_logged(self):
        """Return True if we are logged on website"""

        return self.page is not None and not self.is_on_page(LoginPage)

    def login(self):
        """Login to the website.
        This function is called when is_logged() returns False and the
        password attribute is not None."""

        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)

        if not self.is_on_page(LoginPage):
            self.location('https://' + self.DOMAIN_LOGIN + '/fr/identification.jsp', no_login=True)

        self.page.login(self.username, self.password)

        if self.is_on_page(LoginPage):
            raise BrowserIncorrectPassword()

        self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-mes-comptes.jsp')

        if self.is_on_page(AccountsList) and self.page.need_reload():
            self.location('/ReloadContext?action=1&')

    def get_investments(self, account):
        self.location(account._link_id)

        return self.page.get_investments()

    def get_history(self, account):
        self.location(account._link_id)

        if self.page.select_period():
            return self.page.get_operations(account)

        return ([])<commit_msg>throwing error when an sms is required to access information<commit_after># -*- coding: utf-8 -*-

# Copyright(C) 2012 <NAME>
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#

# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.


from weboob.capabilities.base import UserError
from weboob.deprecated.browser import Browser, BrowserIncorrectPassword

from .pages.login import LoginPage
from .pages.accounts_list import GlobalAccountsList, AccountsList, AccountHistoryPage, InvestmentHistoryPage, PeaHistoryPage

__all__ = ['Fortuneo']


class Fortuneo(Browser):
    DOMAIN_LOGIN = 'www.fortuneo.fr'
    DOMAIN = 'www.fortuneo.fr'
    PROTOCOL = 'https'
    CERTHASH = ['4ff0301115f80f18c4e81a136ca28829b46d416d404174945b1ae48abd0634e2']
    ENCODING = None # refer to the HTML encoding
    PAGES = {
            '.*identification\.jsp.*' :                                                         LoginPage,

            '.*prive/default\.jsp.*' :                                                          AccountsList,
            '.*/prive/mes-comptes/synthese-mes-comptes\.jsp' :                                  AccountsList,
            '.*/prive/mes-comptes/synthese-globale/synthese-mes-comptes\.jsp' :                 GlobalAccountsList,

            '.*/prive/mes-comptes/livret/consulter-situation/consulter-solde\.jsp.*' :          AccountHistoryPage,
            '.*/prive/mes-comptes/compte-courant/consulter-situation/consulter-solde\.jsp.*' :  AccountHistoryPage,
            '.*/prive/mes-comptes/compte-titres-.*':                                            PeaHistoryPage,
            '.*/prive/mes-comptes/assurance-vie.*':                                             InvestmentHistoryPage,
            '.*/prive/mes-comptes/pea.*':                                                       PeaHistoryPage,
            '.*/prive/mes-comptes/compte-especes.*':                                            AccountHistoryPage,
            }

    def __init__(self, *args, **kwargs):
        Browser.__init__(self, *args, **kwargs)

    def home(self):
        """main page (login)"""

        self.login()

    def is_logged(self):
        """Return True if we are logged on website"""

        return self.page is not None and not self.is_on_page(LoginPage)

    def login(self):
        """Login to the website.
        This function is called when is_logged() returns False and the
        password attribute is not None."""

        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)

        if not self.is_on_page(LoginPage):
            self.location('https://' + self.DOMAIN_LOGIN + '/fr/identification.jsp', no_login=True)

        self.page.login(self.username, self.password)

        if self.is_on_page(LoginPage):
            raise BrowserIncorrectPassword()

        self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-mes-comptes.jsp')

        if self.is_on_page(AccountsList) and self.page.need_reload():
            self.location('/ReloadContext?action=1&')
        elif self.is_on_page(AccountsList):
            raise UserError('Authentification with sms is not supported')

    def get_investments(self, account):
        self.location(account._link_id)

        return self.page.get_investments()

    def get_history(self, account):
        self.location(account._link_id)

        if self.page.select_period():
            return self.page.get_operations(account)

        return ([])
{'fraction_non_alphanumeric': 0.1044776119402985, 'fraction_numerical': 0.013154566152289401, 'mean_word_length': 2.1577476038338657, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5771903', 'n_tokens_mistral': 2360, 'n_tokens_neox': 2218, 'n_words': 546}