rlineimpl.py
54 lines
| 1.8 KiB
| text/x-python
|
PythonLexer
/ IPython / rlineimpl.py
vivainio
|
r161 | # -*- coding: utf-8 -*- | ||
""" Imports and provides the "correct" version of readline for the platform. | ||||
Readline is used throughout IPython as "import IPython.rlineimpl as readline. | ||||
In addition to normal readline stuff, this module provides have_readline boolean | ||||
and _outputfile variable used in genutils. | ||||
$Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $""" | ||||
import sys | ||||
have_readline = False | ||||
if sys.platform == 'win32': | ||||
try: | ||||
vivainio
|
r257 | import pyreadline.rlmain | ||
#add config for inputrcpath here: | ||||
#pyreadline.rlmain.config_path="c:/python/test_config.ini" | ||||
from readline import * | ||||
vivainio
|
r268 | #print "Using the new pyreadline (thanks for participating in the testing!)" | ||
vivainio
|
r257 | |||
vivainio
|
r161 | have_readline = True | ||
vivainio
|
r257 | |||
import readline as _rl | ||||
vivainio
|
r161 | except ImportError: | ||
vivainio
|
r268 | #print "IPython team recommends the new pyreadline for Windows use, " | ||
#print "It's superior especially with non-US keyboard layouts." | ||||
#print "Try installing it with 'easy_install pyreadline (ctypes is required) or" | ||||
#print "svn co http://ipython.scipy.org/svn/ipython/pyreadline/trunk pyreadline" | ||||
#print "Trying 'old' windows readline." | ||||
vivainio
|
r307 | #print "Using 'old' readline, you might want to try pyreadline:" | ||
#print "http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro" | ||||
vivainio
|
r162 | try: | ||
from readline import * | ||||
vivainio
|
r164 | import readline as _rl | ||
vivainio
|
r162 | have_readline = True | ||
except ImportError: | ||||
pass | ||||
if have_readline: | ||||
try: | ||||
vivainio
|
r164 | _outputfile=_rl.GetOutputFile() | ||
vivainio
|
r162 | except NameError: | ||
vivainio
|
r164 | print "Failed GetOutputFile" | ||
vivainio
|
r162 | have_readline = False | ||
vivainio
|
r161 | else: | ||
try: | ||||
from readline import * | ||||
have_readline = True | ||||
except ImportError: | ||||
pass | ||||