MCPcopy Create free account
hub / github.com/ipython/ipython / exception_colors

Function exception_colors

IPython/core/excolors.py:18–166  ·  view source on GitHub ↗

Return a color table with fields for exception reporting. The table is an instance of ColorSchemeTable with schemes added for 'Neutral', 'Linux', 'LightBG' and 'NoColor' and fields for exception handling filled in. Examples: >>> ec = exception_colors() >>> ec.active_scheme

()

Source from the content-addressed store, hash-verified

16from IPython.utils.coloransi import ColorSchemeTable, TermColors, ColorScheme
17
18def exception_colors():
19 """Return a color table with fields for exception reporting.
20
21 The table is an instance of ColorSchemeTable with schemes added for
22 'Neutral', 'Linux', 'LightBG' and 'NoColor' and fields for exception handling filled
23 in.
24
25 Examples:
26
27 >>> ec = exception_colors()
28 >>> ec.active_scheme_name
29 ''
30 >>> print(ec.active_colors)
31 None
32
33 Now we activate a color scheme:
34 >>> ec.set_active_scheme('NoColor')
35 >>> ec.active_scheme_name
36 'NoColor'
37 >>> sorted(ec.active_colors.keys())
38 ['Normal', 'caret', 'em', 'excName', 'filename', 'filenameEm', 'line',
39 'lineno', 'linenoEm', 'name', 'nameEm', 'normalEm', 'topline', 'vName',
40 'val', 'valEm']
41 """
42
43 ex_colors = ColorSchemeTable()
44
45 # Populate it with color schemes
46 C = TermColors # shorthand and local lookup
47 ex_colors.add_scheme(ColorScheme(
48 'NoColor',
49 # The color to be used for the top line
50 topline = C.NoColor,
51
52 # The colors to be used in the traceback
53 filename = C.NoColor,
54 lineno = C.NoColor,
55 name = C.NoColor,
56 vName = C.NoColor,
57 val = C.NoColor,
58 em = C.NoColor,
59
60 # Emphasized colors for the last frame of the traceback
61 normalEm = C.NoColor,
62 filenameEm = C.NoColor,
63 linenoEm = C.NoColor,
64 nameEm = C.NoColor,
65 valEm = C.NoColor,
66
67 # Colors for printing the exception
68 excName = C.NoColor,
69 line = C.NoColor,
70 caret = C.NoColor,
71 Normal = C.NoColor
72 ))
73
74 # make some schemes as instances so we can copy them for modification easily
75 ex_colors.add_scheme(ColorScheme(

Callers 3

__init__Method · 0.90
__init__Method · 0.90
excolors.pyFile · 0.85

Calls 4

add_schemeMethod · 0.95
ColorSchemeTableClass · 0.90
ColorSchemeClass · 0.90
copyMethod · 0.45

Tested by

no test coverage detected