Esempio n. 1
0
 def make_message(self, d, thread):
     msg = Message(thread, d['id'])
     msg.children = []
     msg.sender = d['from']
     msg.flags = 0
     msg.title = d['subject']
     msg.date = d['datetime']
     msg.receivers = [d['to']]
     return msg
Esempio n. 2
0
 def make_message(self, d, thread):
     msg = Message(thread, d['id'])
     msg.children = []
     msg.sender = d['from']
     msg.flags = 0
     msg.title = d['subject']
     msg.date = d['datetime']
     msg.receivers = [d['to']]
     return msg
Esempio n. 3
0
 def make_message(self, d, thread):
     m = Message(thread, d['id'])
     m.children = []
     m.sender = d['from']
     m.flags = 0
     if not d.get('read', True):
         m.flags = m.IS_UNREAD
     m.title = d['subject']
     m.date = d['datetime']
     m.receivers = [d['to']]
     return m
Esempio n. 4
0
 def make_message(self, d, thread):
     m = Message(thread, d['id'])
     m.children = []
     m.sender = d['from']
     m.flags = 0
     if not d.get('read', True):
         m.flags = m.IS_UNREAD
     m.title = d['subject']
     m.date = d['datetime']
     m.receivers = [d['to']]
     return m
Esempio n. 5
0
    def _get_messages(self, thread):
        thread_div = self.document.find(True, 'PADpost_txt')
        used_ids = set()

        rcpt = self.document.find('input', attrs={'type': 'hidden', 'name': 'Dest'})['value']
        sender_to_receiver = {rcpt: self.browser.username, self.browser.username: rcpt}
        # site is sorted from latest to oldest message
        for message_table in reversed(thread_div.findAll('table')):
            for td in message_table.findAll('td'):
                profile_a = td.find('a', href=re.compile(r'profil_read.php\?.*'))
                if not profile_a:
                    continue

                first_br = td.find('br')
                assert first_br.nextSibling.name == 'br'
                text_nodes = ovsparse.all_next_siblings(first_br.nextSibling.nextSibling)  # TODO
                #~ print text_nodes

            # date will be used as id
            sitedate = profile_a.findParent('div').find(text=re.compile(',.*')).replace(', ', '')
            sysdate = parse_french_date(sitedate)
            compactdate = datetime.datetime.strftime(sysdate, '%Y%m%dT%H%M%S')

            # but make it unique
            msg_id = ovsparse.create_unique_id(compactdate, used_ids)
            used_ids.add(msg_id)

            message = Message(thread, msg_id)

            message.sender = re.search(r'\?(.+)', profile_a['href']).group(1)
            message.receivers = [sender_to_receiver[message.sender]]

            message.date = sysdate

            message.content = ovsparse.html_message_to_text(text_nodes)

            notread_self = bool(td.find('span', 'ColorSurligne'))
            notread_other = bool(td.find('span', 'new_sortiepartenaire'))
            if notread_other or notread_self:
                message.flags |= Message.IS_NOT_RECEIVED
            else:
                message.flags |= Message.IS_RECEIVED

            yield message
Esempio n. 6
0
    def _get_messages(self, thread):
        thread_div = self.document.find(True, "PADpost_txt")
        used_ids = set()

        rcpt = self.document.find("input", attrs={"type": "hidden", "name": "Dest"})["value"]
        sender_to_receiver = {rcpt: self.browser.username, self.browser.username: rcpt}
        # site is sorted from latest to oldest message
        for message_table in reversed(thread_div.findAll("table")):
            for td in message_table.findAll("td"):
                profile_a = td.find("a", href=re.compile(r"profil_read.php\?.*"))
                if not profile_a:
                    continue

                first_br = td.find("br")
                assert first_br.nextSibling.name == "br"
                text_nodes = ovsparse.all_next_siblings(first_br.nextSibling.nextSibling)  # TODO
                # ~ print text_nodes

            # date will be used as id
            sitedate = profile_a.findParent("div").find(text=re.compile(",.*")).replace(", ", "")
            sysdate = parse_french_date(sitedate)
            compactdate = datetime.datetime.strftime(sysdate, "%Y%m%dT%H%M%S")

            # but make it unique
            msg_id = ovsparse.create_unique_id(compactdate, used_ids)
            used_ids.add(msg_id)

            message = Message(thread, msg_id)

            message.sender = re.search(r"\?(.+)", profile_a["href"]).group(1)
            message.receivers = [sender_to_receiver[message.sender]]

            message.date = sysdate

            message.content = ovsparse.html_message_to_text(text_nodes)

            notread_self = bool(td.find("span", "ColorSurligne"))
            notread_other = bool(td.find("span", "new_sortiepartenaire"))
            if notread_other or notread_self:
                message.flags |= Message.IS_NOT_RECEIVED
            else:
                message.flags |= Message.IS_RECEIVED

            yield message