Show More
@@ -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 |
|
63 | $Id: ultraTB.py 636 2005-07-17 03:11:11Z fperez $""" | |
64 |
|
64 | |||
65 | #***************************************************************************** |
|
65 | #***************************************************************************** | |
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> |
|
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> | |
@@ -98,7 +98,97 b' def inspect_error():' | |||||
98 |
|
98 | |||
99 | error('Internal Python error in the inspect module.\n' |
|
99 | error('Internal Python error in the inspect module.\n' | |
100 | 'Below is the traceback from this internal error.\n') |
|
100 | 'Below is the traceback from this internal error.\n') | |
|
101 | ||||
|
102 | # Make a global variable out of the color scheme table used for coloring | |||
|
103 | # exception tracebacks. This allows user code to add new schemes at runtime. | |||
|
104 | ExceptionColors = ColorSchemeTable() | |||
|
105 | ||||
|
106 | # Populate it with color schemes | |||
|
107 | C = TermColors # shorthand and local lookup | |||
|
108 | ExceptionColors.add_scheme(ColorScheme( | |||
|
109 | 'NoColor', | |||
|
110 | # The color to be used for the top line | |||
|
111 | topline = C.NoColor, | |||
|
112 | ||||
|
113 | # The colors to be used in the traceback | |||
|
114 | filename = C.NoColor, | |||
|
115 | lineno = C.NoColor, | |||
|
116 | name = C.NoColor, | |||
|
117 | vName = C.NoColor, | |||
|
118 | val = C.NoColor, | |||
|
119 | em = C.NoColor, | |||
|
120 | ||||
|
121 | # Emphasized colors for the last frame of the traceback | |||
|
122 | normalEm = C.NoColor, | |||
|
123 | filenameEm = C.NoColor, | |||
|
124 | linenoEm = C.NoColor, | |||
|
125 | nameEm = C.NoColor, | |||
|
126 | valEm = C.NoColor, | |||
|
127 | ||||
|
128 | # Colors for printing the exception | |||
|
129 | excName = C.NoColor, | |||
|
130 | line = C.NoColor, | |||
|
131 | caret = C.NoColor, | |||
|
132 | Normal = C.NoColor | |||
|
133 | )) | |||
|
134 | ||||
|
135 | # make some schemes as instances so we can copy them for modification easily | |||
|
136 | ExceptionColors.add_scheme(ColorScheme( | |||
|
137 | 'Linux', | |||
|
138 | # The color to be used for the top line | |||
|
139 | topline = C.LightRed, | |||
|
140 | ||||
|
141 | # The colors to be used in the traceback | |||
|
142 | filename = C.Green, | |||
|
143 | lineno = C.Green, | |||
|
144 | name = C.Purple, | |||
|
145 | vName = C.Cyan, | |||
|
146 | val = C.Green, | |||
|
147 | em = C.LightCyan, | |||
|
148 | ||||
|
149 | # Emphasized colors for the last frame of the traceback | |||
|
150 | normalEm = C.LightCyan, | |||
|
151 | filenameEm = C.LightGreen, | |||
|
152 | linenoEm = C.LightGreen, | |||
|
153 | nameEm = C.LightPurple, | |||
|
154 | valEm = C.LightBlue, | |||
|
155 | ||||
|
156 | # Colors for printing the exception | |||
|
157 | excName = C.LightRed, | |||
|
158 | line = C.Yellow, | |||
|
159 | caret = C.White, | |||
|
160 | Normal = C.Normal | |||
|
161 | )) | |||
|
162 | ||||
|
163 | # For light backgrounds, swap dark/light colors | |||
|
164 | ExceptionColors.add_scheme(ColorScheme( | |||
|
165 | 'LightBG', | |||
|
166 | # The color to be used for the top line | |||
|
167 | topline = C.Red, | |||
101 |
|
168 | |||
|
169 | # The colors to be used in the traceback | |||
|
170 | filename = C.LightGreen, | |||
|
171 | lineno = C.LightGreen, | |||
|
172 | name = C.LightPurple, | |||
|
173 | vName = C.Cyan, | |||
|
174 | val = C.LightGreen, | |||
|
175 | em = C.Cyan, | |||
|
176 | ||||
|
177 | # Emphasized colors for the last frame of the traceback | |||
|
178 | normalEm = C.Cyan, | |||
|
179 | filenameEm = C.Green, | |||
|
180 | linenoEm = C.Green, | |||
|
181 | nameEm = C.Purple, | |||
|
182 | valEm = C.Blue, | |||
|
183 | ||||
|
184 | # Colors for printing the exception | |||
|
185 | excName = C.Red, | |||
|
186 | #line = C.Brown, # brown often is displayed as yellow | |||
|
187 | line = C.Red, | |||
|
188 | caret = C.Normal, | |||
|
189 | Normal = C.Normal | |||
|
190 | )) | |||
|
191 | ||||
102 | class TBTools: |
|
192 | class TBTools: | |
103 | """Basic tools used by all traceback printer classes.""" |
|
193 | """Basic tools used by all traceback printer classes.""" | |
104 |
|
194 | |||
@@ -112,93 +202,7 b' class TBTools:' | |||||
112 | self.pdb = None |
|
202 | self.pdb = None | |
113 |
|
203 | |||
114 | # Create color table |
|
204 | # Create color table | |
115 |
self.ColorSchemeTable = |
|
205 | self.ColorSchemeTable = ExceptionColors | |
116 |
|
||||
117 | # Populate it with color schemes |
|
|||
118 | C = TermColors # shorthand and local lookup |
|
|||
119 | self.ColorSchemeTable.add_scheme(ColorScheme( |
|
|||
120 | 'NoColor', |
|
|||
121 | # The color to be used for the top line |
|
|||
122 | topline = C.NoColor, |
|
|||
123 |
|
||||
124 | # The colors to be used in the traceback |
|
|||
125 | filename = C.NoColor, |
|
|||
126 | lineno = C.NoColor, |
|
|||
127 | name = C.NoColor, |
|
|||
128 | vName = C.NoColor, |
|
|||
129 | val = C.NoColor, |
|
|||
130 | em = C.NoColor, |
|
|||
131 |
|
||||
132 | # Emphasized colors for the last frame of the traceback |
|
|||
133 | normalEm = C.NoColor, |
|
|||
134 | filenameEm = C.NoColor, |
|
|||
135 | linenoEm = C.NoColor, |
|
|||
136 | nameEm = C.NoColor, |
|
|||
137 | valEm = C.NoColor, |
|
|||
138 |
|
||||
139 | # Colors for printing the exception |
|
|||
140 | excName = C.NoColor, |
|
|||
141 | line = C.NoColor, |
|
|||
142 | caret = C.NoColor, |
|
|||
143 | Normal = C.NoColor |
|
|||
144 | )) |
|
|||
145 |
|
||||
146 | # make some schemes as instances so we can copy them for modification easily: |
|
|||
147 | self.ColorSchemeTable.add_scheme(ColorScheme( |
|
|||
148 | 'Linux', |
|
|||
149 | # The color to be used for the top line |
|
|||
150 | topline = C.LightRed, |
|
|||
151 |
|
||||
152 | # The colors to be used in the traceback |
|
|||
153 | filename = C.Green, |
|
|||
154 | lineno = C.Green, |
|
|||
155 | name = C.Purple, |
|
|||
156 | vName = C.Cyan, |
|
|||
157 | val = C.Green, |
|
|||
158 | em = C.LightCyan, |
|
|||
159 |
|
||||
160 | # Emphasized colors for the last frame of the traceback |
|
|||
161 | normalEm = C.LightCyan, |
|
|||
162 | filenameEm = C.LightGreen, |
|
|||
163 | linenoEm = C.LightGreen, |
|
|||
164 | nameEm = C.LightPurple, |
|
|||
165 | valEm = C.LightBlue, |
|
|||
166 |
|
||||
167 | # Colors for printing the exception |
|
|||
168 | excName = C.LightRed, |
|
|||
169 | line = C.Yellow, |
|
|||
170 | caret = C.White, |
|
|||
171 | Normal = C.Normal |
|
|||
172 | )) |
|
|||
173 |
|
||||
174 | # For light backgrounds, swap dark/light colors |
|
|||
175 | self.ColorSchemeTable.add_scheme(ColorScheme( |
|
|||
176 | 'LightBG', |
|
|||
177 | # The color to be used for the top line |
|
|||
178 | topline = C.Red, |
|
|||
179 |
|
||||
180 | # The colors to be used in the traceback |
|
|||
181 | filename = C.LightGreen, |
|
|||
182 | lineno = C.LightGreen, |
|
|||
183 | name = C.LightPurple, |
|
|||
184 | vName = C.Cyan, |
|
|||
185 | val = C.LightGreen, |
|
|||
186 | em = C.Cyan, |
|
|||
187 |
|
||||
188 | # Emphasized colors for the last frame of the traceback |
|
|||
189 | normalEm = C.Cyan, |
|
|||
190 | filenameEm = C.Green, |
|
|||
191 | linenoEm = C.Green, |
|
|||
192 | nameEm = C.Purple, |
|
|||
193 | valEm = C.Blue, |
|
|||
194 |
|
||||
195 | # Colors for printing the exception |
|
|||
196 | excName = C.Red, |
|
|||
197 | #line = C.Brown, # brown often is displayed as yellow |
|
|||
198 | line = C.Red, |
|
|||
199 | caret = C.Normal, |
|
|||
200 | Normal = C.Normal |
|
|||
201 | )) |
|
|||
202 |
|
206 | |||
203 | self.set_colors(color_scheme) |
|
207 | self.set_colors(color_scheme) | |
204 | self.old_scheme = color_scheme # save initial value for toggles |
|
208 | self.old_scheme = color_scheme # save initial value for toggles |
@@ -1,3 +1,18 b'' | |||||
|
1 | 2005-07-16 Fernando Perez <fperez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/ultraTB.py (ExceptionColors): Make a global variable | |||
|
4 | out of the color scheme table used for coloring exception | |||
|
5 | tracebacks. This allows user code to add new schemes at runtime. | |||
|
6 | This is a minimally modified version of the patch at | |||
|
7 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw | |||
|
8 | for the contribution. | |||
|
9 | ||||
|
10 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a | |||
|
11 | slightly modified version of the patch in | |||
|
12 | http://www.scipy.net/roundup/ipython/issue34, which also allows me | |||
|
13 | to remove the previous try/except solution (which was costlier). | |||
|
14 | Thanks to glehmann for the fix. | |||
|
15 | ||||
1 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
16 | 2005-06-08 Fernando Perez <fperez@colorado.edu> | |
2 |
|
17 | |||
3 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
18 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
General Comments 0
You need to be logged in to leave comments.
Login now