sgpe: Support pagination
This commit is contained in:
parent
888230f7e2
commit
d3f9ce1fe2
2 changed files with 26 additions and 6 deletions
|
|
@ -68,8 +68,12 @@ class SGPEBrowser(BaseBrowser):
|
||||||
def accounts(self):
|
def accounts(self):
|
||||||
self.location('/Pgn/NavigationServlet?PageID=SoldeV3&MenuID=%s&Classeur=1&NumeroPage=1' % self.MENUID)
|
self.location('/Pgn/NavigationServlet?PageID=SoldeV3&MenuID=%s&Classeur=1&NumeroPage=1' % self.MENUID)
|
||||||
|
|
||||||
def history(self, _id):
|
def history(self, _id, page=1):
|
||||||
self.location('/Pgn/NavigationServlet?PageID=ReleveCompteV3&MenuID=%s&Classeur=1&Rib=%s&NumeroPage=1' % (self.MENUID, _id))
|
if page > 1:
|
||||||
|
pgadd = '&page_numero_page_courante=%s' % page
|
||||||
|
else:
|
||||||
|
pgadd = ''
|
||||||
|
self.location('/Pgn/NavigationServlet?PageID=ReleveCompteV3&MenuID=%s&Classeur=1&Rib=%s&NumeroPage=1%s' % (self.MENUID, _id, pgadd))
|
||||||
|
|
||||||
def get_accounts_list(self):
|
def get_accounts_list(self):
|
||||||
if not self.is_on_page(AccountsPage):
|
if not self.is_on_page(AccountsPage):
|
||||||
|
|
@ -83,10 +87,16 @@ class SGPEBrowser(BaseBrowser):
|
||||||
yield a
|
yield a
|
||||||
|
|
||||||
def iter_history(self, account):
|
def iter_history(self, account):
|
||||||
self.history(account.id)
|
page = 1
|
||||||
assert self.is_on_page(HistoryPage)
|
while page:
|
||||||
for transaction in self.page.iter_transactions(account):
|
self.history(account.id, page)
|
||||||
yield transaction
|
assert self.is_on_page(HistoryPage)
|
||||||
|
for transaction in self.page.iter_transactions(account):
|
||||||
|
yield transaction
|
||||||
|
if self.page.has_next():
|
||||||
|
page += 1
|
||||||
|
else:
|
||||||
|
page = False
|
||||||
|
|
||||||
|
|
||||||
class SGProfessionalBrowser(SGPEBrowser):
|
class SGProfessionalBrowser(SGPEBrowser):
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,9 @@ class HistoryPage(SGPEPage):
|
||||||
def iter_transactions(self, account):
|
def iter_transactions(self, account):
|
||||||
table = self.parser.select(self.document.getroot(), '#tab-corps', 1)
|
table = self.parser.select(self.document.getroot(), '#tab-corps', 1)
|
||||||
for i, tr in enumerate(self.parser.select(table, 'tr', 'many')):
|
for i, tr in enumerate(self.parser.select(table, 'tr', 'many')):
|
||||||
|
# td colspan=5
|
||||||
|
if len(self.parser.select(tr, 'td')) == 1:
|
||||||
|
continue
|
||||||
tddate, tdlabel, tddebit, tdcredit, tdval, tdbal = [td.text_content().strip()
|
tddate, tdlabel, tddebit, tdcredit, tdval, tdbal = [td.text_content().strip()
|
||||||
for td
|
for td
|
||||||
in self.parser.select(tr, 'td', 4)]
|
in self.parser.select(tr, 'td', 4)]
|
||||||
|
|
@ -129,3 +132,10 @@ class HistoryPage(SGPEPage):
|
||||||
t.parse(date, l1 + ' ' + l2)
|
t.parse(date, l1 + ' ' + l2)
|
||||||
t._val = val # FIXME is it rdate? date?
|
t._val = val # FIXME is it rdate? date?
|
||||||
yield t
|
yield t
|
||||||
|
|
||||||
|
def has_next(self):
|
||||||
|
for n in self.parser.select(self.document.getroot(), '#numPageBloc'):
|
||||||
|
cur = int(self.parser.select(n, '#numPage', 1).value)
|
||||||
|
for end in self.parser.select(n, '.contenu3-lien'):
|
||||||
|
return int(end.text.replace('/', '')) > cur
|
||||||
|
return False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue