• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python messages.Thread类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weboob.capabilities.messages.Thread的典型用法代码示例。如果您正苦于以下问题:Python Thread类的具体用法?Python Thread怎么用?Python Thread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Thread类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_thread

    def get_thread(self, id):
        thread = None
        parent = None

        if isinstance(id, Thread):
            thread = id
            id = thread.id

        thread_id = url2id(id, nopost=True) or id
        try:
            last_seen_id = self.storage.get('seen', default={})[id2topic(thread_id)]
        except KeyError:
            last_seen_id = 0

        with self.browser:
            for post in self.browser.iter_posts(id):
                if not thread:
                    thread = Thread(thread_id)
                    thread.title = post.title

                m = self._post2message(thread, post)
                m.parent = parent
                if last_seen_id < post.id:
                    m.flags |= Message.IS_UNREAD

                if parent:
                    parent.children = [m]
                else:
                    thread.root = m

                parent = m

        return thread
开发者ID:juliaL03,项目名称:weboob,代码行数:33,代码来源:module.py


示例2: get_thread

    def get_thread(self, id, entry=None):
        if isinstance(id, Thread):
            thread = id
            id = thread.id
        else:
            thread = Thread(id)

        if entry is None:
            entry = Newsfeed(self.config['url'].get()).get_entry(id)
        if entry is None:
            return None

        flags = Message.IS_HTML
        if not thread.id in self.storage.get('seen', default=[]):
            flags |= Message.IS_UNREAD
        if len(entry.content) > 0:
            content = u"<p>Link %s</p> %s" % (entry.link, entry.content[0])
        else:
            content = entry.link

        thread.title = entry.title
        thread.root = Message(thread=thread,
                              id=0,
                              title=entry.title,
                              sender=entry.author,
                              receivers=None,
                              date=entry.datetime,
                              parent=None,
                              content=content,
                              children=[],
                              flags=flags)
        return thread
开发者ID:Boussadia,项目名称:weboob,代码行数:32,代码来源:backend.py


示例3: get_thread

    def get_thread(self, _id):
        thread = Thread(_id)
        thread.title = 'Mail for %s' % _id
        thread.flags = thread.IS_DISCUSSION

        self._get_messages_thread(_id, thread)
        return thread
开发者ID:dasimon,项目名称:weboob,代码行数:7,代码来源:module.py


示例4: get_thread

 def get_thread(self, id):
     thr = Thread(id=id)
     self.fill_thread(thr)
     thr.date = thr.root.date
     thr.title = thr.root.title
     thr.url = thr.root.url
     return thr
开发者ID:laurentb,项目名称:weboob,代码行数:7,代码来源:pages.py


示例5: iter_threads

 def iter_threads(self):
     for thread in self.browser.get_threads():
         t = Thread(thread['id'])
         t.flags = Thread.IS_DISCUSSION
         t.title = u'Discussion with %s' % thread['name']
         t.date = local2utc(datetime.datetime.fromtimestamp(thread['last_message']['utc_timestamp']))
         yield t
开发者ID:laurentb,项目名称:weboob,代码行数:7,代码来源:module.py


示例6: iter_threads

 def iter_threads(self):
     table = self.parser.select(self.document.getroot(), "table#listeMessages", 1)
     for tr in table.xpath("./tr"):
         if tr.attrib.get("class", "") not in ("msgLu", "msgNonLu"):
             continue
         author = unicode(self.parser.select(tr, "td.colEmetteur", 1).text)
         link = self.parser.select(tr, "td.colObjet a", 1)
         date_raw = self.parser.select(tr, "td.colDate1", 1).attrib["data"]
         jsparams = re.search("\((.+)\)", link.attrib["onclick"]).groups()[0]
         jsparams = [i.strip("'\" ") for i in jsparams.split(",")]
         page_id, _id, unread = jsparams
         # this means unread on the website
         unread = False if unread == "false" else True
         # 2012/02/29:01h30min45sec
         dt_match = re.match("(\d+)/(\d+)/(\d+):(\d+)h(\d+)min(\d+)sec", date_raw).groups()
         dt_match = [int(d) for d in dt_match]
         thread = Thread(_id)
         thread._link_id = (page_id, unread)
         thread.date = datetime(*dt_match)
         thread.title = unicode(link.text)
         message = Message(thread, 0)
         message.set_empty_fields(None)
         message.flags = message.IS_HTML
         message.title = thread.title
         message.date = thread.date
         message.sender = author
         message.content = NotLoaded  # This is the only thing we are missing
         thread.root = message
         yield thread
开发者ID:kyrre,项目名称:weboob,代码行数:29,代码来源:messages.py


示例7: get_thread

 def get_thread(self, id):
     if isinstance(id, Thread):
         thread = id
         id = thread.id
     else:
         thread = Thread(id)
     entry = Newsfeed(self.config["url"]).get_entry(id)
     flags = Message.IS_HTML
     if not thread.id in self.storage.get('seen', default=[]):
         flags |= Message.IS_UNREAD
     if len(entry.content):
         content = entry.content[0]
     else:
         content = None
     thread.title = entry.title
     thread.root = Message(thread=thread,
                           id=0,
                           title=entry.title,
                           sender=entry.author,
                           receivers=None,
                           date=entry.datetime,
                           parent=None,
                           content=content,
                           children=[],
                           flags=flags)
     return thread
开发者ID:jocelynj,项目名称:weboob,代码行数:26,代码来源:backend.py


示例8: iter_unread_messages

    def iter_unread_messages(self):
        with self.browser:
            url = self.browser.get_root_feed_url()
            for article in Newsfeed(url, rssid).iter_entries():
                id = url2id(article.link)
                thread = None

                try:
                    last_seen_id = self.storage.get('seen', default={})[id2topic(id)]
                except KeyError:
                    last_seen_id = 0

                child = None
                iterator = self.browser.riter_posts(id, last_seen_id)
                if self.config['thread_unread_messages'].get() > 0:
                    iterator = limit(iterator, self.config['thread_unread_messages'].get())
                for post in iterator:
                    if not thread:
                        thread = Thread('%s.%s' % (post.forum_id, post.topic_id))
                    message = self._post2message(thread, post)

                    if child:
                        message.children.append(child)
                        child.parent = message

                    if post.parent:
                        message.parent = Message(thread=thread,
                                                 id=post.parent)
                    else:
                        thread.root = message
                    yield message
开发者ID:juliaL03,项目名称:weboob,代码行数:31,代码来源:module.py


示例9: iter_threads

 def iter_threads(self):
     with self.browser:
         for story in self.browser.iter_stories():
             thread = Thread(story.id)
             thread.title = story.title
             thread.date = story.date
             yield thread
开发者ID:Boussadia,项目名称:weboob,代码行数:7,代码来源:backend.py


示例10: iter_unread_messages

    def iter_unread_messages(self):
        try:
            contacts = {}
            with self.browser:
                threads = self.browser.get_threads_list()
            for thread in threads:
                #if thread['member'].get('isBan', thread['member'].get('dead', False)):
                #    with self.browser:
                #        self.browser.delete_thread(int(thread['member']['id']))
                #    continue
                if self.antispam and not self.antispam.check_thread(thread):
                    self.logger.info('Skipped a spam-unread-thread from %s' % thread['who']['pseudo'])
                    self.report_spam(thread['member']['id'])
                    continue
                slut = self._get_slut(thread['who']['id'])
                if parse_dt(thread['date']) > slut['lastmsg'] or thread['status'] != slut['status']:
                    t = self.get_thread(thread['who']['id'], contacts, get_profiles=True)
                    for m in t.iter_all_messages():
                        if m.flags & m.IS_UNREAD:
                            yield m

            if not self.config['baskets'].get():
                return

            # Send mail when someone added me in her basket.
            # XXX possibly race condition if a slut adds me in her basket
            #     between the aum.nb_new_baskets() and aum.get_baskets().
            with self.browser:
                slut = self._get_slut(-self.MAGIC_ID_BASKET)

                new_baskets = self.browser.nb_new_baskets()
                if new_baskets > 0:
                    baskets = self.browser.get_baskets()
                    my_name = self.browser.get_my_name()
                    for basket in baskets:
                        if parse_dt(basket['date']) <= slut['lastmsg']:
                            continue
                        contact = self.get_contact(basket['who']['id'])
                        if self.antispam and not self.antispam.check_contact(contact):
                            self.logger.info('Skipped a spam-basket from %s' % contact.name)
                            self.report_spam(basket['who']['id'])
                            continue

                        thread = Thread(int(basket['who']['id']))
                        thread.title = 'Basket of %s' % contact.name
                        thread.root = Message(thread=thread,
                                              id=self.MAGIC_ID_BASKET,
                                              title=thread.title,
                                              sender=contact.name,
                                              receivers=[my_name],
                                              date=parse_dt(basket['date']),
                                              content='You are taken in her basket!',
                                              signature=contact.get_text(),
                                              children=[],
                                              flags=Message.IS_UNREAD)
                        yield thread.root
        except BrowserUnavailable as e:
            self.logger.debug('No messages, browser is unavailable: %s' % e)
            pass  # don't care about waiting
开发者ID:blckshrk,项目名称:Weboob,代码行数:59,代码来源:backend.py


示例11: iter_threads

 def iter_threads(self):
     for msg in self.browser.iter_dates():
         thread = Thread(msg.id)
         thread.title = msg.title
         thread.date = msg.date
         thread.root = msg
         msg.thread = thread
         yield thread
开发者ID:P4ncake,项目名称:weboob,代码行数:8,代码来源:module.py


示例12: iter_threads

    def iter_threads(self):
        for thread in self.browser.get_threads():
            if not "person" in thread:
                # The account has been removed, probably because it was a
                # spammer.
                continue

            t = Thread(thread["_id"])
            t.flags = Thread.IS_DISCUSSION
            t.title = u"Discussion with %s" % thread["person"]["name"]
            contact = self.storage.get("contacts", t.id, default={"lastmsg": 0})

            birthday = parse_date(thread["person"]["birth_date"]).date()
            signature = u"Age: %d (%s)" % ((datetime.date.today() - birthday).days / 365.25, birthday)
            signature += u"\nLast ping: %s" % parse_date(thread["person"]["ping_time"]).strftime("%Y-%m-%d %H:%M:%S")
            signature += u"\nPhotos:\n\t%s" % "\n\t".join([photo["url"] for photo in thread["person"]["photos"]])
            signature += u"\n\n%s" % thread["person"]["bio"]

            t.root = Message(
                thread=t,
                id=1,
                title=t.title,
                sender=unicode(thread["person"]["name"]),
                receivers=[self.browser.my_name],
                date=parse_date(thread["created_date"]),
                content=u"Match!",
                children=[],
                signature=signature,
                flags=Message.IS_UNREAD if int(contact["lastmsg"]) < 1 else 0,
            )
            parent = t.root

            for msg in thread["messages"]:
                flags = 0
                if int(contact["lastmsg"]) < msg["timestamp"]:
                    flags = Message.IS_UNREAD

                msg = Message(
                    thread=t,
                    id=msg["timestamp"],
                    title=t.title,
                    sender=unicode(
                        self.browser.my_name if msg["from"] == self.browser.my_id else thread["person"]["name"]
                    ),
                    receivers=[
                        unicode(self.browser.my_name if msg["to"] == self.browser.my_id else thread["person"]["name"])
                    ],
                    date=parse_date(msg["sent_date"]),
                    content=unicode(msg["message"]),
                    children=[],
                    parent=parent,
                    signature=signature if msg["to"] == self.browser.my_id else u"",
                    flags=flags,
                )
                parent.children.append(msg)
                parent = msg

            yield t
开发者ID:ngrislain,项目名称:weboob,代码行数:58,代码来源:module.py


示例13: iter_threads

    def iter_threads(self):
        threads = self.browser.get_threads_list()

        for thread in threads:
            t = Thread(thread['userid'])
            t.flags = Thread.IS_DISCUSSION
            t.title = u'Discussion with %s' % thread['user']['username']
            t.date = datetime.fromtimestamp(thread['timestamp'])
            yield t
开发者ID:dasimon,项目名称:weboob,代码行数:9,代码来源:module.py


示例14: get_thread

    def get_thread(self, thread):
        if not isinstance(thread, Thread):
            thread = Thread(thread)
            thread.flags = Thread.IS_DISCUSSION

        user = self.browser.get_user(thread.id)
        thread.title = u'Discussion with %s' % user['name']

        contact = self.storage.get('contacts', thread.id, default={'lastmsg': 0})

        signature = u'Age: %s' % user['age']
        signature += u'\nLast online: %s' % user['last_online']
        signature += u'\nPhotos:\n\t%s' % '\n\t'.join([user['photo_host'] + photo['large'] for photo in user['photos']])

        child = None

        for msg in self.browser.get_thread_messages(thread.id):
            flags = 0
            if int(contact['lastmsg']) < msg['utc_timestamp']:
                flags = Message.IS_UNREAD

            if msg['type'] == 'msg':
                content = unicode(msg['msg'])
            elif msg['type'] == 'new_challenge':
                content = u'A new challenge has been proposed!'
            elif msg['type'] == 'serie':
                content = u"I've played"
            elif msg['type'] == 'end_game':
                content = u'%s is the winner! (%s VS %s)' % (self.browser.my_name if msg['score']['w'] == self.browser.my_id else user['name'], msg['score']['s'][0], msg['score']['s'][1])
            else:
                content = u'Unknown action: %s' % msg['type']

            msg = Message(thread=thread,
                          id=msg['utc_timestamp'],
                          title=thread.title,
                          sender=unicode(self.browser.my_name if msg['from'] == self.browser.my_id else user['name']),
                          receivers=[unicode(self.browser.my_name if msg['from'] != self.browser.my_id else user['name'])],
                          date=local2utc(datetime.datetime.fromtimestamp(msg['utc_timestamp'])),
                          content=content,
                          children=[],
                          parent=None,
                          signature=signature if msg['from'] != self.browser.my_id else u'',
                          flags=flags)

            if child:
                msg.children.append(child)
                child.parent = msg
            child = msg
        thread.root = child

        return thread
开发者ID:laurentb,项目名称:weboob,代码行数:51,代码来源:module.py


示例15: _iter_threads

    def _iter_threads(self, root_link=None):
        links = list(self.browser.iter_links(root_link.url if root_link else None))

        for link in links:
            if link.type == link.FORUM:
                link.title = '%s[%s]' % (root_link.title if root_link else '', link.title)
                for thread in self._iter_threads(link):
                    yield thread
            if link.type == link.TOPIC:
                thread = Thread(url2id(link.url))
                thread.title = ('%s ' % root_link.title if root_link else '') + link.title
                thread.date = link.date
                thread.flags = thread.IS_DISCUSSION
                yield thread
开发者ID:P4ncake,项目名称:weboob,代码行数:14,代码来源:module.py


示例16: iter_threads

    def iter_threads(self):
        with self.browser:
            threads = self.browser.get_threads_list()

        for thread in threads:
            # Remove messages from user that quit
            # if thread['member'].get('isBan', thread['member'].get('dead', False)):
            #    with self.browser:
            #        self.browser.delete_thread(thread['member']['id'])
            #    continue
            t = Thread(int(thread["id"]))
            t.flags = Thread.IS_DISCUSSION
            t.title = u"Discussion with %s" % thread["username"]
            yield t
开发者ID:hugues,项目名称:weboob,代码行数:14,代码来源:backend.py


示例17: get_thread

    def get_thread(self, id, getseen=True):
        if not isinstance(id, Thread):
            thread = None
        else:
            thread = id
            id = thread.id

            # Check if we have seen all comments of this thread.
            oldhash = self.storage.get('hash', id, default="")
            newhash = self.browser.get_hash(thread._rsscomment)
            if not getseen and oldhash == newhash:
                return None
            self.storage.set('hash', id, newhash)
            if thread.date:
                self.storage.set('date', id, thread.date)
            self.storage.save()

        with self.browser:
            content = self.browser.get_content(id)

        if not content:
            return None

        if not thread:
            thread = Thread(content.id)

        flags = Message.IS_HTML
        if not thread.id in self.storage.get('seen', default={}):
            flags |= Message.IS_UNREAD

        thread.title = content.title
        if not thread.date:
            thread.date = content.date

        thread.root = Message(thread=thread,
                              id='0',  # root message
                              title=content.title,
                              sender=content.author or u'',
                              receivers=None,
                              date=thread.date,
                              parent=None,
                              content=content.body,
                              signature='URL: %s' % self.browser.absurl(id2url(content.id)),
                              children=[],
                              flags=flags)

        for com in content.comments:
            self._insert_comment(com, thread.root, getseen)

        return thread
开发者ID:eirmag,项目名称:weboob,代码行数:50,代码来源:backend.py


示例18: iter_threads

    def iter_threads(self):
        whats = set()
        if self.config['get_news']:
            whats.add(self.RSS_NEWSPAPERS)
        if self.config['get_telegrams']:
            whats.add(self.RSS_TELEGRAMS)


        for what in whats:
            for article in Newsfeed(what, url2id).iter_entries():
                thread = Thread(article.id)
                thread.title = article.title
                if article.datetime:
                    thread.date = article.datetime
                yield thread
开发者ID:jocelynj,项目名称:weboob,代码行数:15,代码来源:backend.py


示例19: iter_threads_list

    def iter_threads_list(self):
        # site is sorted from latest to oldest
        for message_a in reversed(self.document.findAll('a', href=re.compile(r'message_read.php\?'))):
            ovs_id = re.search(r'Id=(\d+)', message_a["href"]).group(1)
            id_ = ovs_id

            thread = Thread(id_)
            thread.title = ovsparse.all_text_recursive(message_a)
            thread.flags = Thread.IS_DISCUSSION

            #~ parent_tr = message_a.findParent('tr')
            #~ username = all_text_recursive(parent_tr.find('a', href=re.compile(r'profil_read.php\?.*')))
            #~ notread_self = (parent_tr.get('class') == 'newmails')
            #~ notread_other = (parent_tr.find('span', **{'class': 'new_sortiepartenaire'}) is not None)

            yield thread
开发者ID:Konubinix,项目名称:weboob,代码行数:16,代码来源:pages.py


示例20: get_thread

    def get_thread(self, id, getseen=True):
        if not isinstance(id, Thread):
            thread = None
        else:
            thread = id
            id = thread.id

            if thread.date:
                self.storage.set("date", id, thread.date)
                self.storage.save()

        with self.browser:
            content = self.browser.get_content(id)

        if not content:
            return None

        if not thread:
            thread = Thread(content.id)

        flags = Message.IS_HTML
        if not thread.id in self.storage.get("seen", default={}):
            flags |= Message.IS_UNREAD

        thread.title = content.title
        if not thread.date:
            thread.date = content.date

        thread.root = Message(
            thread=thread,
            id="0",  # root message
            title=content.title,
            sender=content.author or u"",
            receivers=None,
            date=thread.date,
            parent=None,
            content=content.body,
            signature="URL: %s" % self.browser.absurl(id2url(content.id)),
            children=[],
            flags=flags,
        )

        for com in content.comments:
            self._insert_comment(com, thread.root, getseen)

        return thread
开发者ID:hugues,项目名称:weboob,代码行数:46,代码来源:backend.py



注:本文中的weboob.capabilities.messages.Thread类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python radio.Radio类代码示例发布时间:2022-05-26
下一篇:
Python housing.Query类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap