当前位置: 首页>>代码示例>>Python>>正文


Python imap.ImapThread类代码示例

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


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

示例1: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg, folder):
        """ Post-create-message bits."""
        with db_session.no_autoflush:
            parent_threads = self.fetch_similar_threads(db_session, new_uid)
            construct_new_thread = True

            if parent_threads:
                # If there's a parent thread that isn't too long already,
                # add to it. Otherwise create a new thread.
                parent_thread = parent_threads[0]
                parent_message_count, = db_session.query(
                    func.count(Message.id)). \
                    filter(Message.thread_id == parent_thread.id).one()
                if parent_message_count < MAX_THREAD_LENGTH:
                    construct_new_thread = False

            if construct_new_thread:
                new_uid.message.thread = ImapThread.from_imap_message(
                    db_session, new_uid.account.namespace, new_uid.message)
                new_uid.message.thread_order = 0
            else:
                parent_thread = parent_threads[0]
                parent_thread.messages.append(new_uid.message)
                constructed_thread = thread_messages(parent_thread.messages)
                for index, message in enumerate(constructed_thread):
                    message.thread_order = index

        db_session.flush()
        # Make sure this thread has all the correct labels
        common.add_any_new_thread_labels(new_uid.message.thread, new_uid,
                                         db_session)
        new_uid.update_imap_flags(msg.flags)
        return new_uid
开发者ID:GEverding,项目名称:inbox,代码行数:33,代码来源:generic.py

示例2: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg, folder):
        """ Gmail-specific post-create-message bits. """
        # Disable autoflush so we don't try to flush a message with null
        # thread_id, causing a crash, and so that we don't flush on each
        # added/removed label.
        with db_session.no_autoflush:
            new_uid.message.g_msgid = msg.g_msgid
            # NOTE: g_thrid == g_msgid on the first message in the thread :)
            new_uid.message.g_thrid = msg.g_thrid

            # we rely on Gmail's threading instead of our threading algorithm.
            new_uid.message.thread_order = 0
            new_uid.update_imap_flags(msg.flags, msg.g_labels)

            # FIXME: @karim not sure if it's necessary to clean up strings like
            # \\Inbox, \\Trash, etc.
            new_uid.g_labels = [label for label in msg.g_labels]

            thread = new_uid.message.thread = ImapThread.from_gmail_message(
                db_session, new_uid.account.namespace, new_uid.message)

            # make sure this thread has all the correct labels
            common.update_thread_labels(thread, folder.name, msg.g_labels,
                                        db_session)
            return new_uid
开发者ID:cruiser,项目名称:inbox,代码行数:25,代码来源:gmail.py

示例3: add_gmail_attrs

def add_gmail_attrs(db_session, log, new_uid, flags, folder, g_thrid, g_msgid,
                    g_labels, created):
    """ Gmail-specific post-create-message bits. """
    # Disable autoflush so we don't try to flush a message with null
    # thread_id, causing a crash, and so that we don't flush on each
    # added/removed label.
    with db_session.no_autoflush:
        new_uid.message.g_msgid = g_msgid
        # NOTE: g_thrid == g_msgid on the first message in the thread :)
        new_uid.message.g_thrid = g_thrid
        new_uid.update_imap_flags(flags, g_labels)

        thread = new_uid.message.thread = ImapThread.from_gmail_message(
            db_session, new_uid.account.namespace, new_uid.message)

        # make sure this thread has all the correct labels
        new_labels = account.update_thread_labels(thread, folder.name,
                                                  g_labels, db_session)

        # Reconciliation for Drafts, Sent Mail folders:
        if (('draft' in new_labels or 'sent' in new_labels) and not
                created and new_uid.message.inbox_uid):
            reconcile_message(db_session, log, new_uid.message.inbox_uid,
                              new_uid.message)

        return new_uid
开发者ID:PaulReiber,项目名称:inbox,代码行数:26,代码来源:gmail.py

示例4: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg):
        """ Post-create-message bits."""
        with db_session.no_autoflush:
            parent_thread = fetch_corresponding_thread(
                db_session, self.namespace_id, new_uid.message)
            construct_new_thread = True

            if parent_thread:
                # If there's a parent thread that isn't too long already,
                # add to it. Otherwise create a new thread.
                parent_message_count = self._count_thread_messages(
                    parent_thread.id, db_session)
                if parent_message_count < MAX_THREAD_LENGTH:
                    construct_new_thread = False

            if construct_new_thread:
                new_uid.message.thread = ImapThread.from_imap_message(
                    db_session, new_uid.account.namespace, new_uid.message)
            else:
                parent_thread.messages.append(new_uid.message)

        db_session.flush()
        # Make sure this thread has all the correct labels
        common.add_any_new_thread_labels(new_uid.message.thread, new_uid,
                                         db_session)
        new_uid.update_flags_and_labels(msg.flags)
        return new_uid
开发者ID:biddyweb,项目名称:sync-engine,代码行数:27,代码来源:generic.py

示例5: add_message_to_thread

    def add_message_to_thread(self, db_session, message_obj, raw_message):
        """
        Associate message_obj to the right Thread object, creating a new
        thread if necessary.

        """
        with db_session.no_autoflush:
            # Disable autoflush so we don't try to flush a message with null
            # thread_id.
            parent_thread = fetch_corresponding_thread(
                db_session, self.namespace_id, message_obj)
            construct_new_thread = True

            if parent_thread:
                # If there's a parent thread that isn't too long already,
                # add to it. Otherwise create a new thread.
                parent_message_count = self._count_thread_messages(
                    parent_thread.id, db_session)
                if parent_message_count < MAX_THREAD_LENGTH:
                    construct_new_thread = False

            if construct_new_thread:
                message_obj.thread = ImapThread.from_imap_message(
                    db_session, self.namespace_id, message_obj)
            else:
                parent_thread.messages.append(message_obj)
开发者ID:tahajahangir,项目名称:sync-engine,代码行数:26,代码来源:generic.py

示例6: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg, folder):
        """ Gmail-specific post-create-message bits. """
        # Disable autoflush so we don't try to flush a message with null
        # thread_id, causing a crash, and so that we don't flush on each
        # added/removed label.
        with db_session.no_autoflush:
            new_uid.message.g_msgid = msg.g_msgid
            # NOTE: g_thrid == g_msgid on the first message in the thread :)
            new_uid.message.g_thrid = msg.g_thrid

            # we rely on Gmail's threading instead of our threading algorithm.
            new_uid.message.thread_order = 0
            new_uid.update_imap_flags(msg.flags, msg.g_labels)

            thread = new_uid.message.thread = ImapThread.from_gmail_message(
                db_session, new_uid.account.namespace, new_uid.message)

            # make sure this thread has all the correct labels
            new_labels = common.update_thread_labels(thread, folder.name,
                                                     msg.g_labels, db_session)

            # Reconciliation for Drafts, Sent Mail folders:
            if (('draft' in new_labels or 'sent' in new_labels) and not
                    msg.created and new_uid.message.inbox_uid):
                reconcile_message(db_session, new_uid.message.inbox_uid,
                                  new_uid.message)

            return new_uid
开发者ID:mishravikas,项目名称:inbox,代码行数:28,代码来源:gmail.py

示例7: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg, folder):
        """ Post-create-message bits."""
        with db_session.no_autoflush:
            clean_subject = cleanup_subject(new_uid.message.subject)
            parent_threads = db_session.query(ImapThread).filter(
                ImapThread.subject.like(clean_subject)).all()

            if parent_threads == []:
                new_uid.message.thread = ImapThread.from_imap_message(
                    db_session, new_uid.account.namespace, new_uid.message)
                new_uid.message.thread_order = 0
            else:
                # FIXME: arbitrarily select the first thread. This shouldn't
                # be a problem now but it could become one if we choose
                # to implement thread-splitting.
                parent_thread = parent_threads[0]
                parent_thread.messages.append(new_uid.message)
                constructed_thread = thread_messages(parent_thread.messages)
                for index, message in enumerate(constructed_thread):
                    message.thread_order = index

            # Make sure this thread has all the correct labels
            common.update_thread_labels(new_uid.message.thread, folder.name,
                                        [folder.canonical_name], db_session)
            new_uid.update_imap_flags(msg.flags)

            return new_uid
开发者ID:mdeng1024,项目名称:inbox,代码行数:27,代码来源:generic.py

示例8: add_message_to_thread

 def add_message_to_thread(self, db_session, message_obj, raw_message):
     """Associate message_obj to the right Thread object, creating a new
     thread if necessary. We rely on Gmail's threading as defined by
     X-GM-THRID instead of our threading algorithm."""
     # NOTE: g_thrid == g_msgid on the first message in the thread
     message_obj.g_msgid = raw_message.g_msgid
     message_obj.g_thrid = raw_message.g_thrid
     with db_session.no_autoflush:
         # Disable autoflush so we don't try to flush a message with null
         # thread_id.
         message_obj.thread = ImapThread.from_gmail_message(db_session, self.namespace_id, message_obj)
开发者ID:rf-,项目名称:sync-engine,代码行数:11,代码来源:gmail.py

示例9: add_yahoo_attrs

def add_yahoo_attrs(db_session, log, new_uid, flags, folder, created):
    """ Yahoo-specific post-create-message bits."""
    with db_session.no_autoflush:
        new_uid.message.thread = ImapThread.from_yahoo_message(
            db_session, new_uid.account.namespace, new_uid.message)
        new_uid.update_imap_flags(flags)

        if folder in ('draft', 'sent') and not created and new_uid.message.inbox_uid:
            reconcile_message(db_session, log, new_uid.message.inbox_uid,
                              new_uid.message)

        return new_uid
开发者ID:AmyWeiner,项目名称:inbox,代码行数:12,代码来源:yahoo.py

示例10: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg):
        """ Gmail-specific post-create-message bits. """
        # Disable autoflush so we don't try to flush a message with null
        # thread_id, causing a crash, and so that we don't flush on each
        # added/removed label.
        with db_session.no_autoflush:
            # NOTE: g_thrid == g_msgid on the first message in the thread :)
            new_uid.message.g_msgid = msg.g_msgid
            new_uid.message.g_thrid = msg.g_thrid

            # We rely on Gmail's threading instead of our threading algorithm.
            new_uid.message.thread = ImapThread.from_gmail_message(
                db_session, new_uid.account.namespace, new_uid.message)

        return new_uid
开发者ID:wakermahmud,项目名称:sync-engine,代码行数:15,代码来源:gmail.py

示例11: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg):
        """ Gmail-specific post-create-message bits. """
        # Disable autoflush so we don't try to flush a message with null
        # thread_id, causing a crash, and so that we don't flush on each
        # added/removed label.
        with db_session.no_autoflush:
            new_uid.message.g_msgid = msg.g_msgid
            # NOTE: g_thrid == g_msgid on the first message in the thread :)
            new_uid.message.g_thrid = msg.g_thrid

            # we rely on Gmail's threading instead of our threading algorithm.
            new_uid.update_flags_and_labels(msg.flags, msg.g_labels)

            thread = new_uid.message.thread = ImapThread.from_gmail_message(
                db_session, new_uid.account.namespace, new_uid.message)

        # make sure this thread has all the correct labels
        common.add_any_new_thread_labels(thread, new_uid, db_session)
        return new_uid
开发者ID:PriviPK,项目名称:privipk-sync-engine,代码行数:19,代码来源:gmail.py

示例12: add_attrs

def add_attrs(db_session, log, new_uid, flags, folder, created):
    """ Post-create-message bits."""
    with db_session.no_autoflush:
        clean_subject = cleanup_subject(new_uid.message.subject)
        parent_threads = db_session.query(ImapThread).filter(
            ImapThread.subject.like(clean_subject)).all()

        if parent_threads == []:
            new_uid.message.thread = ImapThread.from_imap_message(
                db_session, new_uid.account.namespace, new_uid.message)
            new_uid.message.thread_order = 0
        else:
            # FIXME: arbitrarily select the first thread. This shouldn't
            # be a problem now but it could become one if we choose
            # to implement thread-splitting.
            parent_thread = parent_threads[0]
            parent_thread.messages.append(new_uid.message)
            constructed_thread = thread_messages(parent_thread.messages)
            for index, message in enumerate(constructed_thread):
                message.thread_order = index

        # FIXME: refactor 'new_labels' name. This is generic IMAP, not
        # gmail.
        # make sure this thread has all the correct labels
        new_labels = account.update_thread_labels(new_uid.message.thread,
                                                  folder.name,
                                                  [folder.canonical_name],
                                                  db_session)

        # Reconciliation for Drafts, Sent Mail folders:
        if (('draft' in new_labels or 'sent' in new_labels) and not
                created and new_uid.message.inbox_uid):
            reconcile_message(db_session, log, new_uid.message.inbox_uid,
                              new_uid.message)

        new_uid.update_imap_flags(flags)

        return new_uid
开发者ID:rayleyva,项目名称:inbox,代码行数:38,代码来源:imap.py

示例13: add_message_attrs

    def add_message_attrs(self, db_session, new_uid, msg, folder):
        """ Post-create-message bits."""
        with db_session.no_autoflush:
            parent_threads = self.fetch_similar_threads(db_session, new_uid)
            construct_new_thread = True

            if parent_threads:
                # If there's a parent thread that isn't too long already,
                # add to it. Otherwise create a new thread.
                parent_thread = parent_threads[0]
                parent_message_count, = db_session.query(
                    func.count(Message.id)). \
                    filter(Message.thread_id == parent_thread.id).one()
                if parent_message_count < MAX_THREAD_LENGTH:
                    construct_new_thread = False

            if construct_new_thread:
                new_uid.message.thread = ImapThread.from_imap_message(
                    db_session, new_uid.account.namespace, new_uid.message)
                new_uid.message.thread_order = 0
            else:
                # FIXME: arbitrarily select the first thread. This shouldn't
                # be a problem now but it could become one if we choose
                # to implement thread-splitting.
                parent_thread = parent_threads[0]
                parent_thread.messages.append(new_uid.message)
                constructed_thread = thread_messages(parent_thread.messages)
                for index, message in enumerate(constructed_thread):
                    message.thread_order = index

            # Make sure this thread has all the correct labels
            common.update_thread_labels(new_uid.message.thread, folder.name,
                                        [folder.canonical_name], db_session)
            new_uid.update_imap_flags(msg.flags)

            return new_uid
开发者ID:FrictionlessCoin,项目名称:inbox,代码行数:36,代码来源:generic.py


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