]> khamidou — GitHub mirrors - imapclient.git/commitdiff
add import unicode_literals from __future__ everywhere, use print function
authorMathieu Agopian <mathieu.agopian@gmail.com>
Thu, 21 Mar 2013 19:14:29 +0000 (20:14 +0100)
committerMathieu Agopian <mathieu.agopian@gmail.com>
Thu, 21 Mar 2013 19:14:29 +0000 (20:14 +0100)
25 files changed:
imapclient/__init__.py
imapclient/config.py
imapclient/examples/example.py
imapclient/examples/idle_example.py
imapclient/examples/oauth_example.py
imapclient/fixed_offset.py
imapclient/imap_utf7.py
imapclient/imapclient.py
imapclient/imaplib_ssl_fix.py
imapclient/interact.py
imapclient/livetest.py
imapclient/pycompat.py
imapclient/response_lexer.py
imapclient/response_parser.py
imapclient/six.py
imapclient/test/mock.py
imapclient/test/test_fixed_offset.py
imapclient/test/test_imap_utf7.py
imapclient/test/test_imapclient.py
imapclient/test/test_response_parser.py
imapclient/test/test_version.py
imapclient/test/testable_imapclient.py
imapclient/test/util.py
interact.py
livetest.py

index 389fa9068be2e354b920fbc2f1d775a6eb99abfb..6bd5251dd908abcd1106ba1c11081c54eac1fdc8 100644 (file)
@@ -4,6 +4,9 @@
 
 # version_info provides the version number in programmer friendly way.
 # The 4th part will be either alpha, beta or final.
+
+from __future__ import unicode_literals
+
 version_info = (0, 9, 0, 'final')
 
 def _imapclient_version_string(vinfo):
index 68f0737d50d6a724011e2bc56d4b4aa495b46b57..b1fd2b91e6c561f5490ca885ba4d3237e1a44fcc 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
 try:
     from ConfigParser import SafeConfigParser, NoOptionError
 except ImportError:
index 5cec37cc4d4776c36a48fbf3b55a2b0047d64e26..72b421d42cb92996804b228364c64e158b509b55 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 from imapclient import IMAPClient
 
 HOST = 'imap.host.com'
@@ -13,15 +15,15 @@ server = IMAPClient(HOST, use_uid=True, ssl=ssl)
 server.login(USERNAME, PASSWORD)
 
 select_info = server.select_folder('INBOX')
-print '%d messages in INBOX' % select_info['EXISTS']
+print('%d messages in INBOX' % select_info['EXISTS'])
 
 messages = server.search(['NOT DELETED'])
-print "%d messages that aren't deleted" % len(messages)
+print("%d messages that aren't deleted" % len(messages))
 
-print
-print "Messages:"
+print()
+print("Messages:")
 response = server.fetch(messages, ['FLAGS', 'RFC822.SIZE'])
 for msgid, data in response.iteritems():
-    print '   ID %d: %d bytes, flags=%s' % (msgid,
+    print('   ID %d: %d bytes, flags=%s' % (msgid,
                                             data['RFC822.SIZE'],
-                                            data['FLAGS'])
+                                            data['FLAGS']))
index abb91294abed40c8251cb3348077241d5e570a61..b5cca4961216e6a1c0aefdb780f80d6e5b7d6652 100644 (file)
@@ -1,6 +1,8 @@
 # This example is a lot more interesting if you have an active client\r
 # connected to the same IMAP account!\r
 \r
+from __future__ import unicode_literals\r
+\r
 from imapclient import IMAPClient\r
 \r
 HOST = 'imap.host.com'\r
@@ -17,11 +19,11 @@ server.idle()
 \r
 # Wait for up to 30 seconds for an IDLE response\r
 responses = server.idle_check(timeout=30)\r
-print responses\r
+print(responses)\r
 \r
 # Come out of IDLE mode\r
 text, responses = server.idle_done()\r
-print 'IDLE done. Server said %r' % text\r
-print 'Final responses: ', responses\r
+print('IDLE done. Server said %r' % text)\r
+print('Final responses: ', responses)\r
     \r
-print server.logout()\r
+print(server.logout())\r
index 8ca45cdae53a00085185b65a0db07e7f2289811d..ecb0e42d2ddccee902c6eb1fe38dfbf9a21613c3 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals\r
+\r
 from imapclient import IMAPClient\r
 \r
 CONSUMER_KEY = ''\r
@@ -14,9 +16,9 @@ server = IMAPClient(HOST, use_uid=True, ssl=ssl)
 \r
 resp = server.oauth_login(URL, OAUTH_TOKEN, OAUTH_TOKEN_SECRET,\r
                          CONSUMER_KEY, CONSUMER_SECRET)\r
-print resp\r
+print(resp)\r
 \r
 select_info = server.select_folder('INBOX')\r
-print select_info\r
+print(select_info)\r
 \r
-server.logout()
\ No newline at end of file
+server.logout()\r
index dd0d9ca20c2a801693e4562cc4cf8d68a8d73ab5..89f3739b70d8f892202181ae96bf3a4c9bac7d38 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 import time
 from datetime import tzinfo, timedelta
 
index d7b2cdfa2e433a48acf3cb4592ed360ce5257f63..d6aa87d1fdd671315a76962775893344c0906c69 100644 (file)
@@ -22,6 +22,8 @@
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
+from __future__ import unicode_literals
+
 from .six import b, u, text_type, PY3, int2byte
 from .pycompat import iter_as_bytes
 
index 52b353799177f5114bf79ef200b1a611d4e469ed..17f083b50fb0ad64e11808f687b09650ffa93b9b 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 import imaplib
 import select
 import socket
index 719fd3a18264ecb73bc2faaf23637cf69e9ac46f..0a5246523eb175aa504d551bd693ba4e39f7fdea 100644 (file)
@@ -18,6 +18,8 @@ patched.
 Efforts are made to only perform the patch once.
 """
 
+from __future__ import unicode_literals
+
 import sys
 import imaplib
 
index 266fbdc15112e618f2f84b4a2bc189ee3a1b5535..716da3cb6d228adfca6254991e42072c73910016 100644 (file)
@@ -4,6 +4,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 
 from getpass import getpass
 from optparse import OptionParser
@@ -46,9 +48,9 @@ def command_line():
 
 def main():
     opts = command_line()
-    print 'Connecting...'
+    print('Connecting...')
     client = create_client_from_config(opts)
-    print 'Connected.'
+    print('Connected.')
     banner = '\nIMAPClient instance is "c"'
 
     def ipython_011(c):
index f97da2bc32b2f6869859af00ed83ad7061ac0b12..19f53cebbe18759d9328fd8cb23ea8c773001259 100644 (file)
@@ -4,6 +4,7 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import print_function, unicode_literals
 
 import imp
 import os
@@ -651,9 +652,9 @@ def have_matching_types(a, b, type_or_types):
     return isinstance(b, type(a))
 
 def argv_error(msg):
-    print >> sys.stderr, msg
-    print >> sys.stderr
-    print >> sys.stderr, "usage: %s <livetest.ini> [ optional unittest arguments ]" % sys.argv[0]
+    print(msg, file=sys.stderr)
+    print(file=sys.stderr)
+    print("usage: %s <livetest.ini> [ optional unittest arguments ]" % sys.argv[0], file=sys.stderr)
     sys.exit(1)
 
 def parse_argv():
index 3d1d9ee8595e670aeea7e6874d002581ff4c4ece..bff34e0d7e78498b7ab17383ca49a00ba956e032 100644 (file)
@@ -2,6 +2,8 @@
 Further Python 2/3 compatibility helpers that aren't provided by six.
 """
 
+from __future__ import unicode_literals
+
 from .six import PY3, int2byte
 
 if PY3:
index 029cf240fc316475ab6b54501a22cf9a58937bbf..ea0e89daad8e9e1eccbf3436661bbe41df97cb59 100644 (file)
@@ -14,6 +14,8 @@ use for external callers.
 # http://bugs.python.org/issue7594, but redone to be specific to IMAPs
 # requirements while offering nice performance by using generators everywhere.
 
+from __future__ import unicode_literals
+
 __all__ = ["Lexer"]
 
 from .six import advance_iterator, b
index c5758f0eac2c8f8a7f844a340e7dc48ebd45acd2..f5805f167f5b6a8780156bb670443895f04f9124 100644 (file)
@@ -11,6 +11,8 @@ Initially inspired by http://effbot.org/zone/simple-iterator-parser.htm
 
 #TODO more exact error reporting
 
+from __future__ import unicode_literals
+
 import sys
 from datetime import datetime
 
index 2331fe44bddfe6c27a2b2b957bd96865de1060ae..3493d9e6cb4b40258ee6772d02ae78cc47a73136 100644 (file)
@@ -1,5 +1,7 @@
 """Utilities for writing code that runs on Python 2 and 3"""
 
+from __future__ import unicode_literals
+
 import operator
 import sys
 import types
index 24799cf4c3b74f5dfa18083da7b1baebf48f86ad..0733d7158b3568cf718534a08d908be537011e11 100644 (file)
@@ -13,6 +13,8 @@
 # Comments, suggestions and bug reports welcome.
 
 
+from __future__ import unicode_literals
+
 __all__ = (
     'Mock',
     'MagicMock',
index c81b2b051396808e20b6cf3e072396dcc414ce64..2550e9be6e0eaf546743c5b6ddbb490e5465f73d 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 from datetime import timedelta
 from imapclient.test.util import unittest
 from imapclient.fixed_offset import FixedOffset
index 8ffdf3884ce09d92a561f68da489ece95f0a914a..cb8c090bd01f96c79a1b15f1857e304dee376ea3 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 from imapclient.six import b, u, binary_type, text_type, PY3
 from imapclient.imap_utf7 import decode, encode, FolderNameError
 from imapclient.test.util import unittest
index 3258884bf30ec8d5454f81a1343c1aed9939db46..f88733a201d88682bb03240bd4aaf51de1a8bf74 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 import itertools
 import socket
 import sys
index efcd00debbbf9a8a96f44a55a45efd711fde1b59..19f2c55ee71bbec92734833f6b86aa924ca4334a 100644 (file)
@@ -6,6 +6,8 @@
 Unit tests for the FetchTokeniser and FetchParser classes
 '''
 
+from __future__ import unicode_literals
+
 from datetime import datetime
 from textwrap import dedent
 
index a2d0d78fcb3b412b47dfb183ffe3a9bc685017ab..50fab5108cddeeda78b009b29b6dd0b138e6b867 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
 from imapclient import _imapclient_version_string
 from imapclient.test.util import unittest
 
index 26f9b016ce6933057b55dd3248ca10e3bae9ef93..dd33e153c0089c9020a24b537eaeee060b5f5fa9 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 from imapclient.imapclient import IMAPClient
 from imapclient.test.mock import Mock
 
index 232804761894f5b668cc376f9a7df3dc8078e979..3b45bad4cd94737b9a0c7c81e590ca2203fe218d 100644 (file)
@@ -2,6 +2,8 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 def find_unittest2():
     import unittest
     if hasattr(unittest, 'skip') and hasattr(unittest, 'loader'):
index ae273c8c1d19c53938ad787bff8078deda99625a..6ab81a3f780e6a07eb1a64648e59edd683a2c384 100755 (executable)
@@ -4,5 +4,7 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 from imapclient.interact import main
 main()
index a592f2221802511a1385983c250677e20407f3db..2621ae4026cf888e0cd49b3b700c5bed05b2d55a 100755 (executable)
@@ -4,5 +4,7 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+from __future__ import unicode_literals
+
 from imapclient.livetest import main
 main()