From 39b1d77facf0dcb451ba76eb2186645266a4515e Mon Sep 17 00:00:00 2001 From: Gergely Imreh Date: Fri, 19 Mar 2010 10:21:05 +0800 Subject: [PATCH] tweepyshell: add support for IPython, with fallback to code.interact IPython is a much versatile interactive shell compared to code, use it's power if awailable. Signed-off-by: Gergely Imreh --- tweepyshell | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tweepyshell b/tweepyshell index eefb85a..6ba854d 100755 --- a/tweepyshell +++ b/tweepyshell @@ -2,7 +2,6 @@ import sys -import code from getpass import getpass from optparse import OptionParser import tweepy @@ -33,5 +32,14 @@ else: if options.debug: tweepy.debug() -code.interact('', local={'tweepy': tweepy, 'api': API(auth)}) +local_ns = {'tweepy': tweepy, 'api': API(auth)} +shellbanner = '' + +try: + import IPython + ipshell = IPython.Shell.IPShell(user_ns = local_ns) + ipshell.mainloop(sys_exit=1, banner = shellbanner) +except ImportError: + import code + code.interact(shellbanner, local = local_ns) -- 2.25.1