Fix parsing with calibre 0.9
This commit is contained in:
parent
01b5096303
commit
3346c3d37a
1 changed files with 10 additions and 3 deletions
|
|
@ -62,18 +62,25 @@ class PdfPage():
|
||||||
page = txt.split('CONSOMMATION')[2].split('ACTIVITE DETAILLEE')[0]
|
page = txt.split('CONSOMMATION')[2].split('ACTIVITE DETAILLEE')[0]
|
||||||
lines = page.split('\n')
|
lines = page.split('\n')
|
||||||
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
||||||
lines.pop(0) # "Votre consommation au "
|
|
||||||
details = []
|
details = []
|
||||||
detail = None
|
detail = None
|
||||||
|
lines.pop(-1) # line for picture informations
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
if "Votre consommation" in line:
|
||||||
|
line = line.split(": ", 1)[1]
|
||||||
if re.match('[A-Za-z]', line[0]):
|
if re.match('[A-Za-z]', line[0]):
|
||||||
# We have a new element, return the other one
|
# We have a new element, return the other one
|
||||||
if detail is not None:
|
if detail is not None:
|
||||||
details.append(detail)
|
details.append(detail)
|
||||||
detail = Detail()
|
detail = Detail()
|
||||||
|
split = re.split("(\d)", line, maxsplit=1)
|
||||||
|
print split
|
||||||
detail.price = Decimal(0)
|
detail.price = Decimal(0)
|
||||||
detail.infos = NotAvailable
|
detail.infos = split[1] + split[2]
|
||||||
detail.label = unicode(line, encoding='utf-8')
|
if '€' in line:
|
||||||
|
specialprice = split[1] + split[2]
|
||||||
|
detail.price = Decimal(specialprice.replace('€', ''))
|
||||||
|
detail.label = unicode(split[0], encoding='utf-8')
|
||||||
elif '€' in line:
|
elif '€' in line:
|
||||||
detail.price = Decimal(line.replace('€', ''))
|
detail.price = Decimal(line.replace('€', ''))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue