Fix parsing of details (site changed)
This commit is contained in:
parent
1282a32cb1
commit
cd42bff740
1 changed files with 9 additions and 2 deletions
|
|
@ -65,17 +65,24 @@ class PdfPage():
|
||||||
detail = None
|
detail = None
|
||||||
lines.pop(0) # MENSUELLE
|
lines.pop(0) # MENSUELLE
|
||||||
lines.pop(-1) # Line to describes pictures
|
lines.pop(-1) # Line to describes pictures
|
||||||
|
twolines = False
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if "Votre consommation" in line:
|
if "Votre consommation" in line:
|
||||||
line = line.split(": ", 1)[1]
|
line = line.split(": ", 1)[1]
|
||||||
if re.match('[A-Za-z]', line[0]):
|
if twolines:
|
||||||
|
twolines = False
|
||||||
|
detail.infos = unicode(line, encoding='utf-8')
|
||||||
|
elif 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)
|
split = re.split("(\d)", line, maxsplit=1)
|
||||||
detail.price = Decimal(0)
|
detail.price = Decimal(0)
|
||||||
|
if len(split) > 2:
|
||||||
detail.infos = unicode(split[1] + split[2], encoding='utf-8')
|
detail.infos = unicode(split[1] + split[2], encoding='utf-8')
|
||||||
|
else:
|
||||||
|
twolines = True
|
||||||
if '€' in line:
|
if '€' in line:
|
||||||
specialprice = split[1] + split[2]
|
specialprice = split[1] + split[2]
|
||||||
detail.price = Decimal(specialprice.replace('€', ''))
|
detail.price = Decimal(specialprice.replace('€', ''))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue