Commit 444d36ee authored by Florent Fourcot's avatar Florent Fourcot

Rename BasePage to Page

parent 44dffce7
......@@ -330,7 +330,7 @@ Then, each method on your browser which need your user to be authenticated may b
return self.page.get_accounts()
The last thing to know is that :func:`need_login <weboob.tools.browser2.page.need_login>` checks if the current page is a logged one by
reading the attribute :func:`logged <weboob.tools.browser2.page.BasePage.logged>` of the instance. You can either define it yourself, as a
reading the attribute :func:`logged <weboob.tools.browser2.page.Page.logged>` of the instance. You can either define it yourself, as a
class boolean attribute or as a property, or to inherit your class from :class:`LoggedPage <weboob.tools.browser2.page.LoggedPage>`.
......
......@@ -20,10 +20,10 @@
from weboob.capabilities.recipe import Recipe, Comment
from weboob.capabilities.base import NotAvailable, NotLoaded
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
class ResultsPage(BasePage):
class ResultsPage(Page):
""" Page which contains results as a list of recipies
"""
def iter_recipes(self):
......@@ -62,7 +62,7 @@ class ResultsPage(BasePage):
yield recipe
class RecipePage(BasePage):
class RecipePage(Page):
""" Page which contains a recipe
"""
def get_recipe(self, id):
......
......@@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.html import html2text
from .job import AdeccoJobAdvert
import datetime
......@@ -27,7 +27,7 @@ import re
MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre']
class SearchPage(BasePage):
class SearchPage(Page):
def iter_job_adverts(self):
re_id = re.compile('http://www.adecco.fr/trouver-un-emploi/Pages/Details-de-l-Offre/(.*?)/(.*?).aspx\?IOF=(.*?)$', re.DOTALL)
......@@ -55,7 +55,7 @@ class SearchPage(BasePage):
yield advert
class AdvertPage(BasePage):
class AdvertPage(Page):
def get_job_advert(self, url, advert):
re_id = re.compile('http://www.adecco.fr/trouver-un-emploi/Pages/Details-de-l-Offre/(.*?)/(.*?).aspx\?IOF=(.*?)$', re.DOTALL)
if advert is None:
......
......@@ -20,14 +20,14 @@
from weboob.capabilities.recipe import Recipe
from weboob.capabilities.base import NotAvailable, NotLoaded
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
class FourOFourPage(BasePage):
class FourOFourPage(Page):
pass
class ResultsPage(BasePage):
class ResultsPage(Page):
""" Page which contains results as a list of recipies
"""
def iter_recipes(self):
......@@ -56,7 +56,7 @@ class ResultsPage(BasePage):
yield recipe
class RecipePage(BasePage):
class RecipePage(Page):
""" Page which contains a recipe
"""
def get_recipe(self, id):
......
......@@ -22,14 +22,14 @@ from datetime import datetime
import re
import urllib
from decimal import Decimal
from weboob.tools.browser import BasePage,BrokenPageError
from weboob.tools.browser import Page, BrokenPageError
from weboob.capabilities.bill import Subscription, Detail, Bill
# Ugly array to avoid the use of french locale
FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre']
class AmeliBasePage(BasePage):
class AmeliBasePage(Page):
def is_logged(self):
try:
self.parser.select(self.document.getroot(), 'a.logout', 1)
......
......@@ -22,7 +22,7 @@ from datetime import datetime
from decimal import Decimal
import re
import urllib
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.capabilities.bill import Subscription, Detail, Bill
......@@ -30,7 +30,7 @@ from weboob.capabilities.bill import Subscription, Detail, Bill
FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre']
class LoginPage(BasePage):
class LoginPage(Page):
def login(self, login, password):
self.browser.select_form('connexionCompteForm')
self.browser["vp_connexion_portlet_1numPS"] = login.encode('utf8')
......@@ -38,13 +38,13 @@ class LoginPage(BasePage):
self.browser.submit()
class HomePage(BasePage):
class HomePage(Page):
def on_loaded(self):
pass
class AccountPage(BasePage):
class AccountPage(Page):
def get_subscription_list(self):
ident = self.document.xpath('//div[@id="identification"]')[0]
......@@ -59,7 +59,7 @@ class AccountPage(BasePage):
return sub
class HistoryPage(BasePage):
class HistoryPage(Page):
def iter_history(self):
table = self.document.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')[0].xpath('.//tr')
......@@ -83,7 +83,7 @@ class HistoryPage(BasePage):
yield det
class BillsPage(BasePage):
class BillsPage(Page):
def iter_bills(self):
table = self.document.xpath('//table[@id="releveCompteMensuel"]')[0].xpath('.//tr')
......
......@@ -22,14 +22,14 @@ import datetime
from decimal import Decimal
import re
from weboob.tools.browser import BasePage, BrokenPageError
from weboob.tools.browser import Page, BrokenPageError
from weboob.capabilities.bank import Account
from weboob.capabilities import NotAvailable
from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction
from weboob.tools.date import ChaoticDateGuesser
class LoginPage(BasePage):
class LoginPage(Page):
def login(self, username, password):
self.browser.select_form(name='ssoform')
self.browser.set_all_readonly(False)
......@@ -40,7 +40,7 @@ class LoginPage(BasePage):
self.browser.submit(nologin=True)
class AccountsPage(BasePage):
class AccountsPage(Page):
def get_list(self):
for box in self.document.getroot().cssselect('div.roundedBox div.contentBox'):
a = Account()
......@@ -56,7 +56,7 @@ class AccountsPage(BasePage):
yield a
class TransactionsPage(BasePage):
class TransactionsPage(Page):
COL_ID = 0
COL_DATE = 1
COL_DEBIT_DATE = 2
......
......@@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.html import html2text
import dateutil.parser
import re
......@@ -26,7 +26,7 @@ import re
from .job import ApecJobAdvert
class SearchPage(BasePage):
class SearchPage(Page):
def iter_job_adverts(self):
re_id_title = re.compile('/offres-emploi-cadres/\d*_\d*_\d*_(.*?)_(.*?)_(.*?)_(.*?)_(.*?)_(.*?)_(.*?)_(.*?)_(.*?).html', re.DOTALL)
divs = self.document.getroot().xpath("//div[@class='boxContent offre']") + self.document.getroot().xpath("//div[@class='boxContent offre even']")
......@@ -43,7 +43,7 @@ class SearchPage(BasePage):
yield advert
class AdvertPage(BasePage):
class AdvertPage(Page):
def get_job_advert(self, url, advert):
re_id_title = re.compile('/offres-emploi-cadres/\d*_\d*_\d*_(.*?)________(.*?).html(.*?)', re.DOTALL)
if advert is None:
......
......@@ -21,11 +21,11 @@
from decimal import Decimal
from weboob.capabilities.bank import Account
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
class LoginPage(BasePage):
class LoginPage(Page):
def login(self, username, password):
self.browser.select_form(nr=0)
self.browser['_58_login'] = username.encode('utf-8')
......@@ -33,7 +33,7 @@ class LoginPage(BasePage):
self.browser.submit(nologin=True)
class AccountsPage(BasePage):
class AccountsPage(Page):
COL_LABEL = 0
COL_OWNER = 1
COL_ID = 2
......@@ -59,7 +59,7 @@ class Transaction(FrenchTransaction):
pass
class OperationsPage(BasePage):
class OperationsPage(Page):
COL_DATE = 0
COL_LABEL = 1
COL_AMOUNT = 2
......
......@@ -21,14 +21,14 @@ import re
from weboob.capabilities.base import UserError
from weboob.capabilities.image import BaseImage
from weboob.tools.browser import BasePage, BrokenPageError
from weboob.tools.browser import Page, BrokenPageError
from weboob.capabilities import NotAvailable
from .video import ArretSurImagesVideo
class IndexPage(BasePage):
class IndexPage(Page):
def iter_videos(self):
videos = self.document.getroot().cssselect("div[class=bloc-contenu-8]")
for div in videos:
......@@ -55,7 +55,7 @@ class ForbiddenVideo(UserError):
pass
class VideoPage(BasePage):
class VideoPage(Page):
def is_logged(self):
try:
self.parser.select(self.document.getroot(), '#user-info', 1)
......@@ -106,7 +106,7 @@ class VideoPage(BasePage):
return url
class LoginPage(BasePage):
class LoginPage(Page):
def login(self, username, password):
response = self.browser.response()
response.set_data(response.get_data().replace("<br/>", "<br />")) # Python mechanize is broken, fixing it.
......@@ -119,5 +119,5 @@ class LoginPage(BasePage):
self.browser.submit()
class LoginRedirectPage(BasePage):
class LoginRedirectPage(Page):
pass
......@@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.html import html2text
from weboob.capabilities import NotAvailable
from weboob.capabilities.image import BaseImage
......@@ -26,7 +26,7 @@ from weboob.capabilities.collection import Collection
from .video import ArteLiveVideo
class ArteLiveVideoPage(BasePage):
class ArteLiveVideoPage(Page):
def get_video(self, video=None):
if not video:
video = ArteLiveVideo(self.group_dict['id'])
......@@ -43,7 +43,7 @@ class ArteLiveVideoPage(BasePage):
return json_url, video
class ArteLivePage(BasePage):
class ArteLivePage(Page):
def iter_resources(self):
items = list()
for el in self.document.xpath('//ul[@class="filter-liste"]/li'):
......
......@@ -20,10 +20,10 @@
from weboob.capabilities.subtitle import Subtitle
from weboob.capabilities.base import NotAvailable
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
class SearchPage(BasePage):
class SearchPage(Page):
def iter_subtitles(self, language, pattern):
fontresult = self.parser.select(self.document.getroot(), 'div.search-results font.search-results')
# for each result in freefind, explore the subtitle list page to iter subtitles
......@@ -37,7 +37,7 @@ class SearchPage(BasePage):
yield subtitle
class SubtitlesPage(BasePage):
class SubtitlesPage(Page):
def get_subtitle(self, id):
href = id.split('|')[1]
# we have to find the 'tr' which contains the link to this address
......
......@@ -22,7 +22,7 @@ import urllib
from decimal import Decimal, InvalidOperation
import re
from weboob.tools.browser import BasePage as _BasePage, BrowserUnavailable, BrokenPageError
from weboob.tools.browser import Page as _BasePage, BrowserUnavailable, BrokenPageError
from weboob.capabilities.bank import Account
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard
......
......@@ -24,7 +24,7 @@ from decimal import Decimal
import re
from mechanize import Cookie, FormNotFoundError
from weboob.tools.browser import BasePage as _BasePage, BrowserUnavailable, BrokenPageError
from weboob.tools.browser import Page as _BasePage, BrowserUnavailable, BrokenPageError
from weboob.capabilities.bank import Account
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
......
......@@ -22,12 +22,12 @@ import datetime
from decimal import Decimal
import re
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.capabilities.bank import Account
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
class LoginPage(BasePage):
class LoginPage(Page):
def login(self, login, passwd):
self.browser.select_form(name='frmLogin')
self.browser['username'] = login.encode(self.browser.ENCODING)
......@@ -41,7 +41,7 @@ class LoginPage(BasePage):
return True
class Login2Page(BasePage):
class Login2Page(Page):
def login(self, secret):
label = self.document.xpath('//span[@class="PF_LABEL"]')[0].text.strip()
letters = ''
......@@ -53,11 +53,11 @@ class Login2Page(BasePage):
self.browser.submit(name='valider', nologin=True)
class IndexPage(BasePage):
class IndexPage(Page):
pass
class AccountsPage(BasePage):
class AccountsPage(Page):
ACCOUNT_TYPES = {u'Epargne': Account.TYPE_SAVINGS,
u'Liquidités': Account.TYPE_CHECKING,
u'Titres': Account.TYPE_MARKET,
......@@ -170,7 +170,7 @@ class Transaction(FrenchTransaction):
]
class HistoryBasePage(BasePage):
class HistoryBasePage(Page):
def get_history(self):
self.logger.warning('Do not support account of type %s' % type(self).__name__)
return iter([])
......
......@@ -24,7 +24,7 @@ from datetime import datetime
import re
from weboob.capabilities.bank import Account
from weboob.tools.browser import BasePage, BrokenPageError
from weboob.tools.browser import Page, BrokenPageError
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError
from weboob.tools.misc import to_unicode
......@@ -50,7 +50,7 @@ class Transaction(FrenchTransaction):
]
class BEPage(BasePage):
class BEPage(Page):
def get_error(self):
for title in self.document.xpath('/html/head/title'):
if 'erreur' in title.text or 'error' in title.text:
......
......@@ -24,10 +24,10 @@ from decimal import Decimal
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.capabilities.bank import Account
from weboob.capabilities.base import NotAvailable
from weboob.tools.browser import BasePage, BrokenPageError, BrowserPasswordExpired
from weboob.tools.browser import Page, BrokenPageError, BrowserPasswordExpired
class AccountsList(BasePage):
class AccountsList(Page):
ACCOUNT_TYPES = {
u'Liquidités': Account.TYPE_CHECKING,
u'Epargne disponible': Account.TYPE_SAVINGS,
......
......@@ -22,7 +22,7 @@ import time
import re
import urllib
from weboob.tools.browser import BasePage, BrowserUnavailable
from weboob.tools.browser import Page, BrowserUnavailable
from weboob.tools.captcha.virtkeyboard import VirtKeyboard, VirtKeyboardError
......@@ -72,7 +72,7 @@ class BNPVirtKeyboard(VirtKeyboard):
return code
class LoginPage(BasePage):
class LoginPage(Page):
def on_loaded(self):
for td in self.document.getroot().cssselect('td.LibelleErreur'):
if td.text is None:
......@@ -101,7 +101,7 @@ class LoginPage(BasePage):
self.browser.location(url, urllib.urlencode(params))
class ConfirmPage(BasePage):
class ConfirmPage(Page):
def get_error(self):
for td in self.document.xpath('//td[@class="hdvon1"]'):
if td.text:
......@@ -115,12 +115,12 @@ class ConfirmPage(BasePage):
return m.group(1)
class InfoMessagePage(BasePage):
class InfoMessagePage(Page):
def on_loaded(self):
pass
class ChangePasswordPage(BasePage):
class ChangePasswordPage(Page):
def change_password(self, current, new):
try:
vk=BNPVirtKeyboard(self)
......
......@@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BasePage, BrokenPageError
from weboob.tools.browser import Page, BrokenPageError
from weboob.capabilities.messages import Message, Thread
from weboob.capabilities.base import NotLoaded
from weboob.tools.capabilities.messages.genericArticle import try_drop_tree
......@@ -29,7 +29,7 @@ from datetime import datetime
from lxml.html import make_links_absolute
class MessagesPage(BasePage):
class MessagesPage(Page):
def iter_threads(self):
table = self.parser.select(self.document.getroot(), 'table#listeMessages', 1)
for tr in table.xpath('./tr'):
......@@ -61,7 +61,7 @@ class MessagesPage(BasePage):
yield thread
class MessagePage(BasePage):
class MessagePage(Page):
def get_content(self):
"""
Get the message content.
......
......@@ -20,7 +20,7 @@
import re
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
......@@ -48,7 +48,7 @@ class Transaction(FrenchTransaction):
]
class AccountHistory(BasePage):
class AccountHistory(Page):
def iter_operations(self):
for tr in self.document.xpath('//table[@id="tableCompte"]//tr'):
if len(tr.xpath('td[@class="debit"]')) == 0:
......
......@@ -20,7 +20,7 @@
import re
from weboob.tools.browser import BasePage, BrowserPasswordExpired
from weboob.tools.browser import Page, BrowserPasswordExpired
from weboob.tools.ordereddict import OrderedDict
from weboob.capabilities.bank import TransferError
......@@ -33,7 +33,7 @@ class Account(object):
self.receive_checkbox = receive_checkbox
class TransferPage(BasePage):
class TransferPage(Page):
def on_loaded(self):
for td in self.document.xpath('//td[@class="hdvon1"]'):
if td.text and 'Vous avez atteint le seuil de' in td.text:
......@@ -88,7 +88,7 @@ class TransferPage(BasePage):
self.browser.submit()
class TransferConfirmPage(BasePage):
class TransferConfirmPage(Page):
def on_loaded(self):
for td in self.document.getroot().cssselect('td#size2'):
raise TransferError(td.text.strip())
......@@ -100,6 +100,6 @@ class TransferConfirmPage(BasePage):
return
class TransferCompletePage(BasePage):
class TransferCompletePage(Page):
def get_id(self):
return self.group_dict['id']
......@@ -24,12 +24,12 @@ from decimal import Decimal, InvalidOperation
from weboob.capabilities import NotAvailable
from weboob.capabilities.bank import Account
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from .perso.transactions import Transaction
class ProAccountsList(BasePage):
class ProAccountsList(Page):
COL_LABEL = 1
COL_ID = 2
COL_BALANCE = 3
......@@ -77,7 +77,7 @@ class ProAccountsList(BasePage):
return accounts
class ProAccountHistory(BasePage):
class ProAccountHistory(Page):
COL_DATE = 0
COL_LABEL = 1
COL_DEBIT = -2
......
......@@ -22,7 +22,7 @@
from urlparse import urlparse
import re
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
......@@ -40,7 +40,7 @@ class Transaction(FrenchTransaction):
]
class AccountHistory(BasePage):
class AccountHistory(Page):
def get_operations(self):
for form in self.document.xpath('//form[@name="marques"]'):
for tr in form.xpath('.//tbody/tr'):
......
......@@ -22,11 +22,11 @@
from decimal import Decimal
from weboob.capabilities.bank import Account
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
class AccountsList(BasePage):
class AccountsList(Page):
def on_loaded(self):
pass
......
......@@ -21,7 +21,7 @@
import re
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
......@@ -33,7 +33,7 @@ class Transaction(FrenchTransaction):
]
class CardHistory(BasePage):
class CardHistory(Page):
def get_operations(self):
for form in self.document.xpath('//form[@name="marques"]'):
for tr in form.xpath('.//tbody/tr'):
......
......@@ -22,7 +22,7 @@ import re
import hashlib
import urllib
from weboob.tools.browser import BasePage, BrowserIncorrectPassword
from weboob.tools.browser import Page, BrowserIncorrectPassword
from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard
......@@ -73,7 +73,7 @@ class VirtKeyboard(MappedVirtKeyboard):
return hashlib.md5(s).hexdigest()
class LoginPage(BasePage):
class LoginPage(Page):
def on_loaded(self):
pass
# for td in self.document.getroot().cssselect('td.LibelleErreur'):
......@@ -97,6 +97,6 @@ class LoginPage(BasePage):
self.browser.location(form.attrib['action'], urllib.urlencode(args), no_login=True)
class UpdateInfoPage(BasePage):
class UpdateInfoPage(Page):
def on_loaded(self):
raise BrowserIncorrectPassword('Please update your login credentials')
......@@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BasePage, BrowserIncorrectPassword
from weboob.tools.browser import Page, BrowserIncorrectPassword
import urllib2
import re
......@@ -27,7 +27,7 @@ class BrowserAuthenticationCodeMaxLimit(BrowserIncorrectPassword):
pass
class AuthenticationPage(BasePage):
class AuthenticationPage(Page):
MAX_LIMIT = "vous avez atteint le nombre maximum "\
"d'utilisation de l'authentification forte."
......
......@@ -21,10 +21,10 @@
import re
from weboob.capabilities.messages import CantSendMessage
from weboob.tools.browser import BasePage
from weboob.tools.browser import Page
class ComposeFrame(BasePage):
class ComposeFrame(Page):
phone_regex = re.compile('^(\+33|0033|0)(6|7)(\d{8})$')
def post_message(self, message):
......@@ -37,14 +37,14 @@ class ComposeFrame(BasePage):