From: Mathieu Agopian Date: Thu, 28 Mar 2013 18:53:46 +0000 (+0100) Subject: flags shouldn't be quoted nor encoded to utf7, they're atoms X-Git-Tag: 0.10~2^2~21^2~22 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=69f338af26cda20b0aa819e28612978e3a64f58d;p=imapclient.git flags shouldn't be quoted nor encoded to utf7, they're atoms --- diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index ad8ca08..c72ac9c 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -207,8 +207,8 @@ class IMAPClient(object): character and ``%`` matches 0 or more characters except the folder delimiter. - Folder names are always returned as unicode strings except if - folder_decode is not set. + Folder names are always returned as unicode strings, and decoded from + modifier utf-7, except if folder_decode is not set. """ return self._do_list('LIST', directory, pattern) @@ -725,7 +725,6 @@ class IMAPClient(object): time_val = time_val.encode('ascii') else: time_val = None - flags = self.quote_encode_flags(flags) return self._command_and_check('append', self._imap._quote(folder), seq_to_parenlist(flags), @@ -839,7 +838,6 @@ class IMAPClient(object): """ if not messages: return {} - flags = self.quote_encode_flags(flags) data = self._command_and_check('store', messages_to_str(messages), cmd, @@ -890,15 +888,6 @@ class IMAPClient(object): self.log_file.write('%s %s\n' % (datetime.now().strftime('%M:%S.%f'), text)) self.log_file.flush() - def quote_encode_flags(self, flags): - """Encode to modified utf-7 if needed and quote.""" - if isinstance(flags, text_type): - flags = (flags,) - flags = [self._imap._quote(flag) for flag in flags] - if self.folder_encode: - flags = [encode_utf7(flag) for flag in flags] - return flags - def messages_to_str(messages): """Convert a sequence of messages ids or a single integer message id diff --git a/imapclient/test/test_imapclient.py b/imapclient/test/test_imapclient.py index c5f3619..238eba8 100644 --- a/imapclient/test/test_imapclient.py +++ b/imapclient/test/test_imapclient.py @@ -130,7 +130,7 @@ class TestAppend(IMAPClientTest): self.client.append('foobar', msg, ['FLAG', 'WAVE'], None) self.client._imap.append.assert_called_with( - '"foobar"', '("FLAG" "WAVE")', None, sentinel.msg) + '"foobar"', '(FLAG WAVE)', None, sentinel.msg) @patch('imapclient.imapclient.datetime_to_imap') def test_with_msg_time(self, datetime_to_imap): @@ -144,7 +144,7 @@ class TestAppend(IMAPClientTest): self.assertTrue(datetime_to_imap.called) self.client._imap.append.assert_called_with( - '"foobar"', '("FLAG" "WAVE")', '"somedate"', sentinel.msg) + '"foobar"', '(FLAG WAVE)', '"somedate"', sentinel.msg) class TestDateTimeToImap(unittest.TestCase):