]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Add support for fetch modifiers (#62)
authorMenno Smits <menno@freshfoo.com>
Mon, 3 Jan 2011 22:28:12 +0000 (22:28 +0000)
committerMenno Smits <menno@freshfoo.com>
Mon, 3 Jan 2011 22:28:12 +0000 (22:28 +0000)
Patch from Thomas Jost Schnouki (schnouki@schnouki.net).

imapclient/imapclient.py

index 16aa8aa03d1321ad086d663e5a8306ab7cf25c58..665de6f5b5bbb4dfd659f1ad86e3bdd5e8a8ba68 100644 (file)
@@ -458,11 +458,12 @@ class IMAPClient(object):
         return self.add_flags(messages, DELETED)
 
 
-    def fetch(self, messages, parts):
+    def fetch(self, messages, parts, modifiers=None):
         """Retrieve selected data items for one or more messages.
 
         @param messages: Message IDs to fetch.
         @param parts: A sequence of data items to retrieve.
+        @param modifiers: An optional sequence of modifiers.
         @return: A dictionary indexed by message number. Each item is itself a
             dictionary containing the requested message parts.
             INTERNALDATE parts will be returned as datetime objects converted
@@ -473,11 +474,14 @@ class IMAPClient(object):
 
         msg_list = messages_to_str(messages)
         parts_list = seq_to_parenlist([p.upper() for p in parts])
+        modifiers_list = None
+        if modifiers is not None:
+          modifiers_list = seq_to_parenlist([m.upper() for m in modifiers])
 
         if self.use_uid:
-            tag = self._imap._command('UID', 'FETCH', msg_list, parts_list)
+            tag = self._imap._command('UID', 'FETCH', msg_list, parts_list, modifiers_list)
         else:
-            tag = self._imap._command('FETCH', msg_list, parts_list)
+            tag = self._imap._command('FETCH', msg_list, parts_list, modifiers_list)
         typ, data = self._imap._command_complete('FETCH', tag)
         self._checkok('fetch', typ, data)
         typ, data = self._imap._untagged_response(typ, data, 'FETCH')