| 157 | | folders to those with matching names. Wildcards (``*`` and |
| 158 | | ``?``) are supported in *pattern*. |
| 159 | | |
| 160 | | #XXX check wildcard facts |
| 161 | | |
| 162 | | Each folder name will be either a string or a unicode string |
| 163 | | (if the folder on the server required decoding). If the |
| 164 | | folder_encode attribute is False, no decoding will be |
| 165 | | performed and only ordinary strings will be returned. |
| 166 | | |
| 167 | | #XXX check the above is still true |
| | 154 | folders to those with matching names. The wildcards are |
| | 155 | supported in *pattern*. ``*`` matches zero or more of any |
| | 156 | character and ``%`` matches 0 or more characters except the |
| | 157 | folder delimiter. |
| | 158 | |
| | 159 | Folder names are always returned as unicode strings except if |
| | 160 | folder_decode is not set. |
| 181 | | XXX example response |
| 182 | | |
| | 174 | A ``XLIST`` response could look something like:: |
| | 175 | |
| | 176 | [([u'\\HasNoChildren', u'\\Inbox'], '/', u'Inbox'), |
| | 177 | ([u'\\Noselect', u'\\HasChildren'], '/', u'[Gmail]'), |
| | 178 | ([u'\\HasNoChildren', u'\\AllMail'], '/', u'[Gmail]/All Mail'), |
| | 179 | ([u'\\HasNoChildren', u'\\Drafts'], '/', u'[Gmail]/Drafts'), |
| | 180 | ([u'\\HasNoChildren', u'\\Important'], '/', u'[Gmail]/Important'), |
| | 181 | ([u'\\HasNoChildren', u'\\Sent'], '/', u'[Gmail]/Sent Mail'), |
| | 182 | ([u'\\HasNoChildren', u'\\Spam'], '/', u'[Gmail]/Spam'), |
| | 183 | ([u'\\HasNoChildren', u'\\Starred'], '/', u'[Gmail]/Starred'), |
| | 184 | ([u'\\HasNoChildren', u'\\Trash'], '/', u'[Gmail]/Trash')] |
| | 185 | |
| 224 | | """Select the current folder on the server. Future calls to methods |
| 225 | | such as search and fetch will act on the selected folder. |
| 226 | | |
| 227 | | @param folder: The folder name. |
| 228 | | @return: A dictionary containing the SELECT response |
| 229 | | values. At least the EXISTS, FLAGS and RECENT keys are |
| 230 | | guaranteed to exist. Example: |
| | 227 | """Set the current folder on the server. |
| | 228 | |
| | 229 | Future calls to methods such as search and fetch will act on |
| | 230 | the selected folder. |
| | 231 | |
| | 232 | Returns a dictionary containing the ``SELECT`` response. At least |
| | 233 | the ``EXISTS``, ``FLAGS`` and ``RECENT`` keys are guaranteed |
| | 234 | to exist. An example:: |
| | 235 | |
| 446 | | def fetch(self, messages, parts, modifiers=None): |
| 447 | | """Retrieve selected data items for one or more messages. |
| 448 | | |
| 449 | | @param messages: Message IDs to fetch. |
| 450 | | @param parts: A sequence of data items to retrieve. |
| 451 | | @param modifiers: An optional sequence of modifiers (where |
| 452 | | supported by the server, eg. ['CHANGEDSINCE 123']). |
| 453 | | @return: A dictionary indexed by message number. Each item is itself a |
| 454 | | dictionary containing the requested message parts. |
| 455 | | INTERNALDATE parts will be returned as datetime objects converted |
| 456 | | to the local machine's time zone. |
| | 453 | def fetch(self, messages, data, modifiers=None): |
| | 454 | """Retrieve selected *data* associated with one or more *messages*. |
| | 455 | |
| | 456 | *data* should be specified as a sequnce of strings, one item |
| | 457 | per data selector, for example ``['INTERNALDATE', |
| | 458 | 'RFC822']``. |
| | 459 | |
| | 460 | *modifiers* are required for some extensions to the IMAP |
| | 461 | protocol (eg. RFC 4551). These should be a sequnce of strings |
| | 462 | if specified, for example ``['CHANGEDSINCE 123']``. |
| | 463 | |
| | 464 | A dictionary is returned, indexed by message number. Each item |
| | 465 | in this dictionary is also a dictionary, with an entry |
| | 466 | corresponding to each item in *data*. |
| | 467 | |
| | 468 | XXX document SEQ |
| | 469 | |
| | 470 | Example:: |
| | 471 | |
| | 472 | >> c.fetch([3293, 3230], ['INTERNALDATE', 'FLAGS']) |
| | 473 | {3230: {'FLAGS': ('\\Seen',), |
| | 474 | 'INTERNALDATE': datetime.datetime(2011, 1, 30, 13, 32, 9), |
| | 475 | 'SEQ': 84}, |
| | 476 | 3293: {'FLAGS': (), |
| | 477 | 'INTERNALDATE': datetime.datetime(2011, 2, 24, 19, 30, 36), |
| | 478 | 'SEQ': 110}} |
| | 479 | |
| 468 | | tag = self._imap._command('UID', 'FETCH', msg_list, parts_list, modifiers_list) |
| 469 | | else: |
| 470 | | tag = self._imap._command('FETCH', msg_list, parts_list, modifiers_list) |
| | 491 | tag = self._imap._command('UID', 'FETCH', msg_list, data_list, modifiers_list) |
| | 492 | else: |
| | 493 | tag = self._imap._command('FETCH', msg_list, data_list, modifiers_list) |