From 3346c3d37a3ac1473bb66483651edaeae8405b07 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 24 May 2013 14:48:31 +0200 Subject: [PATCH] Fix parsing with calibre 0.9 --- modules/leclercmobile/pages/history.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/leclercmobile/pages/history.py b/modules/leclercmobile/pages/history.py index abb5fa4a..a6b9a531 100644 --- a/modules/leclercmobile/pages/history.py +++ b/modules/leclercmobile/pages/history.py @@ -62,18 +62,25 @@ class PdfPage(): page = txt.split('CONSOMMATION')[2].split('ACTIVITE DETAILLEE')[0] lines = page.split('\n') lines = [x for x in lines if len(x) > 0] # Remove empty lines - lines.pop(0) # "Votre consommation au " details = [] detail = None + lines.pop(-1) # line for picture informations for line in lines: + if "Votre consommation" in line: + line = line.split(": ", 1)[1] if re.match('[A-Za-z]', line[0]): # We have a new element, return the other one if detail is not None: details.append(detail) detail = Detail() + split = re.split("(\d)", line, maxsplit=1) + print split detail.price = Decimal(0) - detail.infos = NotAvailable - detail.label = unicode(line, encoding='utf-8') + detail.infos = split[1] + split[2] + if '€' in line: + specialprice = split[1] + split[2] + detail.price = Decimal(specialprice.replace('€', '')) + detail.label = unicode(split[0], encoding='utf-8') elif '€' in line: detail.price = Decimal(line.replace('€', '')) else: