Use browser2 tools in get_recipients
This commit is contained in:
parent
913790c1a7
commit
cc1e587552
1 changed files with 25 additions and 27 deletions
|
|
@ -19,39 +19,37 @@
|
||||||
|
|
||||||
from weboob.capabilities.bank import Recipient, AccountNotFound, Transfer
|
from weboob.capabilities.bank import Recipient, AccountNotFound, Transfer
|
||||||
from weboob.tools.browser2.page import HTMLPage, LoggedPage, ListElement, ItemElement, method
|
from weboob.tools.browser2.page import HTMLPage, LoggedPage, ListElement, ItemElement, method
|
||||||
from weboob.tools.browser2.filters import CleanText, CleanDecimal
|
from weboob.tools.browser2.filters import CleanText, CleanDecimal, Attr, Format
|
||||||
from .login import INGVirtKeyboard
|
from .login import INGVirtKeyboard
|
||||||
|
|
||||||
__all__ = ['TransferPage']
|
__all__ = ['TransferPage']
|
||||||
|
|
||||||
|
|
||||||
class TransferPage(LoggedPage, HTMLPage):
|
class TransferPage(LoggedPage, HTMLPage):
|
||||||
def get_recipients(self):
|
|
||||||
# First, internals recipients
|
|
||||||
table = self.doc.xpath('//table[@id="transfer_form:receiptAccount"]')
|
|
||||||
for tr in table[0].xpath('tbody/tr'):
|
|
||||||
tds = tr.xpath('td')
|
|
||||||
id = tds[0].xpath('input')[0].attrib['value']
|
|
||||||
name = tds[0].xpath('label')[0].text
|
|
||||||
name += u" " + tds[1].xpath('label')[0].text.replace('\n', '')
|
|
||||||
name += u" " + tds[2].xpath('label')[0].text.replace('\n', '')
|
|
||||||
recipient = Recipient()
|
|
||||||
recipient.id = id
|
|
||||||
recipient.label = name
|
|
||||||
recipient._type = "int"
|
|
||||||
yield recipient
|
|
||||||
|
|
||||||
# Second, externals recipients
|
@method
|
||||||
select = self.doc.xpath('//select[@id="transfer_form:externalAccounts"]')
|
class get_recipients(ListElement):
|
||||||
if len(select) > 0:
|
class ExternalRecipients(ListElement):
|
||||||
recipients = select[0].xpath('option')
|
item_xpath = '//select[@id="transfer_form:externalAccounts"]/option'
|
||||||
recipients.pop(0)
|
|
||||||
for option in recipients:
|
class item(ItemElement):
|
||||||
recipient = Recipient()
|
klass = Recipient
|
||||||
recipient.id = option.attrib['value']
|
condition = lambda self: Attr('.', 'value')(self.el) != "na"
|
||||||
recipient.label = option.text
|
|
||||||
recipient._type = "ext"
|
obj_id = Attr('.', 'value')
|
||||||
yield recipient
|
obj_label = CleanText('.')
|
||||||
|
obj__type = 'ext'
|
||||||
|
|
||||||
|
class InternalRecipients(ListElement):
|
||||||
|
item_xpath = '//table[@id="transfer_form:receiptAccount"]/tbody/tr'
|
||||||
|
|
||||||
|
class item(ItemElement):
|
||||||
|
klass = Recipient
|
||||||
|
|
||||||
|
obj_id = Attr('td[1]/input', 'value')
|
||||||
|
obj_label = Format(u"%s %s %s", CleanText('td[1]/label'),
|
||||||
|
CleanText('td[2]/label'), CleanText('td[3]/label'))
|
||||||
|
obj__type = "int"
|
||||||
|
|
||||||
def ischecked(self, _id):
|
def ischecked(self, _id):
|
||||||
# remove prefix (CC-, LA-, ...)
|
# remove prefix (CC-, LA-, ...)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue