From: Menno Smits Date: Fri, 14 Jan 2011 13:07:38 +0000 (+0000) Subject: get_folder_delimiter tidied up and deprecated X-Git-Tag: 0.7~3^2~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5036172c0beb407279eacc14b015958b5a0d76f4;p=imapclient.git get_folder_delimiter tidied up and deprecated --- diff --git a/NEWS b/NEWS index 3cfb409..86542d5 100644 --- a/NEWS +++ b/NEWS @@ -52,7 +52,7 @@ example. Added NAMESPACE support (#63) ----------------------------- -See the namespace() method. +namespace() method added and get_folder_delimiter() has been deprecated. =============== Version 0.6.2 diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index fa239a9..fc3044b 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -6,6 +6,7 @@ import re import imaplib import response_lexer from operator import itemgetter +import warnings #imaplib.Debug = 5 import imap_utf7 @@ -160,17 +161,18 @@ class IMAPClient(object): def get_folder_delimiter(self): """Determine the folder separator used by the IMAP server. + WARNING: The implementation just picks the first folder + separator from the first namespace returned. This is not + particularly sensible. Use namespace instead(). + @return: The folder separator. @rtype: string """ - typ, data = self._imap.namespace() - self._checkok('namespace', typ, data) - - match = self.re_sep.match(data[0]) - if match: - return match.group(1) - else: - raise self.Error('could not determine folder separator') + warnings.warn(DeprecationWarning('get_folder_delimiter is going away. Use namespace() instead.')) + for part in self.namespace(): + for ns in part: + return ns[1] + raise self.Error('could not determine folder separator') def list_folders(self, directory="", pattern="*"): """Get a listing of folders on the server.