add TransactionsElement and TransactionElement

This commit is contained in:
Romain Bignon 2014-03-12 08:42:03 +01:00
commit 75f17333a2

View file

@ -27,13 +27,20 @@ from weboob.capabilities import NotAvailable, NotLoaded
from weboob.tools.misc import to_unicode from weboob.tools.misc import to_unicode
from weboob.tools.log import getLogger from weboob.tools.log import getLogger
from weboob.tools.browser2.page import TableElement from weboob.tools.browser2.page import TableElement, ItemElement
from weboob.tools.browser2.filters import Filter, CleanText, CleanDecimal from weboob.tools.browser2.filters import Filter, CleanText, CleanDecimal, TableCell
__all__ = ['FrenchTransaction'] __all__ = ['FrenchTransaction']
class classproperty(object):
def __init__(self, f):
self.f = f
def __get__(self, obj, owner):
return self.f(owner)
class FrenchTransaction(Transaction): class FrenchTransaction(Transaction):
""" """
Transaction with some helpers for french bank websites. Transaction with some helpers for french bank websites.
@ -167,13 +174,29 @@ class FrenchTransaction(Transaction):
return return
class TransactionsElement(TableElement): @classproperty
columns = {'date': [u'Date'], def TransactionElement(k):
'vdate': [u'Valeur'], class _TransactionElement(ItemElement):
'raw': [u'Opération', u'Libellé'], klass = k
'credit': [u'Crédit', 'Montant'],
'debit': [u'Débit'], obj_date = klass.Date(TableCell('date'))
} obj_vdate = klass.Date(TableCell('vdate', 'date'))
obj_raw = klass.Raw(TableCell('raw'))
obj_amount = klass.Amount(TableCell('credit'), TableCell('debit', default=''))
return _TransactionElement
@classproperty
def TransactionsElement(klass):
class _TransactionsElement(TableElement):
col_date = [u'Date']
col_vdate = [u'Valeur']
col_raw = [u'Opération', u'Libellé']
col_credit = [u'Crédit', u'Montant']
col_debit = [u'Débit']
item = klass.TransactionElement
return _TransactionsElement
class Date(CleanText): class Date(CleanText):
def __call__(self, item): def __call__(self, item):