Show More
The requested changes are too big and content was truncated. Show full diff
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,56 +1,56 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ Imports and provides the 'correct' version of readline for the platform. |
|
2 | """ Imports and provides the 'correct' version of readline for the platform. | |
3 |
|
3 | |||
4 | Readline is used throughout IPython as 'import IPython.rlineimpl as readline'. |
|
4 | Readline is used throughout IPython as 'import IPython.rlineimpl as readline'. | |
5 |
|
5 | |||
6 | In addition to normal readline stuff, this module provides have_readline |
|
6 | In addition to normal readline stuff, this module provides have_readline | |
7 | boolean and _outputfile variable used in genutils. |
|
7 | boolean and _outputfile variable used in genutils. | |
8 |
|
8 | |||
9 | $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $""" |
|
9 | $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $""" | |
10 |
|
10 | |||
11 | import sys |
|
11 | import sys | |
12 |
|
12 | |||
13 | try: |
|
13 | try: | |
14 | from readline import * |
|
14 | from readline import * | |
15 | import readline as _rl |
|
15 | import readline as _rl | |
16 | have_readline = True |
|
16 | have_readline = True | |
17 | except ImportError: |
|
17 | except ImportError: | |
18 | try: |
|
18 | try: | |
19 | from pyreadline import * |
|
19 | from pyreadline import * | |
20 | import pyreadline as _rl |
|
20 | import pyreadline as _rl | |
21 | have_readline = True |
|
21 | have_readline = True | |
22 | except ImportError: |
|
22 | except ImportError: | |
23 | have_readline = False |
|
23 | have_readline = False | |
24 |
|
24 | |||
25 | if sys.platform == 'win32' and have_readline: |
|
25 | if sys.platform == 'win32' and have_readline: | |
26 | try: |
|
26 | try: | |
27 | _outputfile=_rl.GetOutputFile() |
|
27 | _outputfile=_rl.GetOutputFile() | |
28 | except AttributeError: |
|
28 | except AttributeError: | |
29 | print "Failed GetOutputFile" |
|
29 | print "Failed GetOutputFile" | |
30 | have_readline = False |
|
30 | have_readline = False | |
31 |
|
31 | |||
32 | # Test to see if libedit is being used instead of GNU readline. |
|
32 | # Test to see if libedit is being used instead of GNU readline. | |
33 | # Thanks to Boyd Waters for this patch. |
|
33 | # Thanks to Boyd Waters for this patch. | |
34 | uses_libedit = False |
|
34 | uses_libedit = False | |
35 | if sys.platform == 'darwin' and have_readline: |
|
35 | if sys.platform == 'darwin' and have_readline: | |
36 |
|
|
36 | import commands | |
37 |
|
|
37 | (status, result) = commands.getstatusoutput( "otool -L %s | grep libedit" % _rl.__file__ ) | |
38 |
|
|
38 | if status == 0 and len(result) > 0: | |
39 |
|
|
39 | # we are bound to libedit - new in Leopard | |
40 |
|
|
40 | _rl.parse_and_bind("bind ^I rl_complete") | |
41 |
|
|
41 | print "Leopard libedit detected." | |
42 |
|
|
42 | uses_libedit = True | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | # the clear_history() function was only introduced in Python 2.4 and is |
|
45 | # the clear_history() function was only introduced in Python 2.4 and is | |
46 | # actually optional in the readline API, so we must explicitly check for its |
|
46 | # actually optional in the readline API, so we must explicitly check for its | |
47 | # existence. Some known platforms actually don't have it. This thread: |
|
47 | # existence. Some known platforms actually don't have it. This thread: | |
48 | # http://mail.python.org/pipermail/python-dev/2003-August/037845.html |
|
48 | # http://mail.python.org/pipermail/python-dev/2003-August/037845.html | |
49 | # has the original discussion. |
|
49 | # has the original discussion. | |
50 |
|
50 | |||
51 | if have_readline: |
|
51 | if have_readline: | |
52 | try: |
|
52 | try: | |
53 | _rl.clear_history |
|
53 | _rl.clear_history | |
54 | except AttributeError: |
|
54 | except AttributeError: | |
55 | def clear_history(): pass |
|
55 | def clear_history(): pass | |
56 | _rl.clear_history = clear_history No newline at end of file |
|
56 | _rl.clear_history = clear_history |
General Comments 0
You need to be logged in to leave comments.
Login now