Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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 <imrehg@gmail.com>
  • Loading branch information...
commit 39b1d77facf0dcb451ba76eb2186645266a4515e 1 parent 006d21c
@imrehg imrehg authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 tweepyshell
View
12 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('<Tweepy shell>', local={'tweepy': tweepy, 'api': API(auth)})
+local_ns = {'tweepy': tweepy, 'api': API(auth)}
+shellbanner = '<Tweepy shell>'
+
+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)
Please sign in to comment.
Something went wrong with that request. Please try again.