summaryrefslogtreecommitdiff
path: root/mail/src
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
commit6b7337bf23303c8cb04f7c3b13a8a753ea153567 (patch)
tree079f69ae14437f80fb3ce2df847c7e628be5f322 /mail/src
parentb5f2c2596af6a7143718ca97e9ce15bcbaacfb9b (diff)
factor out bound and filter for msg seqs
Diffstat (limited to 'mail/src')
-rw-r--r--mail/src/leap/mail/imap/mailbox.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py
index 86dac778..84eb528c 100644
--- a/mail/src/leap/mail/imap/mailbox.py
+++ b/mail/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):
"""