Fix bills list

Signed-off-by: Kitof <git@kitof.net>
This commit is contained in:
Kitof 2013-07-19 13:42:20 +02:00 committed by Florent
commit 850dce420e

View file

@ -62,26 +62,26 @@ class DetailsPage(BasePage):
if divint.xpath('div[@class="detail"]'): if divint.xpath('div[@class="detail"]'):
self.parse_div(divint, u"Appels émis : %s | Appels reçus : %s", num, True) self.parse_div(divint, u"Appels émis : %s | Appels reçus : %s", num, True)
for divbill in self.document.xpath('//div[@class="facture"]'): for divbills in self.document.xpath('//div[@id="factContainer"]'):
for trbill in divbill.xpath('table/tr'): for divbill in divbills.xpath('.//div[@class="factLigne hide "]'):
mydate = unicode(trbill.find('td').text.split(":")[1].strip()) alink = divbill.xpath('.//div[@class="pdf"]/a')[0]
for alink in trbill.xpath('td/a'): localid = re.search('&l=(?P<id>\d*)&id',
bill = Bill() alink.attrib.get('href')).group('id')
bill.label = unicode(mydate) mydate_str = re.search('&date=(?P<date>\d*)$',
billid = mydate.replace('-', '') alink.attrib.get('href')).group('date')
billid = billid[4:8] + billid[2:4] + billid[0:2] mydate = datetime.strptime(mydate_str, "%Y%m%d").date()
bill.id = billid
bill.date = date(*reversed([int(x) bill = Bill()
for x in mydate.split("-")])) bill.label = unicode(mydate_str)
bill.format = u"pdf" bill.id = unicode(mydate_str)
bill._url = alink.attrib.get('href') bill.date = mydate
if "pdfrecap" in alink.attrib.get('href'): bill.format = u"pdf"
bill.id = "recap-" + bill.id bill._url = alink.attrib.get('href')
localid = re.search('&l=(?P<id>\d*)&id', if "pdfrecap" in alink.attrib.get('href'):
alink.attrib.get('href')).group('id') bill.id = "recap-" + bill.id
if localid not in self.datebills: if localid not in self.datebills:
self.datebills[localid] = [] self.datebills[localid] = []
self.datebills[localid].append(bill) self.datebills[localid].append(bill)
def parse_div(self, divglobal, string, num, inter=False): def parse_div(self, divglobal, string, num, inter=False):
divs = divglobal.xpath('div[@class="detail"]') divs = divglobal.xpath('div[@class="detail"]')