]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Use correct "interact" imports for IPython 4
authorMenno Smits <menno@freshfoo.com>
Mon, 23 Nov 2015 23:43:45 +0000 (12:43 +1300)
committerMenno Smits <menno@freshfoo.com>
Mon, 23 Nov 2015 23:43:45 +0000 (12:43 +1300)
This avoids a deprecation warning during import.

Fixes #157.

imapclient/interact.py

index 1b8bf0c34dabd397a39798d1ba239507587f2e49..2afe58918cb1fa2cb47f9ddc84fb59f3f50db2c4 100644 (file)
@@ -60,6 +60,11 @@ def main():
     print('Connected.')
     banner = '\nIMAPClient instance is "c"'
 
+    def ipython_400(c):
+        from IPython.terminal.embed import InteractiveShellEmbed
+        ipshell = InteractiveShellEmbed(banner1=banner)
+        ipshell('')
+
     def ipython_011(c):
         from IPython.frontend.terminal.embed import InteractiveShellEmbed
         ipshell = InteractiveShellEmbed(banner1=banner)
@@ -73,12 +78,19 @@ def main():
         import code
         code.interact(banner, local=dict(c=c))
 
-    for shell_attempt in (ipython_011, ipython_010, builtin):
+    shell_attempts = (
+        ipython_400,
+        ipython_011,
+        ipython_010,
+        builtin,
+    )
+    for shell in shell_attempts:
         try:
-            shell_attempt(client)
-            break
+            shell(client)
         except ImportError:
             pass
+        else:
+            break
 
 if __name__ == '__main__':
     main()