From: Menno Smits Date: Mon, 23 Nov 2015 23:43:45 +0000 (+1300) Subject: Use correct "interact" imports for IPython 4 X-Git-Tag: 1.0.0~1^2~4 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=06f0ba69aae062466605ac3253a17e2189c8d522;p=imapclient.git Use correct "interact" imports for IPython 4 This avoids a deprecation warning during import. Fixes #157. --- diff --git a/imapclient/interact.py b/imapclient/interact.py index 1b8bf0c..2afe589 100644 --- a/imapclient/interact.py +++ b/imapclient/interact.py @@ -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()