当前位置: 首页>>代码示例>>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;未经允许,请勿转载。