##// END OF EJS Templates
Fixing doctest in excolors that changed because of the new ipstruct.py
Brian Granger -
Show More
@@ -1,137 +1,137 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 Color schemes for exception handling code in IPython.
4 4 """
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2005-2006 Fernando Perez <fperez@colorado.edu>
8 8 #
9 9 # Distributed under the terms of the BSD License. The full license is in
10 10 # the file COPYING, distributed as part of this software.
11 11 #*****************************************************************************
12 12
13 13 #****************************************************************************
14 14 # Required modules
15 15 from IPython.utils.coloransi import ColorSchemeTable, TermColors, ColorScheme
16 16
17 17 def exception_colors():
18 18 """Return a color table with fields for exception reporting.
19 19
20 20 The table is an instance of ColorSchemeTable with schemes added for
21 21 'Linux', 'LightBG' and 'NoColor' and fields for exception handling filled
22 22 in.
23 23
24 24 Examples:
25 25
26 26 >>> ec = exception_colors()
27 27 >>> ec.active_scheme_name
28 28 ''
29 29 >>> print ec.active_colors
30 30 None
31 31
32 32 Now we activate a color scheme:
33 33 >>> ec.set_active_scheme('NoColor')
34 34 >>> ec.active_scheme_name
35 35 'NoColor'
36 36 >>> ec.active_colors.keys()
37 ['em', 'caret', '__allownew', 'name', 'val', 'vName', 'Normal', 'normalEm',
38 'filename', 'linenoEm', 'excName', 'lineno', 'valEm', 'filenameEm',
39 'nameEm', 'line', 'topline']
37 ['em', 'filenameEm', 'excName', 'valEm', 'nameEm', 'line', 'topline',
38 'name', 'caret', 'val', 'vName', 'Normal', 'filename', 'linenoEm',
39 'lineno', 'normalEm']
40 40 """
41 41
42 42 ex_colors = ColorSchemeTable()
43 43
44 44 # Populate it with color schemes
45 45 C = TermColors # shorthand and local lookup
46 46 ex_colors.add_scheme(ColorScheme(
47 47 'NoColor',
48 48 # The color to be used for the top line
49 49 topline = C.NoColor,
50 50
51 51 # The colors to be used in the traceback
52 52 filename = C.NoColor,
53 53 lineno = C.NoColor,
54 54 name = C.NoColor,
55 55 vName = C.NoColor,
56 56 val = C.NoColor,
57 57 em = C.NoColor,
58 58
59 59 # Emphasized colors for the last frame of the traceback
60 60 normalEm = C.NoColor,
61 61 filenameEm = C.NoColor,
62 62 linenoEm = C.NoColor,
63 63 nameEm = C.NoColor,
64 64 valEm = C.NoColor,
65 65
66 66 # Colors for printing the exception
67 67 excName = C.NoColor,
68 68 line = C.NoColor,
69 69 caret = C.NoColor,
70 70 Normal = C.NoColor
71 71 ))
72 72
73 73 # make some schemes as instances so we can copy them for modification easily
74 74 ex_colors.add_scheme(ColorScheme(
75 75 'Linux',
76 76 # The color to be used for the top line
77 77 topline = C.LightRed,
78 78
79 79 # The colors to be used in the traceback
80 80 filename = C.Green,
81 81 lineno = C.Green,
82 82 name = C.Purple,
83 83 vName = C.Cyan,
84 84 val = C.Green,
85 85 em = C.LightCyan,
86 86
87 87 # Emphasized colors for the last frame of the traceback
88 88 normalEm = C.LightCyan,
89 89 filenameEm = C.LightGreen,
90 90 linenoEm = C.LightGreen,
91 91 nameEm = C.LightPurple,
92 92 valEm = C.LightBlue,
93 93
94 94 # Colors for printing the exception
95 95 excName = C.LightRed,
96 96 line = C.Yellow,
97 97 caret = C.White,
98 98 Normal = C.Normal
99 99 ))
100 100
101 101 # For light backgrounds, swap dark/light colors
102 102 ex_colors.add_scheme(ColorScheme(
103 103 'LightBG',
104 104 # The color to be used for the top line
105 105 topline = C.Red,
106 106
107 107 # The colors to be used in the traceback
108 108 filename = C.LightGreen,
109 109 lineno = C.LightGreen,
110 110 name = C.LightPurple,
111 111 vName = C.Cyan,
112 112 val = C.LightGreen,
113 113 em = C.Cyan,
114 114
115 115 # Emphasized colors for the last frame of the traceback
116 116 normalEm = C.Cyan,
117 117 filenameEm = C.Green,
118 118 linenoEm = C.Green,
119 119 nameEm = C.Purple,
120 120 valEm = C.Blue,
121 121
122 122 # Colors for printing the exception
123 123 excName = C.Red,
124 124 #line = C.Brown, # brown often is displayed as yellow
125 125 line = C.Red,
126 126 caret = C.Normal,
127 127 Normal = C.Normal,
128 128 ))
129 129
130 130 return ex_colors
131 131
132 132
133 133 # For backwards compatibility, keep around a single global object. Note that
134 134 # this should NOT be used, the factory function should be used instead, since
135 135 # these objects are stateful and it's very easy to get strange bugs if any code
136 136 # modifies the module-level object's state.
137 137 ExceptionColors = exception_colors()
General Comments 0
You need to be logged in to leave comments. Login now