當前位置: 首頁>>代碼示例>>Python>>正文


Python Transaction.clean_amount方法代碼示例

本文整理匯總了Python中weboob.capabilities.bank.Transaction.clean_amount方法的典型用法代碼示例。如果您正苦於以下問題:Python Transaction.clean_amount方法的具體用法?Python Transaction.clean_amount怎麽用?Python Transaction.clean_amount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在weboob.capabilities.bank.Transaction的用法示例。


在下文中一共展示了Transaction.clean_amount方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_transactions

# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import clean_amount [as 別名]
    def get_transactions(self):
        table = self.document.findall('//tbody')[0]
        for tr in table.xpath('tr'):
            textdate = tr.find('td[@class="op_date"]').text_content()
            textraw = tr.find('td[@class="op_label"]').text_content().strip()
            # The id will be rewrite
            op = Transaction(1)
            amount = op.clean_amount(tr.find('td[@class="op_amount"]').text_content())
            id = hashlib.md5(textdate + textraw.encode('utf-8') + amount.encode('utf-8')).hexdigest()
            op.id = id
            op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])),
                     raw = textraw)
            # force the use of website category
            op.category = unicode(tr.find('td[@class="op_type"]').text)

            op.amount = Decimal(amount)

            yield op
開發者ID:eirmag,項目名稱:weboob,代碼行數:20,代碼來源:account_history.py

示例2: get_transactions

# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import clean_amount [as 別名]
 def get_transactions(self, index):
     i = 0
     for table in self.document.xpath('//table'):
         try:
             textdate = table.find('.//td[@class="date"]').text_content()
         except AttributeError:
             continue
         # Do not parse transactions already parsed
         if i < index:
             i += 1
             continue
         if textdate == 'hier':
             textdate = (date.today() - timedelta(days=1)).strftime('%d/%m/%Y')
         elif textdate == "aujourd'hui":
             textdate = date.today().strftime('%d/%m/%Y')
         else:
             frenchmonth = textdate.split(' ')[1]
             month = self.monthvalue[frenchmonth]
             textdate = textdate.replace(' ', '')
             textdate = textdate.replace(frenchmonth, '/%s/' %month)
         # We use lower for compatibility with old website
         textraw = table.find('.//td[@class="lbl"]').text_content().strip().lower()
         # The id will be rewrite
         op = Transaction(1)
         amount = op.clean_amount(table.xpath('.//td[starts-with(@class, "amount")]')[0].text_content())
         id = hashlib.md5(textdate.encode('utf-8') + textraw.encode('utf-8')
                 + amount.encode('utf-8')).hexdigest()
         op.id = id
         op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])),
                 raw = textraw)
         category = table.find('.//td[@class="picto"]/span')
         category = unicode(category.attrib['class'].split('-')[0].lower())
         try:
             op.category = self.catvalue[category]
         except:
             op.category = category
         op.amount = Decimal(amount)
         yield op
開發者ID:blckshrk,項目名稱:Weboob,代碼行數:40,代碼來源:accounts_list.py


注:本文中的weboob.capabilities.bank.Transaction.clean_amount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。