Changeset 244:dc0d90049f28

Show
Ignore:
Timestamp:
28/02/11 13:34:27 (15 months ago)
Author:
Menno Smits <menno@…>
Branch:
default
Message:

filled in many more documentatation gaps

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • doc-src/index.rst

    r240 r244  
    9191 
    9292 
    93 More Examples 
    94 ------------- 
    95 XXX 
    96  
    97  
    9893Indices and tables 
    9994================== 
  • imapclient/imapclient.py

    r243 r244  
    131131 
    132132    def get_folder_delimiter(self): 
    133         """Determine the folder separator used by the IMAP server. 
     133        """Return the folder separator used by the IMAP server. 
    134134 
    135135        WARNING: The implementation just picks the first folder 
    136136        separator from the first namespace returned. This is not 
    137137        particularly sensible. Use namespace instead(). 
    138  
    139         @return: The folder separator. 
    140         @rtype: string 
    141138        """ 
    142139        warnings.warn(DeprecationWarning('get_folder_delimiter is going away. Use namespace() instead.')) 
     
    155152        Specifying *directory* will limit returned folders to that 
    156153        base directory. Specifying *pattern* will limit returned 
    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. 
    168161        """ 
    169162        return self._do_list('LIST', directory, pattern) 
    170163 
    171164    def xlist_folders(self, directory="", pattern="*"): 
    172         """Execute the XLIST command, returning``(flags, delimiter, 
     165        """Execute the XLIST command, returning ``(flags, delimiter, 
    173166        name)`` tuples. 
    174167 
    175168        This method returns special flags for each folder and a 
    176169        localized name for certain folders (e.g. the name of the 
    177         'inbox' may be localized and the flags can be used to 
     170        inbox may be localized and the flags can be used to 
    178171        determine the actual inbox, even if the name has been 
    179172        localized. 
    180173 
    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 
    183186        This is a Gmail-specific IMAP extension. It is the 
    184         responsibility of the caller to either check for 'XLIST' in 
     187        responsibility of the caller to either check for ``XLIST`` in 
    185188        the server capabilites, or to handle the error if the server 
    186189        doesn't support this externsion. 
     
    222225 
    223226    def select_folder(self, folder, readonly=False): 
    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 
    231236            {'EXISTS': 3, 
    232237             'FLAGS': ('\\Answered', '\\Flagged', '\\Deleted', ... ), 
     
    410415        """Add *flags* to *messages*. 
    411416 
    412         *flags* should be a sequence of strings. Returns the flags set 
    413          for each modified message (see *get_flags*). 
     417        *flags* should be a sequence of strings. 
     418 
     419        Returns the flags set for each modified message (see 
     420        *get_flags*). 
    414421        """ 
    415422        return self._store('+FLAGS', messages, flags) 
     
    444451 
    445452 
    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 
    457480        """ 
    458481        if not messages: 
     
    460483 
    461484        msg_list = messages_to_str(messages) 
    462         parts_list = seq_to_parenlist([p.upper() for p in parts]) 
     485        data_list = seq_to_parenlist([p.upper() for p in data]) 
    463486        modifiers_list = None 
    464487        if modifiers is not None: 
     
    466489 
    467490        if self.use_uid: 
    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) 
    471494        typ, data = self._imap._command_complete('FETCH', tag) 
    472495        self._checkok('fetch', typ, data) 
     
    520543 
    521544    def expunge(self): 
    522         """Remove any messaages from the server that have the \Deleted 
    523         flag set. 
    524  
    525         XXX check if this is just for the current folder 
     545        """Remove any messages from the currently selected folder that 
     546        have the ``\\Deleted`` flag set. 
    526547        """ 
    527548        typ, data = self._imap.expunge()