From 6808ac471f1fa514989254bb2f9d350f3859f5c7 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sun, 16 Feb 2014 21:52:45 +0100 Subject: [PATCH] fix parsing dates in labels (compatibility with Perigord) --- modules/cragr/web/pages.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py index eef2241c..22d98363 100644 --- a/modules/cragr/web/pages.py +++ b/modules/cragr/web/pages.py @@ -325,11 +325,13 @@ class TransactionsPage(BasePage): t.type = self.TYPES.get(t.category, t.TYPE_UNKNOWN) # Parse operation date in label (for card transactions for example) - m = re.match('(.*) (\d{2})/(\d{2})$', t.label) + m = re.match('(?P.*) (?P
[0-3]\d)/(?P[0-1]\d)$', t.label) + if not m: + m = re.match('^(?P
[0-3]\d)/(?P[0-1]\d) (?P.*)$', t.label) if m: - if t.type == t.TYPE_CARD: - t.rdate = date_guesser.guess_date(int(m.group(2)), int(m.group(3)), change_current_date=False) - t.label = m.group(1).strip() + if t.type in (t.TYPE_CARD, t.TYPE_WITHDRAWAL): + t.rdate = date_guesser.guess_date(int(m.groupdict()['dd']), int(m.groupdict()['mm']), change_current_date=False) + t.label = m.groupdict()['text'].strip() # Strip city or other useless information from label. t.label = re.sub('(.*) .*', r'\1', t.label).strip()