summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-01-16 17:24:27 -0400
committerKali Kaneko <kali@leap.se>2014-01-16 17:24:27 -0400
commit557fac26982aa1360ed51d158869312d6438eb84 (patch)
tree136192bffa64c29a895c030982a3ff149fcdedb7
parent759a3fff83252c6ef67434a860574da49b066df4 (diff)
factor out bound and filter for msg seqs
-rw-r--r--src/leap/mail/imap/mailbox.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py
index 86dac77..84eb528 100644
--- a/src/leap/mail/imap/mailbox.py
+++ b/src/leap/mail/imap/mailbox.py
@@ -467,6 +467,36 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
d.addCallback(self._expunge_cb)
return d
+ def _bound_seq(self, messages_asked):
+ """
+ Put an upper bound to a messages sequence if this is open.
+
+ :param messages_asked: IDs of the messages.
+ :type messages_asked: MessageSet
+ :rtype: MessageSet
+ """
+ if not messages_asked.last:
+ try:
+ iter(messages_asked)
+ except TypeError:
+ # looks like we cannot iterate
+ messages_asked.last = self.last_uid
+ return messages_asked
+
+ def _filter_msg_seq(self, messages_asked):
+ """
+ Filter a message sequence returning only the ones that do exist in the
+ collection.
+
+ :param messages_asked: IDs of the messages.
+ :type messages_asked: MessageSet
+ :rtype: set
+ """
+ set_asked = set(messages_asked)
+ set_exist = set(self.messages.all_uid_iter())
+ seq_messg = set_asked.intersection(set_exist)
+ return seq_messg
+
@deferred
def fetch(self, messages_asked, uid):
"""