本文整理汇总了Python中weboob.capabilities.bank.Account类的典型用法代码示例。如果您正苦于以下问题:Python Account类的具体用法?Python Account怎么用?Python Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_accounts_list
def get_accounts_list(self):
#Parse CCP
compte_table = self.document.xpath("//table[@id='comptes']", smart_strings=False)[0]
compte_ligne = compte_table.xpath("./tbody/tr")
for compte in compte_ligne:
account = Account()
tp = compte.xpath("./td/a")[0]
account.label = tp.text
account.link_id = tp.get("href")
account.id = compte.xpath("./td")[1].text
account.balance = float(''.join( compte.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() ))
self.Account_List.append(account)
#Parse epargne
epargne_table = self.document.xpath("//table[@id='comptesEpargne']", smart_strings=False)[0]
epargne_ligne = epargne_table.xpath("./tbody/tr")
for epargne in epargne_ligne:
account = Account()
tp = epargne.xpath("./td/a")[0]
account.label = tp.text
account.link_id = tp.get("href")
account.id = epargne.xpath("./td")[1].text
account.balance = float(''.join( epargne.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() ) )
self.Account_List.append(account)
return self.Account_List
示例2: get_cards
def get_cards(self, account_id):
divs = self.doc.xpath('//div[@class="content-boxed"]')
assert len(divs)
msgs = re.compile(u'Vous avez fait opposition sur cette carte bancaire.' +
'|Votre carte bancaire a été envoyée.' +
'|BforBank a fait opposition sur votre carte' +
'|Pour des raisons de sécurité, la demande de réception du code confidentiel de votre carte par SMS est indisponible')
divs = [d for d in divs if not msgs.search(CleanText('.//div[has-class("alert")]', default='')(d))]
divs = [d.xpath('.//div[@class="m-card-infos"]')[0] for d in divs]
divs = [d for d in divs if not d.xpath('.//div[@class="m-card-infos-body-text"][text()="Débit immédiat"]')]
if not len(divs):
self.logger.warning('all cards are cancelled, acting as if there is no card')
return []
cards = []
for div in divs:
label = CleanText('.//div[@class="m-card-infos-body-title"]')(div)
number = CleanText('.//div[@class="m-card-infos-body-num"]', default='')(div)
number = re.sub('[^\d*]', '', number).replace('*', 'x')
debit = CleanText(u'.//div[@class="m-card-infos-body-text"][contains(text(),"Débit")]')(div)
assert debit == u'Débit différé', 'unrecognized card type %s: %s' % (number, debit)
card = Account()
card.id = '%s.%s' % (account_id, number)
card.label = label
card.number = number
card.type = Account.TYPE_CARD
cards.append(card)
return cards
示例3: get_accounts_list
def get_accounts_list(self):
for table in self.doc.xpath('//div[@class="comptestabl"]/table'):
try:
account_type = self.ACCOUNT_TYPES[table.get('summary').lower()]
if not account_type:
account_type = self.ACCOUNT_TYPES[table.xpath('./caption/text()')[0].strip().lower()]
except (IndexError,KeyError):
account_type = Account.TYPE_UNKNOWN
for tr in table.xpath('./tbody/tr'):
cols = tr.findall('td')
link = cols[0].find('a')
if link is None:
continue
a = Account()
a.type = account_type
a.id = unicode(re.search('([A-Z\d]{4}[A-Z\d\*]{3}[A-Z\d]{4})', link.attrib['title']).group(1))
a.label = unicode(link.attrib['title'].replace('%s ' % a.id, ''))
tmp_balance = CleanText(None).filter(cols[1])
a.currency = a.get_currency(tmp_balance)
if not a.currency:
a.currency = u'EUR'
a.balance = Decimal(Transaction.clean_amount(tmp_balance))
a._has_cards = False
a.url = urljoin(self.url, link.attrib['href'])
yield a
示例4: get_list
def get_list(self):
account_type = Account.TYPE_UNKNOWN
accounts = []
for tr in self.document.xpath('//table[@class="ecli"]/tr'):
if tr.attrib.get('class', '') == 'entete':
account_type = self.ACCOUNT_TYPES.get(tr.find('th').text.strip(), Account.TYPE_UNKNOWN)
continue
tds = tr.findall('td')
balance = tds[-1].text.strip()
if balance == '':
continue
account = Account()
account.label = u' '.join([txt.strip() for txt in tds[0].itertext()])
account.label = re.sub(u'[ \xa0\u2022\r\n\t]+', u' ', account.label).strip()
account.id = re.findall('(\d+)', account.label)[0]
account.balance = Decimal(FrenchTransaction.clean_amount(balance))
account.currency = account.get_currency(balance)
account.type = account_type
m = re.search(r"javascript:submitForm\(([\w_]+),'([^']+)'\);", tds[0].find('a').attrib['onclick'])
if not m:
self.logger.warning('Unable to find link for %r' % account.label)
account._link = None
else:
account._link = m.group(2)
accounts.append(account)
return accounts
示例5: account
def account(self):
label = u' '.join(self.doc.xpath(
'//div[contains(@class,"myCreditCardDetails")]')[0]\
.text_content().split())
balance = self.amount(u'Balance')
cardlimit = self.doc.xpath(
u'//li[text()="Available to Spend"]')[0].text_content()\
.replace(u'Available to Spend', u'').replace(u'Limit', u'').strip()
paymin = self.amount(u'Payment Due')
if self.doc.xpath(u'//li[@class="noPaymentDue"]'):
# If payment date is not scheduled yet, set it somewhere in a
# distant future, so that we always have a valid date.
paydate = datetime.now() + timedelta(days=999)
else:
rawtext = self.doc.xpath(
u'//li[contains(text(),"Due Date")]')[0].text_content()
datetext = re.match('.*(\d\d/\d\d/\d\d\d\d).*', rawtext).group(1)
paydate = datetime.strptime(datetext, '%m/%d/%Y')
a = Account()
a.id = label[-4:]
a.label = label
a.currency = Account.get_currency(balance)
a.balance = -AmTr.decimal_amount(balance)
a.type = Account.TYPE_CARD
a.cardlimit = AmTr.decimal_amount(cardlimit)
a.paymin = AmTr.decimal_amount(paymin)
if paydate is not None:
a.paydate = paydate
return a
示例6: _add_account
def _add_account(self, accounts, link, label, account_type, balance):
info = self._get_account_info(link)
if info is None:
self.logger.warning('Unable to parse account %r: %r' % (label, link))
return
account = Account()
account.id = info['id']
account.iban = u'FR76' + info['id']
account._info = info
account.label = label
account.type = info['acc_type'] if 'acc_type' in info else account_type
account.balance = Decimal(FrenchTransaction.clean_amount(balance)) if balance else self.get_balance(account)
account.currency = account.get_currency(balance)
account._card_links = []
if account._info['type'] == 'HISTORIQUE_CB' and account.id in accounts:
a = accounts[account.id]
if not a.coming:
a.coming = Decimal('0.0')
a.coming += account.balance
a._card_links.append(account._info)
return
accounts[account.id] = account
示例7: parse_table
def parse_table(self, what):
tables = self.document.xpath("//table[@id='%s']" % what, smart_strings=False)
if len(tables) < 1:
return
lines = tables[0].xpath(".//tbody/tr")
for line in lines:
account = Account()
tmp = line.xpath("./td//a")[0]
account.label = to_unicode(tmp.text)
account._link_id = tmp.get("href")
if "BourseEnLigne" in account._link_id:
continue
tmp = line.xpath("./td/span/strong")
if len(tmp) >= 2:
tmp_id = tmp[0].text
tmp_balance = tmp[1].text
else:
tmp_id = line.xpath("./td//span")[1].text
tmp_balance = tmp[0].text
account.id = tmp_id
account.balance = Decimal("".join(tmp_balance.replace(".", "").replace(",", ".").split()))
self.account_list.append(account)
示例8: _add_account
def _add_account(self, accounts, link, label, account_type, balance):
info = self._get_account_info(link, accounts)
if info is None:
self.logger.warning('Unable to parse account %r: %r' % (label, link))
return
account = Account()
account.id = info['id']
if is_rib_valid(info['id']):
account.iban = rib2iban(info['id'])
account._info = info
account.label = label
account.type = self.ACCOUNT_TYPES.get(label, info['acc_type'] if 'acc_type' in info else account_type)
balance = balance or self.get_balance(account)
account.balance = Decimal(FrenchTransaction.clean_amount(balance)) if balance and balance is not NotAvailable else NotAvailable
account.currency = account.get_currency(balance) if balance and balance is not NotAvailable else NotAvailable
account._card_links = []
if account._info['type'] == 'HISTORIQUE_CB' and account.id in accounts:
a = accounts[account.id]
if not a.coming:
a.coming = Decimal('0.0')
if account.balance and account.balance is not NotAvailable:
a.coming += account.balance
a._card_links.append(account._info)
return
accounts[account.id] = account
示例9: get_accounts_list
def get_accounts_list(self):
balance = self.index.stay_or_go().get_balance()
account = Account()
account.id = self.username
account.label = u'Carte Oney'
account.balance = balance
account.currency = u'EUR'
return [account]
示例10: get_list
def get_list(self):
for line in self.document.xpath('//li[@id="menu-n2-mesproduits"]//li//a'):
if line.get('onclick') is None:
continue
account = Account()
account.id = line.get('onclick').split("'")[1]
account.label = self.parser.tocleanstring(line)
yield account
示例11: get_accounts_list
def get_accounts_list(self):
self.location("%s://%s/summarySearch.do?reqCode=search" % (self.PROTOCOL, self.DOMAIN))
account = Account()
account.id = u"1"
account.currency = Account.CUR_EUR
account.balance = self.page.get_balance()
account.label = u"Synthèse financière"
return [account]
示例12: get_list
def get_list(self):
l = []
ids = set()
for a in self.document.getiterator('a'):
link=a.attrib.get('href')
if link is None:
continue
if link.startswith("/outil/UWLM/ListeMouvements"):
account = Account()
#by default the website propose the last 7 days or last 45 days but we can force to have the last 55days
account._link_id=link+"&mode=55"
account._coming_links = []
parameters=link.split("?").pop().split("&")
for parameter in parameters:
list=parameter.split("=")
value=list.pop()
name=list.pop()
if name=="agence":
account.id=value
elif name=="compte":
account.id+=value
elif name=="nature":
# TODO parse this string to get the right Account.TYPE_* to
# store in account.type.
account._type=value
if account.id in ids:
continue
ids.add(account.id)
div = a.getparent().getprevious()
if not div.text.strip():
div = div.find('div')
account.label=u''+div.text.strip()
balance = FrenchTransaction.clean_amount(a.text)
if '-' in balance:
balance='-'+balance.replace('-', '')
account.balance=Decimal(balance)
account.currency = account.get_currency(a.text)
self.logger.debug('%s Type: %s' % (account.label, account._type))
l.append(account)
if link.startswith('/outil/UWCB/UWCBEncours'):
if len(l) == 0:
self.logger.warning('There is a card account but not any check account')
continue
account = l[-1]
coming = FrenchTransaction.clean_amount(a.text)
if '-' in coming:
coming = '-'+coming.replace('-', '')
if not account.coming:
account.coming = Decimal('0')
account.coming += Decimal(coming)
account._coming_links.append(link)
return l
示例13: get_list
def get_list(self):
for table in self.document.getroot().cssselect('div#table-panorama table.table-produit'):
tds = table.xpath('./tbody/tr')[0].findall('td')
if len(tds) < 3:
continue
boxes = table.xpath('./tbody//tr')
foot = table.xpath('./tfoot//tr')
for box in boxes:
account = Account()
if len(box.xpath('.//a')) != 0 and 'onclick' in box.xpath('.//a')[0].attrib:
args = self.js2args(box.xpath('.//a')[0].attrib['onclick'])
account.label = u'{0} {1}'.format(unicode(table.xpath('./caption')[0].text.strip()), unicode(box.xpath('.//a')[0].text.strip()))
elif len(foot[0].xpath('.//a')) != 0 and 'onclick' in foot[0].xpath('.//a')[0].attrib:
args = self.js2args(foot[0].xpath('.//a')[0].attrib['onclick'])
account.label = unicode(table.xpath('./caption')[0].text.strip())
else:
continue
self.logger.debug('Args: %r' % args)
if 'paramNumCompte' not in args:
try:
label = unicode(table.xpath('./caption')[0].text.strip())
except Exception:
label = 'Unable to determine'
self.logger.warning('Unable to get account ID for %r' % label)
continue
try:
account.id = args['paramNumCompte'] + args['paramNumContrat']
if 'Visa' in account.label:
card_id = re.search('(\d+)', box.xpath('./td[2]')[0].text.strip())
if card_id:
account.id += card_id.group(1)
if 'Valorisation' in account.label or u'Liquidités' in account.label:
account.id += args['idPanorama:_idcl'].split('Jsp')[-1]
except KeyError:
account.id = args['paramNumCompte']
account_type_str = table.attrib['class'].split(' ')[-1][len('tableaux-comptes-'):]
account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
currency_title = table.xpath('./thead//th[@class="montant"]')[0].text.strip()
m = re.match('Montant \((\w+)\)', currency_title)
if not m:
self.logger.warning('Unable to parse currency %r' % currency_title)
else:
account.currency = account.get_currency(m.group(1))
try:
account.balance = Decimal(FrenchTransaction.clean_amount(self.parse_number(u''.join([txt.strip() for txt in box.cssselect("td.montant")[0].itertext()]))))
except InvalidOperation:
#The account doesn't have a amount
pass
account._args = args
yield account
示例14: get_list
def get_list(self):
l = []
for cpt in self.document.xpath(".//*[@class='synthese_id_compte']"):
account = Account()
# account.id
account.id = (
cpt.xpath("./span[1]/text()")[0]
.replace(u"\xa0", "")
.replace(",", ".")
.replace("EUR", "")
.replace("\n", "")
.replace("\t", "")
.replace(u"\xb0", "")
.replace(" ", "")
.replace("N", "")
)
# account balance
account.balance = Decimal(
cpt.xpath("./span[2]/text()")[0]
.replace("+", "")
.replace(u"\xa0", "")
.replace(",", ".")
.replace("EUR", "")
.replace("\n", "")
.replace("\t", "")
.replace(" ", "")
)
# account coming TODO
# mycomingval = cpt.xpath("../../following-sibling::*[1]/td[2]/a[@class='lien_synthese_encours']/span/text()")[0].replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xa0", "")
# mycomingval = cpt.xpath("../../following-sibling::*[1]/td[2]")[0]
# mycomingval = cpt.xpath("./../../../a[@class='lien_synthese_encours']/span[@class='synthese_encours']/text()")[0].replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xa0", "")
# if mycomingval == '-':
# account.coming = Decimal(0)
# else:
# account.coming = Decimal(mycomingval)
# account._link_id
url_to_parse = cpt.xpath("@href")[0].replace("\n", "") # link
compte_id_re = re.compile(r"/prive/mes-comptes/([^/]+/).*COMPTE_ACTIF=([^\&]+)\&?")
account._link_id = "/fr/prive/mes-comptes/%sconsulter-situation/consulter-solde.jsp?COMPTE_ACTIF=%s" % (
compte_id_re.search(url_to_parse).groups()[0],
compte_id_re.search(url_to_parse).groups()[1],
)
# account.label
temp_label = cpt.xpath("./text()")[1].replace(u"-\xa0", "").replace("\n", "").replace("\t", "")
account.label = " ".join(temp_label.split(" ")[:2])
l.append(account)
return l
示例15: _parse_account
def _parse_account(self, tr):
account = Account()
account.id = tr.xpath('.//td[@class="libelleCompte"]/input')[0].attrib['id'][len('libelleCompte'):]
if len(str(account.id)) == 23:
account.id = str(account.id)[5:21]
a = tr.xpath('.//td[@class="libelleCompte"]/a')[0]
m = re.match(r'javascript:goToStatements\(\'(\d+)\'', a.get('onclick', ''))
if m:
account._link_id = m.group(1)
else:
# Can't get history for this account.
account._link_id = None
# To prevent multiple-IDs for CIF (for example), add an arbitrary char in ID.
account.id += 'C'
account.label = u''+a.text.strip()
tds = tr.findall('td')
account.balance = self._parse_amount(tds[3].find('a'))
if tds[4].find('a') is not None:
account.coming = self._parse_amount(tds[4].find('a'))
else:
account.coming = NotAvailable
return account