parse special cases
This commit is contained in:
parent
ac8e035d29
commit
c450ffde06
1 changed files with 17 additions and 3 deletions
|
|
@ -18,16 +18,20 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import re
|
||||
from datetime import date
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.capabilities.bank import Operation
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
|
||||
|
||||
__all__ = ['AccountHistory']
|
||||
|
||||
|
||||
class AccountHistory(BasePage):
|
||||
LABEL_PATTERNS = [(u'^CHEQUEN°(?P<no>.*)', u'CHEQUE', u'N°%(no)s')]
|
||||
|
||||
def on_loaded(self):
|
||||
self.operations = []
|
||||
|
||||
|
|
@ -44,11 +48,21 @@ class AccountHistory(BasePage):
|
|||
if child.text: label += child.text
|
||||
if child.tail: label += child.tail
|
||||
if tds[1].tail: label += tds[1].tail
|
||||
|
||||
label = label.strip()
|
||||
category = NotAvailable
|
||||
for pattern, _cat, _lab in self.LABEL_PATTERNS:
|
||||
m = re.match(pattern, label)
|
||||
if m:
|
||||
category = _cat % m.groupdict()
|
||||
label = _lab % m.groupdict()
|
||||
break
|
||||
else:
|
||||
if ' ' in label:
|
||||
category, useless, label = [part.strip() for part in label.partition(' ')]
|
||||
|
||||
amount = tds[2].text.replace('.', '').replace(',', '.')
|
||||
(category, useless, label) = label.partition(' ')
|
||||
category = category.strip()
|
||||
label = label.strip()
|
||||
|
||||
# if we don't have exactly one '.', this is not a floatm try the next
|
||||
operation = Operation(len(self.operations))
|
||||
if amount.count('.') != 1:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue