本文整理汇总了Python中weboob.tools.capabilities.bank.transactions.FrenchTransaction类的典型用法代码示例。如果您正苦于以下问题:Python FrenchTransaction类的具体用法?Python FrenchTransaction怎么用?Python FrenchTransaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrenchTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_loan_list
def get_loan_list(self):
accounts = OrderedDict()
# Old website
for tr in self.doc.xpath('//table[@cellpadding="1"]/tr[not(@class) and td[a]]'):
tds = tr.findall('td')
account = Account()
account.id = CleanText('./a')(tds[2]).split('-')[0].strip()
account.label = CleanText('./a')(tds[2]).split('-')[-1].strip()
account.type = Account.TYPE_LOAN
account.balance = -CleanDecimal('./a', replace_dots=True)(tds[4])
account.currency = account.get_currency(CleanText('./a')(tds[4]))
accounts[account.id] = account
if len(accounts) == 0:
# New website
for table in self.doc.xpath('//div[@class="panel"]'):
title = table.getprevious()
if title is None:
continue
account_type = self.ACCOUNT_TYPES.get(CleanText('.')(title), Account.TYPE_UNKNOWN)
for tr in table.xpath('./table/tbody/tr[contains(@id,"MM_SYNTHESE_CREDITS") and contains(@id,"IdTrGlobal")]'):
tds = tr.findall('td')
if len(tds) == 0 :
continue
for i in tds[0].xpath('.//a/strong'):
label = i.text.strip()
break
if len(tds) == 3 and Decimal(FrenchTransaction.clean_amount(CleanText('.')(tds[-2]))) and any(cls in Attr('.', 'id')(tr) for cls in ['dgImmo', 'dgConso']) == False:
# in case of Consumer credit or revolving credit, we substract avalaible amount with max amout
# to get what was spend
balance = Decimal(FrenchTransaction.clean_amount(CleanText('.')(tds[-2]))) - Decimal(FrenchTransaction.clean_amount(CleanText('.')(tds[-1])))
else:
balance = Decimal(FrenchTransaction.clean_amount(CleanText('.')(tds[-1])))
account = Loan()
account.id = label.split(' ')[-1]
account.label = unicode(label)
account.type = account_type
account.balance = -abs(balance)
account.currency = account.get_currency(CleanText('.')(tds[-1]))
account._card_links = []
if "immobiliers" in CleanText('.')(title):
xp = './/div[contains(@id, "IdDivDetail")]/table/tbody/tr[contains(@id, "%s")]/td'
account.maturity_date = Date(CleanText(xp % 'IdDerniereEcheance'), dayfirst=True, default=NotAvailable)(tr)
account.total_amount = CleanDecimal(CleanText(xp % 'IdCapitalEmprunte'), replace_dots=True, default=NotAvailable)(tr)
account.subscription_date = Date(CleanText(xp % 'IdDateOuverture'), dayfirst=True, default=NotAvailable)(tr)
account.next_payment_date = Date(CleanText(xp % 'IdDateProchaineEcheance'), dayfirst=True, default=NotAvailable)(tr)
account.rate = CleanDecimal(CleanText(xp % 'IdTaux'), replace_dots=True, default=NotAvailable)(tr)
account.next_payment_amount = CleanDecimal(CleanText(xp % 'IdMontantEcheance'), replace_dots=True, default=NotAvailable)(tr)
elif "renouvelables" in CleanText('.')(title):
self.go_loans_conso(tr)
d = self.browser.loans_conso()
if d:
account.total_amount = d['contrat']['creditMaxAutorise']
account.available_amount = d['situationCredit']['disponible']
account.next_payment_amount = d['situationCredit']['mensualiteEnCours']
accounts[account.id] = account
return accounts.values()
示例2: parse_decimal
def parse_decimal(self, td, percentage=False):
value = CleanText('.')(td)
if value and value != '-':
if percentage:
return Decimal(FrenchTransaction.clean_amount(value)) / 100
return Decimal(FrenchTransaction.clean_amount(value))
else:
return NotAvailable
示例3: 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
示例4: iter_investments
def iter_investments(self):
# We did not get some html, but something like that (XX is a quantity, YY a price):
# message='[...]
# popup=2{6{E:ALO{PAR{{reel{695{380{ALSTOM REGROUPT#XX#YY,YY €#YY,YY €#1 YYY,YY €#-YYY,YY €#-42,42%#-0,98 %#42,42 %#|1|AXA#cotationValeur.php?val=E:CS&pl=6&nc=1&
# popup=2{6{E:CS{PAR{{reel{695{380{AXA#XX#YY,YY €#YY,YYY €#YYY,YY €#YY,YY €#3,70%#42,42 %#42,42 %#|1|blablablab #cotationValeur.php?val=P:CODE&pl=6&nc=1&
# [...]
lines = self.doc.split("popup=2")
lines.pop(0)
invests = []
for line in lines:
columns = line.split('#')
_pl = columns[0].split('{')[1]
_id = columns[0].split('{')[2]
invest = Investment(_id)
invest.label = unicode(columns[0].split('{')[-1])
invest.code = unicode(_id)
if ':' in invest.code:
invest.code = self.browser.titrevalue.open(val=invest.code,pl=_pl).get_isin()
# The code we got is not a real ISIN code.
if not re.match('^[A-Z]{2}[\d]{10}$|^[A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4}$', invest.code):
m = re.search('\{([A-Z]{2}[\d]{10})\{|\{([A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4})\{', line)
if m:
invest.code = unicode(m.group(1) or m.group(2))
quantity = FrenchTransaction.clean_amount(columns[1])
invest.quantity = CleanDecimal(default=NotAvailable).filter(quantity)
unitprice = FrenchTransaction.clean_amount(columns[2])
invest.unitprice = CleanDecimal(default=NotAvailable).filter(unitprice)
unitvalue = FrenchTransaction.clean_amount(columns[3])
invest.unitvalue = CleanDecimal(default=NotAvailable).filter(unitvalue)
valuation = FrenchTransaction.clean_amount(columns[4])
# valuation is not nullable, use 0 as default value
invest.valuation = CleanDecimal(default=Decimal('0')).filter(valuation)
diff = FrenchTransaction.clean_amount(columns[5])
invest.diff = CleanDecimal(default=NotAvailable).filter(diff)
# On some case we have a multine investment with a total column
# for now we have only see this on 2 lines, we will need to adapt it when o
if columns[9] == u'|Total' and _id == 'fichevaleur':
prev_inv = invest
invest = invests.pop(-1)
if prev_inv.quantity:
invest.quantity = invest.quantity + prev_inv.quantity
if prev_inv.valuation:
invest.valuation = invest.valuation + prev_inv.valuation
if prev_inv.diff:
invest.diff = invest.diff + prev_inv.diff
invests.append(invest)
for invest in invests:
yield invest
示例5: get_funding_src
def get_funding_src(self, t):
if 'fundingSource' not in self.doc['data']['details']:
return None
funding_src_lst = [src for src in self.doc['data']['details']['fundingSource']['fundingSourceList'] if src['type'] != 'BALANCE']
assert len(funding_src_lst) <= 1
for src in funding_src_lst:
tr = FrenchTransaction(t.id+'_fundingSrc')
tr.amount = CleanDecimal(replace_dots=True).filter(src['amount'])
tr.date = tr.rdate = t.date
tr.label = tr.raw = u'Crédit depuis %s' % src['institution']
return tr
示例6: get_monthly_transactions
def get_monthly_transactions(self, trs):
groups = [list(g) for k, g in groupby(sorted(trs, key=lambda tr: tr.date), lambda tr: tr.date)]
trs = []
for group in groups:
if group[0].date > date.today():
continue
tr = FrenchTransaction()
tr.raw = tr.label = u"RELEVE CARTE %s" % group[0].date
tr.amount = -sum([t.amount for t in group])
tr.date = tr.rdate = tr.vdate = group[0].date
tr.type = FrenchTransaction.TYPE_CARD_SUMMARY
trs.append(tr)
return trs
示例7: iter_investments
def iter_investments(self):
# We did not get some html, but something like that (XX is a quantity, YY a price):
# message='[...]
# popup=2{6{E:ALO{PAR{{reel{695{380{ALSTOM REGROUPT#XX#YY,YY €#YY,YY €#1 YYY,YY €#-YYY,YY €#-42,42%#-0,98 %#42,42 %#|1|AXA#cotationValeur.php?val=E:CS&pl=6&nc=1&
# popup=2{6{E:CS{PAR{{reel{695{380{AXA#XX#YY,YY €#YY,YYY €#YYY,YY €#YY,YY €#3,70%#42,42 %#42,42 %#|1|blablablab #cotationValeur.php?val=P:CODE&pl=6&nc=1&
# [...]
lines = self.doc.split("popup=2")
lines.pop(0)
for line in lines:
columns = line.split('#')
_pl = columns[0].split('{')[1]
_id = columns[0].split('{')[2]
invest = Investment(_id)
invest.label = unicode(columns[0].split('{')[-1])
invest.code = unicode(_id)
if ':' in invest.code:
invest.code = self.browser.titrevalue.open(val=invest.code,pl=_pl).get_isin()
# The code we got is not a real ISIN code.
if not re.match('^[A-Z]{2}[\d]{10}$|^[A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4}$', invest.code):
m = re.search('\{([A-Z]{2}[\d]{10})\{|\{([A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4})\{', line)
if m:
invest.code = unicode(m.group(1) or m.group(2))
quantity = FrenchTransaction.clean_amount(columns[1])
if quantity != '':
invest.quantity = Decimal(quantity)
else:
invest.quantity = NotAvailable
unitprice = FrenchTransaction.clean_amount(columns[2])
if unitprice != '':
invest.unitprice = Decimal(unitprice)
else:
invest.unitprice = NotAvailable
unitvalue = FrenchTransaction.clean_amount(columns[3])
if unitvalue != '':
invest.unitvalue = Decimal(unitvalue)
else:
invest.unitvalue = NotAvailable
valuation = FrenchTransaction.clean_amount(columns[4])
if valuation != '':
invest.valuation = Decimal(valuation)
else:
# valuation is not nullable.
invest.valuation = Decimal('0')
diff = FrenchTransaction.clean_amount(columns[5])
if diff != '':
invest.diff = Decimal(diff)
else:
invest.diff = NotAvailable
yield invest
示例8: get_list
def get_list(self):
l = []
divabo = self.document.xpath('//div[@id="accountSummary"]')[0]
owner = divabo.xpath('a/h3')[0].text
phone = divabo.xpath('dl/dd')[0].text
credit = divabo.xpath('dl/dd')[1].text
expiredate = divabo.xpath('dl/dd')[2].text
phoneplan = divabo.xpath('dl/dd')[3].text
self.browser.logger.debug('Found ' + owner + ' as subscriber')
self.browser.logger.debug('Found ' + phone + ' as phone number')
self.browser.logger.debug('Found ' + credit + ' as available credit')
self.browser.logger.debug('Found ' + expiredate + ' as expire date ')
self.browser.logger.debug('Found %s as subscription type', phoneplan)
subscription = Subscription(phone)
subscription.label = unicode(u'%s - %s - %s - %s' %
(phone, credit, phoneplan, expiredate))
subscription.subscriber = unicode(owner)
expiredate = date(*reversed([int(x) for x in expiredate.split(".")]))
subscription.validity = expiredate
subscription._balance = Decimal(FrenchTransaction.clean_amount(credit))
l.append(subscription)
return l
示例9: 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.currency = account.get_currency(tmp_balance)
account.balance = Decimal(FrenchTransaction.clean_amount(tmp_balance))
if account.id in self.accounts:
a = self.accounts[account.id]
a._card_links.append(account._link_id)
if not a.coming:
a.coming = Decimal("0.0")
a.coming += account.balance
else:
account._card_links = []
self.accounts[account.id] = account
示例10: _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
示例11: _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
示例12: 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
示例13: get_list
def get_list(self):
div = self.document.xpath('//div[@id="descriptifdroite"]')[0]
account = Account()
account.id = re.search(u'(\d+)', div.xpath('.//div[@class="credithauttexte"]')[0].text).group(1)
account.label = u'Carte PASS'
account.balance = Decimal('0')
for tr in div.xpath('.//table/tr'):
tds = tr.findall('td')
if len(tds) < 3:
continue
label = u''.join([txt.strip() for txt in tds[1].itertext()])
value = u''.join([txt.strip() for txt in tds[2].itertext()])
if 'encours depuis le dernier' in label.lower():
coming = u'-' + value
account.coming = Decimal(FrenchTransaction.clean_amount(coming))
account.currency = account.get_currency(coming)
elif u'arrêté de compte' in label.lower():
m = re.search(u'(\d+)/(\d+)/(\d+)', label)
if m:
account._outstanding_date = datetime.date(*reversed(map(int, m.groups())))
break
yield account
示例14: iter_bills
def iter_bills(self, sub):
#pdb.set_trace()
years = [None] + self.document.xpath('//ul[@class="years"]/li/a')
for year in years:
#pdb.set_trace()
if year is not None and year.attrib['href']:
self.browser.location(year.attrib['href'])
tables = self.browser.page.document.xpath('//table[contains(@summary, "factures")]')
for table in tables:
for tr in table.xpath('.//tr'):
list_tds = tr.xpath('.//td')
if len(list_tds) == 0:
continue
url = re.sub('[\r\n\t]', '', list_tds[0].xpath('.//a')[0].attrib['href'])
date_search = re.search('dateFactureQE=(\d+/\d+/\d+)', url)
if not date_search:
continue
date = datetime.strptime(date_search.group(1), "%d/%m/%Y").date()
amount = self.parser.tocleanstring(list_tds[2])
if amount is None:
continue
bill = Bill()
bill.id = sub._id + "." + date.strftime("%Y%m%d")
bill.price = Decimal(FrenchTransaction.clean_amount(amount))
bill.currency = bill.get_currency(amount)
bill.date = date
bill.label = self.parser.tocleanstring(list_tds[0])
bill.format = u'pdf'
bill._url = url
yield bill
示例15: get_list
def get_list(self):
accounts = []
previous_account = None
noaccounts = self.get_from_js('_js_noMvts =', ';')
if noaccounts is not None:
assert 'avez aucun compte' in noaccounts
return []
txt = self.get_from_js('_data = new Array(', ');', is_list=True)
if txt is None:
raise BrowserUnavailable('Unable to find accounts list in scripts')
data = json.loads('[%s]' % txt.replace("'", '"'))
for line in data:
a = Account()
a.id = line[self.COL_ID].replace(' ', '')
if re.match(r'Classement=(.*?):::Banque=(.*?):::Agence=(.*?):::SScompte=(.*?):::Serie=(.*)', a.id):
a.id = str(CleanDecimal().filter(a.id))
a._acc_nb = a.id.split('_')[0] if len(a.id.split('_')) > 1 else None
a.label = MyStrip(line[self.COL_LABEL], xpath='.//div[@class="libelleCompteTDB"]')
# This account can be multiple life insurance accounts
if a.label == 'ASSURANCE VIE-BON CAPI-SCPI-DIVERS *':
continue
a.balance = Decimal(FrenchTransaction.clean_amount(line[self.COL_BALANCE]))
a.currency = a.get_currency(line[self.COL_BALANCE])
a.type = self.get_account_type(a.label)
# The parent account must be created right before
if a.type == Account.TYPE_CARD:
# duplicate
if find_object(accounts, id=a.id):
self.logger.warning('Ignoring duplicate card %r', a.id)
continue
a.parent = previous_account
if line[self.COL_HISTORY] == 'true':
a._inv = False
a._link = self.get_history_link()
a._args = self.make__args_dict(line)
else:
a._inv = True
a._args = {'_ipc_eventValue': line[self.COL_ID],
'_ipc_fireEvent': line[self.COL_FIRE_EVENT],
}
a._link = self.doc.xpath('//form[@name="changePageForm"]')[0].attrib['action']
if a.type is Account.TYPE_CARD:
a.coming = a.balance
a.balance = Decimal('0.0')
accounts.append(a)
previous_account = a
return accounts