Show More
@@ -4,7 +4,7 b'' | |||||
4 | All the matplotlib support code was co-developed with John Hunter, |
|
4 | All the matplotlib support code was co-developed with John Hunter, | |
5 | matplotlib's author. |
|
5 | matplotlib's author. | |
6 |
|
6 | |||
7 |
$Id: Shell.py 215 |
|
7 | $Id: Shell.py 2156 2007-03-19 02:32:19Z fperez $""" | |
8 |
|
8 | |||
9 | #***************************************************************************** |
|
9 | #***************************************************************************** | |
10 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
10 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
@@ -446,8 +446,7 b' class MatplotlibShellBase:' | |||||
446 | user_ns = IPython.ipapi.make_user_ns(user_ns) |
|
446 | user_ns = IPython.ipapi.make_user_ns(user_ns) | |
447 |
|
447 | |||
448 | exec ("import matplotlib\n" |
|
448 | exec ("import matplotlib\n" | |
449 | "import matplotlib.pylab as pylab\n" |
|
449 | "import matplotlib.pylab as pylab\n") in user_ns | |
450 | "from matplotlib.pylab import *") in user_ns |
|
|||
451 |
|
450 | |||
452 | # Build matplotlib info banner |
|
451 | # Build matplotlib info banner | |
453 | b=""" |
|
452 | b=""" | |
@@ -931,6 +930,17 b' class IPShellQt4(threading.Thread):' | |||||
931 |
|
930 | |||
932 | # A set of matplotlib public IPython shell classes, for single-threaded |
|
931 | # A set of matplotlib public IPython shell classes, for single-threaded | |
933 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. |
|
932 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. | |
|
933 | def _load_pylab(user_ns): | |||
|
934 | """Allow users to disable pulling all of pylab into the top-level | |||
|
935 | namespace. | |||
|
936 | ||||
|
937 | This little utility must be called AFTER the actual ipython instance is | |||
|
938 | running, since only then will the options file have been fully parsed.""" | |||
|
939 | ||||
|
940 | ip = IPython.ipapi.get() | |||
|
941 | if ip.options.pylab_import_all: | |||
|
942 | exec "from matplotlib.pylab import *" in user_ns | |||
|
943 | ||||
934 | class IPShellMatplotlib(IPShell): |
|
944 | class IPShellMatplotlib(IPShell): | |
935 | """Subclass IPShell with MatplotlibShell as the internal shell. |
|
945 | """Subclass IPShell with MatplotlibShell as the internal shell. | |
936 |
|
946 | |||
@@ -941,6 +951,7 b' class IPShellMatplotlib(IPShell):' | |||||
941 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
951 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
942 | IPShell.__init__(self,argv,user_ns,user_global_ns,debug, |
|
952 | IPShell.__init__(self,argv,user_ns,user_global_ns,debug, | |
943 | shell_class=MatplotlibShell) |
|
953 | shell_class=MatplotlibShell) | |
|
954 | _load_pylab(user_ns) | |||
944 |
|
955 | |||
945 | class IPShellMatplotlibGTK(IPShellGTK): |
|
956 | class IPShellMatplotlibGTK(IPShellGTK): | |
946 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. |
|
957 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. | |
@@ -950,6 +961,7 b' class IPShellMatplotlibGTK(IPShellGTK):' | |||||
950 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
961 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
951 | IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug, |
|
962 | IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug, | |
952 | shell_class=MatplotlibMTShell) |
|
963 | shell_class=MatplotlibMTShell) | |
|
964 | _load_pylab(user_ns) | |||
953 |
|
965 | |||
954 | class IPShellMatplotlibWX(IPShellWX): |
|
966 | class IPShellMatplotlibWX(IPShellWX): | |
955 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. |
|
967 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. | |
@@ -959,6 +971,7 b' class IPShellMatplotlibWX(IPShellWX):' | |||||
959 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
971 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
960 | IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug, |
|
972 | IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug, | |
961 | shell_class=MatplotlibMTShell) |
|
973 | shell_class=MatplotlibMTShell) | |
|
974 | _load_pylab(user_ns) | |||
962 |
|
975 | |||
963 | class IPShellMatplotlibQt(IPShellQt): |
|
976 | class IPShellMatplotlibQt(IPShellQt): | |
964 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. |
|
977 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. | |
@@ -968,6 +981,7 b' class IPShellMatplotlibQt(IPShellQt):' | |||||
968 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
981 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
969 | IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, |
|
982 | IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, | |
970 | shell_class=MatplotlibMTShell) |
|
983 | shell_class=MatplotlibMTShell) | |
|
984 | _load_pylab(user_ns) | |||
971 |
|
985 | |||
972 | class IPShellMatplotlibQt4(IPShellQt4): |
|
986 | class IPShellMatplotlibQt4(IPShellQt4): | |
973 | """Subclass IPShellQt4 with MatplotlibMTShell as the internal shell. |
|
987 | """Subclass IPShellQt4 with MatplotlibMTShell as the internal shell. | |
@@ -977,6 +991,7 b' class IPShellMatplotlibQt4(IPShellQt4):' | |||||
977 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
991 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
978 | IPShellQt4.__init__(self,argv,user_ns,user_global_ns,debug, |
|
992 | IPShellQt4.__init__(self,argv,user_ns,user_global_ns,debug, | |
979 | shell_class=MatplotlibMTShell) |
|
993 | shell_class=MatplotlibMTShell) | |
|
994 | _load_pylab(user_ns) | |||
980 |
|
995 | |||
981 | #----------------------------------------------------------------------------- |
|
996 | #----------------------------------------------------------------------------- | |
982 | # Factory functions to actually start the proper thread-aware shell |
|
997 | # Factory functions to actually start the proper thread-aware shell |
@@ -1,5 +1,5 b'' | |||||
1 | # -*- Mode: Shell-Script -*- Not really, but shows comments correctly |
|
1 | # -*- Mode: Shell-Script -*- Not really, but shows comments correctly | |
2 | # $Id: ipythonrc 1979 2006-12-12 18:50:20Z vivainio $ |
|
2 | # $Id: ipythonrc 2156 2007-03-19 02:32:19Z fperez $ | |
3 |
|
3 | |||
4 | #*************************************************************************** |
|
4 | #*************************************************************************** | |
5 | # |
|
5 | # | |
@@ -258,6 +258,15 b" prompt_out 'Out[\\#]: '" | |||||
258 | # the output prompts will be unpadded (flush left). |
|
258 | # the output prompts will be unpadded (flush left). | |
259 | prompts_pad_left 1 |
|
259 | prompts_pad_left 1 | |
260 |
|
260 | |||
|
261 | # Pylab support: when ipython is started with the -pylab switch, by default it | |||
|
262 | # executes 'from matplotlib.pylab import *'. Set this variable to false if you | |||
|
263 | # want to disable this behavior. | |||
|
264 | ||||
|
265 | # For details on pylab, see the matplotlib website: | |||
|
266 | # http://matplotlib.sf.net | |||
|
267 | pylab_import_all 1 | |||
|
268 | ||||
|
269 | ||||
261 | # quick 1 -> same as ipython -quick |
|
270 | # quick 1 -> same as ipython -quick | |
262 | quick 0 |
|
271 | quick 0 | |
263 |
|
272 |
@@ -6,7 +6,7 b' Requires Python 2.1 or better.' | |||||
6 |
|
6 | |||
7 | This file contains the main make_IPython() starter function. |
|
7 | This file contains the main make_IPython() starter function. | |
8 |
|
8 | |||
9 |
$Id: ipmaker.py 2 |
|
9 | $Id: ipmaker.py 2156 2007-03-19 02:32:19Z fperez $""" | |
10 |
|
10 | |||
11 | #***************************************************************************** |
|
11 | #***************************************************************************** | |
12 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> |
|
12 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> | |
@@ -159,6 +159,7 b" object? -> Details about 'object'. ?object also works, ?? prints more." | |||||
159 | 'debug! deep_reload! editor=s log|l messages! nosep ' |
|
159 | 'debug! deep_reload! editor=s log|l messages! nosep ' | |
160 | 'object_info_string_level=i pdb! ' |
|
160 | 'object_info_string_level=i pdb! ' | |
161 | 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s ' |
|
161 | 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s ' | |
|
162 | 'pylab_import_all! ' | |||
162 | 'quick screen_length|sl=i prompts_pad_left=i ' |
|
163 | 'quick screen_length|sl=i prompts_pad_left=i ' | |
163 | 'logfile|lf=s logplay|lp=s profile|p=s ' |
|
164 | 'logfile|lf=s logplay|lp=s profile|p=s ' | |
164 | 'readline! readline_merge_completions! ' |
|
165 | 'readline! readline_merge_completions! ' | |
@@ -213,6 +214,7 b" object? -> Details about 'object'. ?object also works, ?? prints more." | |||||
213 | prompt_in2 = ' .\\D.: ', |
|
214 | prompt_in2 = ' .\\D.: ', | |
214 | prompt_out = 'Out[\\#]: ', |
|
215 | prompt_out = 'Out[\\#]: ', | |
215 | prompts_pad_left = 1, |
|
216 | prompts_pad_left = 1, | |
|
217 | pylab_import_all = 1, | |||
216 | quiet = 0, |
|
218 | quiet = 0, | |
217 | quick = 0, |
|
219 | quick = 0, | |
218 | readline = 1, |
|
220 | readline = 1, |
@@ -60,7 +60,7 b' You can implement other color schemes easily, the syntax is fairly' | |||||
60 | self-explanatory. Please send back new schemes you develop to the author for |
|
60 | self-explanatory. Please send back new schemes you develop to the author for | |
61 | possible inclusion in future releases. |
|
61 | possible inclusion in future releases. | |
62 |
|
62 | |||
63 |
$Id: ultraTB.py 215 |
|
63 | $Id: ultraTB.py 2156 2007-03-19 02:32:19Z fperez $""" | |
64 |
|
64 | |||
65 | #***************************************************************************** |
|
65 | #***************************************************************************** | |
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> |
|
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> | |
@@ -103,7 +103,7 b' INDENT_SIZE = 8' | |||||
103 | # formatter. When running in an actual IPython instance, the user's rc.colors |
|
103 | # formatter. When running in an actual IPython instance, the user's rc.colors | |
104 | # value is used, but havinga module global makes this functionality available |
|
104 | # value is used, but havinga module global makes this functionality available | |
105 | # to users of ultraTB who are NOT running inside ipython. |
|
105 | # to users of ultraTB who are NOT running inside ipython. | |
106 |
DEFAULT_SCHEME = 'NoColor |
|
106 | DEFAULT_SCHEME = 'NoColor' | |
107 |
|
107 | |||
108 | #--------------------------------------------------------------------------- |
|
108 | #--------------------------------------------------------------------------- | |
109 | # Code begins |
|
109 | # Code begins | |
@@ -160,16 +160,17 b' def _fixed_getinnerframes(etb, context=1,tb_offset=0):' | |||||
160 |
|
160 | |||
161 | _parser = PyColorize.Parser() |
|
161 | _parser = PyColorize.Parser() | |
162 |
|
162 | |||
163 | def _formatTracebackLines(lnum, index, lines, Colors, lvals=None): |
|
163 | def _formatTracebackLines(lnum, index, lines, Colors, lvals=None,scheme=None): | |
164 | numbers_width = INDENT_SIZE - 1 |
|
164 | numbers_width = INDENT_SIZE - 1 | |
165 | res = [] |
|
165 | res = [] | |
166 | i = lnum - index |
|
166 | i = lnum - index | |
167 |
|
167 | |||
168 | # This lets us get fully syntax-highlighted tracebacks. |
|
168 | # This lets us get fully syntax-highlighted tracebacks. | |
169 | try: |
|
169 | if scheme is None: | |
170 | scheme = __IPYTHON__.rc.colors |
|
170 | try: | |
171 | except: |
|
171 | scheme = __IPYTHON__.rc.colors | |
172 | scheme = DEFAULT_SCHEME |
|
172 | except: | |
|
173 | scheme = DEFAULT_SCHEME | |||
173 | _line_format = _parser.format2 |
|
174 | _line_format = _parser.format2 | |
174 |
|
175 | |||
175 | for line in lines: |
|
176 | for line in lines: | |
@@ -420,6 +421,7 b' class VerboseTB(TBTools):' | |||||
420 | # some locals |
|
421 | # some locals | |
421 | Colors = self.Colors # just a shorthand + quicker name lookup |
|
422 | Colors = self.Colors # just a shorthand + quicker name lookup | |
422 | ColorsNormal = Colors.Normal # used a lot |
|
423 | ColorsNormal = Colors.Normal # used a lot | |
|
424 | col_scheme = self.color_scheme_table.active_scheme_name | |||
423 | indent = ' '*INDENT_SIZE |
|
425 | indent = ' '*INDENT_SIZE | |
424 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) |
|
426 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) | |
425 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) |
|
427 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) | |
@@ -658,7 +660,8 b' class VerboseTB(TBTools):' | |||||
658 | frames.append(level) |
|
660 | frames.append(level) | |
659 | else: |
|
661 | else: | |
660 | frames.append('%s%s' % (level,''.join( |
|
662 | frames.append('%s%s' % (level,''.join( | |
661 |
_formatTracebackLines(lnum,index,lines, |
|
663 | _formatTracebackLines(lnum,index,lines,Colors,lvals, | |
|
664 | col_scheme)))) | |||
662 |
|
665 | |||
663 | # Get (safely) a string form of the exception info |
|
666 | # Get (safely) a string form of the exception info | |
664 | try: |
|
667 | try: |
@@ -1,5 +1,10 b'' | |||||
1 | 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1 | 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
2 | |||
|
3 | * IPython/Shell.py (_load_pylab): Make the execution of 'from | |||
|
4 | pylab import *' when -pylab is given be optional. A new flag, | |||
|
5 | pylab_import_all controls this behavior, the default is True for | |||
|
6 | backwards compatibility. | |||
|
7 | ||||
3 | * IPython/ultraTB.py (_formatTracebackLines): Added (slightly |
|
8 | * IPython/ultraTB.py (_formatTracebackLines): Added (slightly | |
4 | modified) R. Bernstein's patch for fully syntax highlighted |
|
9 | modified) R. Bernstein's patch for fully syntax highlighted | |
5 | tracebacks. The functionality is also available under ultraTB for |
|
10 | tracebacks. The functionality is also available under ultraTB for |
General Comments 0
You need to be logged in to leave comments.
Login now