Пример #1
0
    def _iter_divs(self, divs, num, inter=False):
        for div in divs:
            detail = Detail()
            detail.label = CleanText('div[@class="titre"]/p')(div)
            detail.id = "-" + detail.label.split(' ')[1].lower()
            if inter:
                detail.label = detail.label + u" (international)"
                detail.id = detail.id + "-inter"
            detail.infos = CleanText('div[@class="conso"]/p')(div)
            detail.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div)

            self.details[num].append(detail)
Пример #2
0
    def _iter_divs(self, divs, num, inter=False):
        for div in divs:
            detail = Detail()
            detail.label = CleanText('div[@class="titre"]/p')(div)
            detail.id = "-" + detail.label.split(' ')[1].lower()
            if inter:
                detail.label = detail.label + u" (international)"
                detail.id = detail.id + "-inter"
            detail.infos = CleanText('div[@class="conso"]/p')(div)
            detail.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div)

            self.details[num].append(detail)
Пример #3
0
    def iter_divs(self, divs, num, inter=False):
        for div in divs:
            detail = Detail()

            detail.label = unicode(div.find('div[@class="titre"]/p').text_content())
            detail.id = "-" + detail.label.split(' ')[1].lower()
            if inter:
                detail.label = detail.label + u" (international)"
                detail.id = detail.id + "-inter"
            detail.infos = unicode(div.find('div[@class="conso"]/p').text_content().lstrip())
            detail.price = convert_price(div)

            self.details[num].append(detail)
Пример #4
0
    def parse_voice(self, div, string, num, inter=False):
        voice = Detail()
        voice.id = "-voice"
        voice.label = unicode(div.find('div[@class="titre"]/p').text_content())
        if inter:
            voice.label = voice.label + " (international)"
            voice.id = voice.id + "-inter"
        voice.price = convert_price(div)
        voice1 = div.xpath('div[@class="conso"]/p/span')[0].text
        voice2 = div.xpath('div[@class="conso"]/p/span')[1].text
        voice.infos = unicode(string) % (voice1, voice2)

        return voice
Пример #5
0
    def parse_voice(self, div, string, num, inter=False):
        voice = Detail()
        voice.id = "-voice"
        voice.label = unicode(div.find('div[@class="titre"]/p').text_content())
        if inter:
            voice.label = voice.label + " (international)"
            voice.id = voice.id + "-inter"
        voice.price = convert_price(div)
        voice1 = div.xpath('div[@class="conso"]/p/span')[0].text
        voice2 = div.xpath('div[@class="conso"]/p/span')[1].text
        voice.infos = unicode(string) % (voice1, voice2)

        return voice
Пример #6
0
    def _parse_voice(self, div, string, num, inter=False):
        voicediv = div.xpath('div[@class="conso"]')[0]
        voice = Detail()
        voice.id = "-voice"
        voice.label = CleanText('div[@class="titre"]/p')(div)
        if inter:
            voice.label = voice.label + " (international)"
            voice.id = voice.id + "-inter"
        voice.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div)
        voice1 = CleanText('.//span[@class="actif"][1]')(voicediv)
        voice2 = CleanText('.//span[@class="actif"][2]')(voicediv)
        voice.infos = unicode(string) % (voice1, voice2)

        return voice
Пример #7
0
    def _parse_voice(self, div, string, num, inter=False):
        voicediv = div.xpath('div[@class="conso"]')[0]
        voice = Detail()
        voice.id = "-voice"
        voice.label = CleanText('div[@class="titre"]/p')(div)
        if inter:
            voice.label = voice.label + " (international)"
            voice.id = voice.id + "-inter"
        voice.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div)
        voice1 = CleanText('.//span[@class="actif"][1]')(voicediv)
        voice2 = CleanText('.//span[@class="actif"][2]')(voicediv)
        voice.infos = unicode(string) % (voice1, voice2)

        return voice
Пример #8
0
    def iter_divs(self, divs, num, inter=False):
        for div in divs:
            detail = Detail()

            detail.label = unicode(
                div.find('div[@class="titre"]/p').text_content())
            detail.id = "-" + detail.label.split(' ')[1].lower()
            if inter:
                detail.label = detail.label + u" (international)"
                detail.id = detail.id + "-inter"
            detail.infos = unicode(
                div.find('div[@class="conso"]/p').text_content().lstrip())
            detail.price = convert_price(div)

            self.details[num].append(detail)
Пример #9
0
 def get_details(self, sub):
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ""
     det.price = Decimal("0.0")
     return det
Пример #10
0
 def iter_details(self, sub):
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ''
     det.price = Decimal('0.0')
     yield det
Пример #11
0
 def iter_history(self):
     tables = self.doc.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')
     if len(tables) > 0:
         lines = tables[0].xpath('.//tr')
         sno = 0
         for tr in lines:
             list_a = tr.xpath('.//a')
             if len(list_a) == 0:
                 continue
             date = tr.xpath('.//td')[0].text.strip()
             lot = list_a[0].text.replace('(*)', '').strip()
             if lot == 'SNL':
                 sno = sno + 1
                 lot = lot + str(sno)
             factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
             factures_lbl = ''
             for a in factures:
                 factures_lbl = factures_lbl + a.text.replace('(**)', '').strip() + ' '
             montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip()
             det = Detail()
             det.id = u''+lot
             det.label = u''+lot
             det.infos = u''+factures_lbl
             det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
             det.price = Decimal(montant.replace(',', '.'))
             yield det
Пример #12
0
 def get_details(self, sub):
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ''
     det.price = Decimal('0.0')
     return det
Пример #13
0
 def iter_history(self):
     tables = self.doc.xpath(
         '//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')
     if len(tables) > 0:
         lines = tables[0].xpath('.//tr')
         sno = 0
         for tr in lines:
             list_a = tr.xpath('.//a')
             if len(list_a) == 0:
                 continue
             date = tr.xpath('.//td')[0].text.strip()
             lot = list_a[0].text.replace('(*)', '').strip()
             if lot == 'SNL':
                 sno = sno + 1
                 lot = lot + str(sno)
             factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
             factures_lbl = ''
             for a in factures:
                 factures_lbl = factures_lbl + a.text.replace(
                     '(**)', '').strip() + ' '
             montant = tr.xpath(
                 './/div[@class="cAlignDroite"]')[0].text.strip()
             det = Detail()
             det.id = u'' + lot
             det.label = u'' + lot
             det.infos = u'' + factures_lbl
             det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
             det.price = Decimal(montant.replace(',', '.'))
             yield det
Пример #14
0
 def get_details(self, sub):
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ''
     det.price = Decimal('0.0')
     return det
Пример #15
0
 def iter_details(self, sub):
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ''
     det.price = Decimal('0.0')
     yield det
Пример #16
0
 def iter_details(self, sub):
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ""
     det.price = Decimal("0.0")
     yield det
Пример #17
0
 def iter_payment_details(self, sub):
     if sub._id.isdigit():
         idx = 0
     else:
         idx = sub._id.replace('AFFILIE', '')
     if len(self.document.xpath('//div[@class="centrepage"]/h2')) > idx or self.document.xpath('//table[@id="DetailPaiement3"]') > idx:
         id_str = self.document.xpath('//div[@class="centrepage"]/h2')[idx].text.strip()
         m = re.match('.*le (.*) pour un montant de.*', id_str)
         if m:
             id_str = m.group(1)
             id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
             id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
             table = self.document.xpath('//table[@class="tableau"]')[idx].xpath('.//tr')
             line = 1
             last_date = None
             for tr in table:
                 tds = tr.xpath('.//td')
                 if len(tds) == 0:
                     continue
                 date_str = tds[0].text
                 det = Detail()
                 det.id = id + "." + str(line)
                 det.label = unicode(tds[1].text.strip())
                 if date_str is None or date_str == '':
                     det.infos = u''
                     det.datetime = last_date
                 else:
                     det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', tds[2].text)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', tds[3].text)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', tds[4].text)) + '%'
                     det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
                     last_date = det.datetime
                 det.price = Decimal(re.sub('[^\d,-]+', '', tds[5].text).replace(',', '.'))
                 line = line + 1
                 yield det
Пример #18
0
 def iter_details(self, sub):
     self.logger.debug('call Browser.iter_details')
     det = Detail()
     det.id = sub.id
     det.label = sub.label
     det.infos = ''
     det.price = Decimal('0.0')
     yield det
Пример #19
0
 def get_balance(self, subscription):
     if not isinstance(subscription, Subscription):
         subscription = self.get_subscription(subscription)
     balance = Detail()
     balance.id = "%s-balance" % subscription.id
     balance.price = subscription._balance
     balance.label = u"Balance %s" % subscription.id
     balance.currency = u'EUR'
     return balance
Пример #20
0
    def iter_payments(self, sub):

        table = self.browser.page.document.xpath('//table[contains(@summary, "Informations sur mon")]')[0]
        for tr in table.xpath('.//tr'):
            list_tds = tr.xpath('.//td')
            if len(list_tds) == 0:
                continue
            date = datetime.strptime(self.parser.tocleanstring(list_tds[0]), "%d/%m/%Y").date()
            amount = self.parser.tocleanstring(list_tds[1])
            if amount is None:
                continue
            det = Detail()
            det.id = sub._id + "." + date.strftime("%Y%m%d")
            det.price = Decimal(re.sub('[^\d,-]+', '', amount).replace(',', '.'))
            det.datetime = date
            det.label = unicode(self.parser.tocleanstring(list_tds[2]))
            yield det
Пример #21
0
    def iter_payments(self, sub):

        table = self.browser.page.document.xpath('//table[contains(@summary, "Informations sur mon")]')[0]
        for tr in table.xpath('.//tr'):
            list_tds = tr.xpath('.//td')
            if len(list_tds) == 0:
                continue
            date = datetime.strptime(self.parser.tocleanstring(list_tds[0]), "%d/%m/%Y").date()
            amount = self.parser.tocleanstring(list_tds[1])
            if amount is None:
                continue
            det = Detail()
            det.id = sub._id + "." + date.strftime("%Y%m%d")
            det.price = Decimal(re.sub('[^\d,-]+', '', amount).replace(',', '.'))
            det.datetime = date
            det.label = unicode(self.parser.tocleanstring(list_tds[2]))
            yield det
Пример #22
0
 def iter_payment_details(self, sub):
     if sub._id.isdigit():
         idx = 0
     else:
         idx = sub._id.replace('AFFILIE', '')
     if len(
             self.document.xpath('//div[@class="centrepage"]/h3')
     ) > idx or self.document.xpath('//table[@id="DetailPaiement3"]') > idx:
         id_str = self.document.xpath(
             '//div[@class="centrepage"]/h3')[idx].text.strip()
         m = re.match('.*le (.*) pour un montant de.*', id_str)
         if m:
             id_str = m.group(1)
             id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
             id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
             table = self.document.xpath(
                 '//table[@id="DetailPaiement3"]')[idx].xpath('.//tr')
             line = 1
             last_date = None
             for tr in table:
                 tds = tr.xpath('.//td')
                 if len(tds) == 0:
                     continue
                 date_str = tds[0].text
                 det = Detail()
                 det.id = id + "." + str(line)
                 det.label = unicode(tds[1].text.strip())
                 if date_str is None or date_str == '':
                     det.infos = u''
                     det.datetime = last_date
                 else:
                     det.infos = u'Payé ' + unicode(
                         re.sub('[^\d,-]+', '',
                                tds[2].text)) + u'€ / Base ' + unicode(
                                    re.sub('[^\d,-]+', '', tds[3].text)
                                ) + u'€ / Taux ' + unicode(
                                    re.sub('[^\d,-]+', '',
                                           tds[4].text)) + '%'
                     det.datetime = datetime.strptime(date_str,
                                                      '%d/%m/%Y').date()
                     last_date = det.datetime
                 det.price = Decimal(
                     re.sub('[^\d,-]+', '', tds[5].text).replace(',', '.'))
                 line = line + 1
                 yield det
Пример #23
0
 def iter_payment_details(self, sub):
     if sub._id.isdigit():
         idx = 0
     else:
         idx = sub._id.replace("AFFILIE", "")
     if (
         len(self.document.xpath('//div[@class="centrepage"]/h3')) > idx
         or self.document.xpath('//table[@id="DetailPaiement3"]') > idx
     ):
         id_str = self.document.xpath('//div[@class="centrepage"]/h3')[idx].text.strip()
         m = re.match(".*le (.*) pour un montant de.*", id_str)
         if m:
             id_str = m.group(1)
             id_date = datetime.strptime(id_str, "%d/%m/%Y").date()
             id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
             table = self.document.xpath('//table[@id="DetailPaiement3"]')[idx].xpath(".//tr")
             line = 1
             last_date = None
             for tr in table:
                 tds = tr.xpath(".//td")
                 if len(tds) == 0:
                     continue
                 date_str = tds[0].text
                 det = Detail()
                 det.id = id + "." + str(line)
                 det.label = unicode(tds[1].text.strip())
                 if date_str is None or date_str == "":
                     det.infos = u""
                     det.datetime = last_date
                 else:
                     det.infos = (
                         u"Payé "
                         + unicode(re.sub("[^\d,-]+", "", tds[2].text))
                         + u"€ / Base "
                         + unicode(re.sub("[^\d,-]+", "", tds[3].text))
                         + u"€ / Taux "
                         + unicode(re.sub("[^\d,-]+", "", tds[4].text))
                         + "%"
                     )
                     det.datetime = datetime.strptime(date_str, "%d/%m/%Y").date()
                     last_date = det.datetime
                 det.price = Decimal(re.sub("[^\d,-]+", "", tds[5].text).replace(",", "."))
                 line = line + 1
                 yield det
Пример #24
0
 def iter_history(self):
     table = self.document.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')[0].xpath('.//tr')
     for tr in table:
         list_a = tr.xpath('.//a')
         if len(list_a) == 0:
             continue
         date = tr.xpath('.//td')[0].text.strip()
         lot = list_a[0].text
         factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
         factures_lbl = ''
         for a in factures:
             factures_lbl = factures_lbl + a.text + ' '
         montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip()
         det = Detail()
         det.id = lot
         det.label = lot
         det.infos = factures_lbl
         det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
         det.price = Decimal(montant.replace(',', '.'))
         yield det
Пример #25
0
 def iter_history(self):
     table = self.document.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]')[0].xpath('.//tr')
     for tr in table:
         list_a = tr.xpath('.//a')
         if len(list_a) == 0:
             continue
         date = tr.xpath('.//td')[0].text.strip()
         lot = list_a[0].text
         factures = tr.xpath('.//div[@class="cAlignGauche"]/a')
         factures_lbl = ''
         for a in factures:
             factures_lbl = factures_lbl + a.text + ' '
         montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip()
         det = Detail()
         det.id = lot
         det.label = lot
         det.infos = factures_lbl
         det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
         det.price = Decimal(montant.replace(',', '.'))
         yield det
Пример #26
0
    def iter_payment_details(self, sub):
        if CleanText('//div[@class="infoPrestationsAssure"]/span')(
                self.doc).startswith('Pour %s' % sub.subscriber):
            id_str = self.doc.xpath(
                '//div[@class="centrepage"]/h2')[0].text.strip()
            m = re.match('.*le (.*) pour un montant de.*', id_str)
            if m:
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = self.doc.xpath(
                    '//div[@class="infoPrestationsAssure"]//table')[0].xpath(
                        './/tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    if len(tds) == 5:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        jours = tds[2].text
                        if jours is None:
                            jours = '0'

                        montant = tds[3].text
                        if montant is None:
                            montant = '0'

                        price = tds[4].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = date_str + u' (' + unicode(
                                re.sub('[^\d,-]+', '',
                                       jours)) + u'j) * ' + unicode(
                                           re.sub('[^\d,-]+', '',
                                                  montant)) + u'€'
                            det.datetime = datetime.strptime(
                                date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 6:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        paye = tds[2].text
                        if paye is None:
                            paye = '0'

                        base = tds[3].text
                        if base is None:
                            base = '0'

                        taux = tds[4].text
                        if taux is None:
                            taux = '0'

                        price = tds[5].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u'Payé ' + unicode(
                                re.sub('[^\d,-]+', '',
                                       paye)) + u'€ / Base ' + unicode(
                                           re.sub('[^\d,-]+', '', base)
                                       ) + u'€ / Taux ' + unicode(
                                           re.sub('[^\d,-]+', '', taux)) + '%'
                            det.datetime = datetime.strptime(
                                date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det
Пример #27
0
    def iter_payment_details(self, sub):
        if CleanText('//div[@class="infoPrestationsAssure"]/span')(self.doc).startswith('Pour %s' % sub.subscriber):
            id_str = self.doc.xpath('//div[@class="centrepage"]/h2')[0].text.strip()
            m = re.match('.*le (.*) pour un montant de.*', id_str)
            if m:
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = self.doc.xpath('//div[@class="infoPrestationsAssure"]//table')[0].xpath('.//tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    if len(tds) == 5:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        jours = tds[2].text
                        if jours is None:
                            jours = '0'

                        montant = tds[3].text
                        if montant is None:
                            montant = '0'

                        price = tds[4].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = date_str + u' (' + unicode(re.sub('[^\d,-]+', '', jours)) + u'j) * ' + unicode(re.sub('[^\d,-]+', '', montant)) + u'€'
                            det.datetime = datetime.strptime(date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 6:
                        date_str = tds[0].text
                        det.id = id + "." + str(line)
                        det.label = unicode(tds[1].text.strip())

                        paye = tds[2].text
                        if paye is None:
                            paye = '0'

                        base = tds[3].text
                        if base is None:
                            base = '0'

                        taux = tds[4].text
                        if taux is None:
                            taux = '0'

                        price = tds[5].text
                        if price is None:
                            price = '0'


                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', paye)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', base)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', taux)) + '%'
                            det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det
Пример #28
0
    def iter_payment_details(self, sub):
        id_str = self.doc.xpath('//div[@class="entete container"]/h2')[0].text.strip()
        m = re.match('.*le (.*) pour un montant de.*', id_str)
        if m:
            blocs_benes = self.doc.xpath('//span[contains(@id,"nomBeneficiaire")]')
            blocs_prestas = self.doc.xpath('//table[@id="tableauPrestation"]')
            i = 0
            last_bloc = len(blocs_benes)
            for i in range(0, last_bloc):
                bene = blocs_benes[i].text;
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = blocs_prestas[i].xpath('.//tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    # TO TEST : Indemnités journalières : Pas pu tester de cas de figure similaire dans la nouvelle mouture du site
                    if len(tds) == 4:
                        date_str = Regexp(pattern=r'.*<br/>(\d+/\d+/\d+)\).*').filter(tds[0].text)
                        det.id = id + "." + str(line)
                        det.label = tds[0].xpath('.//span')[0].text.strip()

                        jours = tds[1].text
                        if jours is None:
                            jours = '0'

                        montant = tds[2].text
                        if montant is None:
                            montant = '0'

                        price = tds[3].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = '%s (%sj) * %s€' % (date_str, re.sub(r'[^\d,-]+', '', jours), re.sub(r'[^\d,-]+', '', montant))
                            det.datetime = datetime.strptime(date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 5:
                        date_str = Regexp(pattern=r'\w*(\d{2})/(\d{2})/(\d{4}).*', template='\\1/\\2/\\3', default="").filter("".join(tds[0].itertext()))
                        det.id = id + "." + str(line)
                        det.label = '%s - %s' % (bene, tds[0].xpath('.//span')[0].text.strip())

                        paye = tds[1].text
                        if paye is None:
                            paye = '0'

                        base = tds[2].text
                        if base is None:
                            base = '0'

                        tdtaux = tds[3].xpath('.//span')[0].text
                        if tdtaux is None:
                            taux = '0'
                        else:
                            taux = tdtaux.strip()

                        tdprice = tds[4].xpath('.//span')[0].text
                        if tdprice is None:
                            price = '0'
                        else:
                            price = tdprice.strip()

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u' Payé %s€ / Base %s€ / Taux %s%%' % (re.sub(r'[^\d,-]+', '', paye), re.sub(r'[^\d,-]+', '', base), re.sub('[^\d,-]+', '', taux))
                            det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det
Пример #29
0
    def iter_payment_details(self, sub):
        id_str = self.doc.xpath(
            '//div[@class="entete container"]/h2')[0].text.strip()
        m = re.match('.*le (.*) pour un montant de.*', id_str)
        if m:
            blocs_benes = self.doc.xpath(
                '//span[contains(@id,"nomBeneficiaire")]')
            blocs_prestas = self.doc.xpath('//table[@id="tableauPrestation"]')
            i = 0
            last_bloc = len(blocs_benes)
            for i in range(0, last_bloc):
                bene = blocs_benes[i].text
                id_str = m.group(1)
                id_date = datetime.strptime(id_str, '%d/%m/%Y').date()
                id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d")
                table = blocs_prestas[i].xpath('.//tr')
                line = 1
                last_date = None
                for tr in table:
                    tds = tr.xpath('.//td')
                    if len(tds) == 0:
                        continue

                    det = Detail()

                    # TO TEST : Indemnités journalières : Pas pu tester de cas de figure similaire dans la nouvelle mouture du site
                    if len(tds) == 4:
                        date_str = Regexp(r'.*<br/>(\d+/\d+/\d+)\).*',
                                          '\\1')(tds[0].text)
                        det.id = id + "." + str(line)
                        det.label = unicode(
                            tds[0].xpath('.//span')[0].text.strip())

                        jours = tds[1].text
                        if jours is None:
                            jours = '0'

                        montant = tds[2].text
                        if montant is None:
                            montant = '0'

                        price = tds[3].text
                        if price is None:
                            price = '0'

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = date_str + u' (' + unicode(
                                re.sub('[^\d,-]+', '',
                                       jours)) + u'j) * ' + unicode(
                                           re.sub('[^\d,-]+', '',
                                                  montant)) + u'€'
                            det.datetime = datetime.strptime(
                                date_str.split(' ')[3], '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))

                    if len(tds) == 5:
                        date_str = Regexp(
                            pattern=r'\w*(\d{2})/(\d{2})/(\d{4}).*',
                            template='\\1/\\2/\\3',
                            default="").filter("".join(tds[0].itertext()))
                        det.id = id + "." + str(line)
                        det.label = bene + u' - ' + unicode(
                            tds[0].xpath('.//span')[0].text.strip())

                        paye = tds[1].text
                        if paye is None:
                            paye = '0'

                        base = tds[2].text
                        if base is None:
                            base = '0'

                        tdtaux = tds[3].xpath('.//span')[0].text
                        if tdtaux is None:
                            taux = '0'
                        else:
                            taux = tdtaux.strip()

                        tdprice = tds[4].xpath('.//span')[0].text
                        if tdprice is None:
                            price = '0'
                        else:
                            price = tdprice.strip()

                        if date_str is None or date_str == '':
                            det.infos = u''
                            det.datetime = last_date
                        else:
                            det.infos = u' Payé ' + unicode(
                                re.sub('[^\d,-]+', '',
                                       paye)) + u'€ / Base ' + unicode(
                                           re.sub('[^\d,-]+', '', base)
                                       ) + u'€ / Taux ' + unicode(
                                           re.sub('[^\d,-]+', '', taux)) + '%'
                            det.datetime = datetime.strptime(
                                date_str, '%d/%m/%Y').date()
                            last_date = det.datetime
                        det.price = Decimal(
                            re.sub('[^\d,-]+', '', price).replace(',', '.'))
                    line = line + 1
                    yield det