##// END OF EJS Templates
ColorANSI.py -> utils/coloransi.py and all imports updated.
Brian Granger -
Show More
@@ -21,13 +21,12 b' Authors'
21 # From the standard library
21 # From the standard library
22 import os
22 import os
23 import sys
23 import sys
24 from pprint import pprint,pformat
24 from pprint import pformat
25
25
26 # Our own
26 # Our own
27 from IPython import Release
27 from IPython import Release
28 from IPython import ultraTB
28 from IPython import ultraTB
29 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
29 from IPython.Itpl import itpl
30 from IPython.Itpl import Itpl,itpl,printpl
31
30
32 from IPython.genutils import *
31 from IPython.genutils import *
33
32
@@ -31,7 +31,8 b' import linecache'
31 import os
31 import os
32 import sys
32 import sys
33
33
34 from IPython import PyColorize, ColorANSI, ipapi
34 from IPython import PyColorize, ipapi
35 from IPython.utils import coloransi
35 from IPython.genutils import Term
36 from IPython.genutils import Term
36 from IPython.excolors import exception_colors
37 from IPython.excolors import exception_colors
37
38
@@ -114,7 +115,7 b' class Tracer(object):'
114 def_colors = 'NoColor'
115 def_colors = 'NoColor'
115 try:
116 try:
116 # Limited tab completion support
117 # Limited tab completion support
117 import rlcompleter,readline
118 import readline
118 readline.parse_and_bind('tab: complete')
119 readline.parse_and_bind('tab: complete')
119 except ImportError:
120 except ImportError:
120 pass
121 pass
@@ -207,7 +208,7 b' class Pdb(OldPdb):'
207 self.color_scheme_table = exception_colors()
208 self.color_scheme_table = exception_colors()
208
209
209 # shorthands
210 # shorthands
210 C = ColorANSI.TermColors
211 C = coloransi.TermColors
211 cst = self.color_scheme_table
212 cst = self.color_scheme_table
212
213
213 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
214 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
@@ -254,7 +255,7 b' class Pdb(OldPdb):'
254 self.color_scheme_table = exception_colors()
255 self.color_scheme_table = exception_colors()
255
256
256 # shorthands
257 # shorthands
257 C = ColorANSI.TermColors
258 C = coloransi.TermColors
258 cst = self.color_scheme_table
259 cst = self.color_scheme_table
259
260
260 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
261 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
@@ -31,7 +31,7 b' from IPython import PyColorize'
31 from IPython.genutils import page,indent,Term
31 from IPython.genutils import page,indent,Term
32 from IPython.Itpl import itpl
32 from IPython.Itpl import itpl
33 from IPython.wildcard import list_namespace
33 from IPython.wildcard import list_namespace
34 from IPython.ColorANSI import *
34 from IPython.utils.coloransi import *
35
35
36 #****************************************************************************
36 #****************************************************************************
37 # HACK!!! This is a crude fix for bugs in python 2.3's inspect module. We
37 # HACK!!! This is a crude fix for bugs in python 2.3's inspect module. We
@@ -20,7 +20,7 b' import sys'
20 import time
20 import time
21
21
22 # IPython's own
22 # IPython's own
23 from IPython import ColorANSI
23 from IPython.utils import coloransi
24 from IPython import Release
24 from IPython import Release
25 from IPython.external.Itpl import ItplNS
25 from IPython.external.Itpl import ItplNS
26 from IPython.ipapi import TryNext
26 from IPython.ipapi import TryNext
@@ -32,11 +32,11 b' from IPython.genutils import *'
32 #****************************************************************************
32 #****************************************************************************
33 #Color schemes for Prompts.
33 #Color schemes for Prompts.
34
34
35 PromptColors = ColorANSI.ColorSchemeTable()
35 PromptColors = coloransi.ColorSchemeTable()
36 InputColors = ColorANSI.InputTermColors # just a shorthand
36 InputColors = coloransi.InputTermColors # just a shorthand
37 Colors = ColorANSI.TermColors # just a shorthand
37 Colors = coloransi.TermColors # just a shorthand
38
38
39 PromptColors.add_scheme(ColorANSI.ColorScheme(
39 PromptColors.add_scheme(coloransi.ColorScheme(
40 'NoColor',
40 'NoColor',
41 in_prompt = InputColors.NoColor, # Input prompt
41 in_prompt = InputColors.NoColor, # Input prompt
42 in_number = InputColors.NoColor, # Input prompt number
42 in_number = InputColors.NoColor, # Input prompt number
@@ -50,7 +50,7 b' PromptColors.add_scheme(ColorANSI.ColorScheme('
50 ))
50 ))
51
51
52 # make some schemes as instances so we can copy them for modification easily:
52 # make some schemes as instances so we can copy them for modification easily:
53 __PColLinux = ColorANSI.ColorScheme(
53 __PColLinux = coloransi.ColorScheme(
54 'Linux',
54 'Linux',
55 in_prompt = InputColors.Green,
55 in_prompt = InputColors.Green,
56 in_number = InputColors.LightGreen,
56 in_number = InputColors.LightGreen,
@@ -185,7 +185,7 b" prompt_specials_nocolor[r'\\#'] = '${self.cache.prompt_count}'"
185 # with a color name which may begin with a letter used by any other of the
185 # with a color name which may begin with a letter used by any other of the
186 # allowed specials. This of course means that \\C will never be allowed for
186 # allowed specials. This of course means that \\C will never be allowed for
187 # anything else.
187 # anything else.
188 input_colors = ColorANSI.InputTermColors
188 input_colors = coloransi.InputTermColors
189 for _color in dir(input_colors):
189 for _color in dir(input_colors):
190 if _color[0] != '_':
190 if _color[0] != '_':
191 c_name = r'\C_'+_color
191 c_name = r'\C_'+_color
@@ -38,12 +38,11 b' import cStringIO'
38 import keyword
38 import keyword
39 import os
39 import os
40 import optparse
40 import optparse
41 import string
42 import sys
41 import sys
43 import token
42 import token
44 import tokenize
43 import tokenize
45
44
46 from IPython.ColorANSI import *
45 from IPython.utils.coloransi import *
47
46
48 #############################################################################
47 #############################################################################
49 ### Python Source Parser (does Hilighting)
48 ### Python Source Parser (does Hilighting)
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -12,7 +12,7 b' Color schemes for exception handling code in IPython.'
12
12
13 #****************************************************************************
13 #****************************************************************************
14 # Required modules
14 # Required modules
15 from IPython.ColorANSI import ColorSchemeTable, TermColors, ColorScheme
15 from IPython.utils.coloransi import ColorSchemeTable, TermColors, ColorScheme
16
16
17 def exception_colors():
17 def exception_colors():
18 """Return a color table with fields for exception reporting.
18 """Return a color table with fields for exception reporting.
@@ -105,8 +105,8 b" ANSI_STYLES = {'0;30': [0, 'BLACK'], '0;31': [1, 'RED'],"
105 [13, 'MEDIUM VIOLET RED'],
105 [13, 'MEDIUM VIOLET RED'],
106 '1;36': [14, 'LIGHT STEEL BLUE'], '1;37': [15, 'YELLOW']}
106 '1;36': [14, 'LIGHT STEEL BLUE'], '1;37': [15, 'YELLOW']}
107
107
108 # XXX: Maybe one day we should factor this code with ColorANSI. Right now
108 # XXX: Maybe one day we should factor this code with coloransi. Right now
109 # ColorANSI is hard to reuse and makes our code more complex.
109 # coloransi is hard to reuse and makes our code more complex.
110
110
111 #we define platform specific fonts
111 #we define platform specific fonts
112 if wx.Platform == '__WXMSW__':
112 if wx.Platform == '__WXMSW__':
@@ -31,37 +31,29 b' import __main__'
31 import __builtin__
31 import __builtin__
32 import StringIO
32 import StringIO
33 import bdb
33 import bdb
34 import cPickle as pickle
35 import codeop
34 import codeop
36 import exceptions
35 import exceptions
37 import glob
36 import glob
38 import inspect
39 import keyword
37 import keyword
40 import new
38 import new
41 import os
39 import os
42 import pydoc
43 import re
40 import re
44 import shutil
41 import shutil
45 import string
42 import string
46 import sys
43 import sys
47 import tempfile
44 import tempfile
48 import traceback
49 import types
50 from pprint import pprint, pformat
51
45
52 # IPython's own modules
46 # IPython's own modules
53 #import IPython
47 #import IPython
54 from IPython import Debugger,OInspect,PyColorize,ultraTB
48 from IPython import Debugger,OInspect,PyColorize,ultraTB
55 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
56 from IPython.Extensions import pickleshare
49 from IPython.Extensions import pickleshare
57 from IPython.FakeModule import FakeModule, init_fakemod_dict
50 from IPython.FakeModule import FakeModule, init_fakemod_dict
58 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
51 from IPython.Itpl import ItplNS
59 from IPython.Logger import Logger
52 from IPython.Logger import Logger
60 from IPython.Magic import Magic
53 from IPython.Magic import Magic
61 from IPython.Prompts import CachedOutput
54 from IPython.Prompts import CachedOutput
62 from IPython.ipstruct import Struct
55 from IPython.ipstruct import Struct
63 from IPython.background_jobs import BackgroundJobManager
56 from IPython.background_jobs import BackgroundJobManager
64 from IPython.usage import cmd_line_usage,interactive_usage
65 from IPython.genutils import *
57 from IPython.genutils import *
66 from IPython.strdispatch import StrDispatch
58 from IPython.strdispatch import StrDispatch
67 import IPython.ipapi
59 import IPython.ipapi
@@ -21,30 +21,26 b' __docformat__ = "restructuredtext en"'
21
21
22 # Required modules
22 # Required modules
23 import __builtin__
23 import __builtin__
24 import os
25 import socket
24 import socket
26 import sys
25 import sys
27 import time
28
26
29 # IPython's own
27 # IPython's own
30 from IPython.external.Itpl import ItplNS
28 from IPython.external.Itpl import ItplNS
31 from macro import Macro
32
29
33 from IPython import ColorANSI
30 from IPython.utils import coloransi
34 from IPython import Release
31 from IPython import Release
35 from IPython.ipapi import TryNext
32 from IPython.ipapi import TryNext
36 from IPython.ipstruct import Struct
37 from IPython.genutils import *
33 from IPython.genutils import *
38
34
39 #****************************************************************************
35 #****************************************************************************
40 #Color schemes for Prompts.
36 #Color schemes for Prompts.
41
37
42 PromptColors = ColorANSI.ColorSchemeTable()
38 PromptColors = coloransi.ColorSchemeTable()
43 InputColors = ColorANSI.InputTermColors # just a shorthand
39 InputColors = coloransi.InputTermColors # just a shorthand
44 Colors = ColorANSI.TermColors # just a shorthand
40 Colors = coloransi.TermColors # just a shorthand
45
41
46
42
47 __PColNoColor = ColorANSI.ColorScheme(
43 __PColNoColor = coloransi.ColorScheme(
48 'NoColor',
44 'NoColor',
49 in_prompt = InputColors.NoColor, # Input prompt
45 in_prompt = InputColors.NoColor, # Input prompt
50 in_number = InputColors.NoColor, # Input prompt number
46 in_number = InputColors.NoColor, # Input prompt number
@@ -172,7 +168,7 b" prompt_specials_nocolor[r'\\#'] = '${self.cache.prompt_count}'"
172 # with a color name which may begin with a letter used by any other of the
168 # with a color name which may begin with a letter used by any other of the
173 # allowed specials. This of course means that \\C will never be allowed for
169 # allowed specials. This of course means that \\C will never be allowed for
174 # anything else.
170 # anything else.
175 input_colors = ColorANSI.InputTermColors
171 input_colors = coloransi.InputTermColors
176 for _color in dir(input_colors):
172 for _color in dir(input_colors):
177 if _color[0] != '_':
173 if _color[0] != '_':
178 c_name = r'\C_'+_color
174 c_name = r'\C_'+_color
@@ -17,17 +17,14 b' __docformat__ = "restructuredtext en"'
17 #-------------------------------------------------------------------------------
17 #-------------------------------------------------------------------------------
18
18
19 import sys
19 import sys
20 import cPickle as pickle
21 from types import FunctionType
22 import linecache
20 import linecache
23 import warnings
21 import warnings
24
22
25 from twisted.internet import reactor
23 from twisted.python import components
26 from twisted.python import components, log
27 from twisted.python.failure import Failure
24 from twisted.python.failure import Failure
28 from zope.interface import Interface, implements, Attribute
25 from zope.interface import Interface, implements, Attribute
29
26
30 from IPython.ColorANSI import TermColors
27 from IPython.utils.coloransi import TermColors
31
28
32 from IPython.kernel.twistedutil import blockingCallFromThread
29 from IPython.kernel.twistedutil import blockingCallFromThread
33 from IPython.kernel import error
30 from IPython.kernel import error
@@ -37,10 +34,8 b' from IPython.kernel.mapper import ('
37 IMultiEngineMapperFactory,
34 IMultiEngineMapperFactory,
38 IMapper
35 IMapper
39 )
36 )
40 from IPython.kernel import map as Map
37
41 from IPython.kernel import multiengine as me
38 from IPython.kernel.multiengine import IFullSynchronousMultiEngine
42 from IPython.kernel.multiengine import (IFullMultiEngine,
43 IFullSynchronousMultiEngine)
44
39
45
40
46 #-------------------------------------------------------------------------------
41 #-------------------------------------------------------------------------------
@@ -311,7 +306,7 b' class InteractiveMultiEngineClient(object):'
311
306
312 def findsource_file(self,f):
307 def findsource_file(self,f):
313 linecache.checkcache()
308 linecache.checkcache()
314 s = findsource(f.f_code)
309 s = findsource(f.f_code) # findsource is not defined!
315 lnum = f.f_lineno
310 lnum = f.f_lineno
316 wsource = s[0][f.f_lineno:]
311 wsource = s[0][f.f_lineno:]
317 return strip_whitespace(wsource)
312 return strip_whitespace(wsource)
@@ -198,7 +198,7 b' def make_runners():'
198 # XXX: Shell.py is also ommited because of a bug in the skip_doctest
198 # XXX: Shell.py is also ommited because of a bug in the skip_doctest
199 # decorator. See ticket https://bugs.launchpad.net/bugs/366209
199 # decorator. See ticket https://bugs.launchpad.net/bugs/366209
200 top_mod = \
200 top_mod = \
201 ['background_jobs.py', 'ColorANSI.py', 'completer.py', 'ConfigLoader.py',
201 ['background_jobs.py', 'coloransi.py', 'completer.py', 'ConfigLoader.py',
202 'CrashHandler.py', 'Debugger.py', 'deep_reload.py', 'demo.py',
202 'CrashHandler.py', 'Debugger.py', 'deep_reload.py', 'demo.py',
203 'DPyGetOpt.py', 'dtutils.py', 'excolors.py', 'FakeModule.py',
203 'DPyGetOpt.py', 'dtutils.py', 'excolors.py', 'FakeModule.py',
204 'generics.py', 'genutils.py', 'history.py', 'hooks.py', 'ipapi.py',
204 'generics.py', 'genutils.py', 'history.py', 'hooks.py', 'ipapi.py',
1 NO CONTENT: file renamed from IPython/ColorANSI.py to IPython/utils/coloransi.py
NO CONTENT: file renamed from IPython/ColorANSI.py to IPython/utils/coloransi.py
@@ -71,6 +71,17 b' We propose to create the following new sub-packages:'
71 standards, but that we plan on keeping. To be moved out of this sub-package
71 standards, but that we plan on keeping. To be moved out of this sub-package
72 a module needs to have a maintainer, tests and documentation.
72 a module needs to have a maintainer, tests and documentation.
73
73
74 Prodecure
75 =========
76
77 1. Move the file to its new location with its new name.
78 2. Rename all import statements to reflect the change.
79 3. Run PyFlakes on each changes module.
80 3. Add tests/test_imports.py to test it.
81
82 Need to modify iptests to properly skip modules that are no longer top
83 level modules.
84
74 Where things will be moved
85 Where things will be moved
75 ==========================
86 ==========================
76
87
General Comments 0
You need to be logged in to leave comments. Login now