diff --git a/IPython/CrashHandler.py b/IPython/CrashHandler.py index b437cac..1b48c18 100644 --- a/IPython/CrashHandler.py +++ b/IPython/CrashHandler.py @@ -21,13 +21,12 @@ Authors # From the standard library import os import sys -from pprint import pprint,pformat +from pprint import pformat # Our own from IPython import Release from IPython import ultraTB -from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names -from IPython.Itpl import Itpl,itpl,printpl +from IPython.Itpl import itpl from IPython.genutils import * diff --git a/IPython/Debugger.py b/IPython/Debugger.py index 117b7d1..3223c7b 100644 --- a/IPython/Debugger.py +++ b/IPython/Debugger.py @@ -31,7 +31,8 @@ import linecache import os import sys -from IPython import PyColorize, ColorANSI, ipapi +from IPython import PyColorize, ipapi +from IPython.utils import coloransi from IPython.genutils import Term from IPython.excolors import exception_colors @@ -114,7 +115,7 @@ class Tracer(object): def_colors = 'NoColor' try: # Limited tab completion support - import rlcompleter,readline + import readline readline.parse_and_bind('tab: complete') except ImportError: pass @@ -207,7 +208,7 @@ class Pdb(OldPdb): self.color_scheme_table = exception_colors() # shorthands - C = ColorANSI.TermColors + C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.breakpoint_enabled = C.NoColor @@ -254,7 +255,7 @@ class Pdb(OldPdb): self.color_scheme_table = exception_colors() # shorthands - C = ColorANSI.TermColors + C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.breakpoint_enabled = C.NoColor diff --git a/IPython/OInspect.py b/IPython/OInspect.py index ecef640..0aa196e 100644 --- a/IPython/OInspect.py +++ b/IPython/OInspect.py @@ -31,7 +31,7 @@ from IPython import PyColorize from IPython.genutils import page,indent,Term from IPython.Itpl import itpl from IPython.wildcard import list_namespace -from IPython.ColorANSI import * +from IPython.utils.coloransi import * #**************************************************************************** # HACK!!! This is a crude fix for bugs in python 2.3's inspect module. We diff --git a/IPython/Prompts.py b/IPython/Prompts.py index 21f1086..8ad8db1 100644 --- a/IPython/Prompts.py +++ b/IPython/Prompts.py @@ -20,7 +20,7 @@ import sys import time # IPython's own -from IPython import ColorANSI +from IPython.utils import coloransi from IPython import Release from IPython.external.Itpl import ItplNS from IPython.ipapi import TryNext @@ -32,11 +32,11 @@ from IPython.genutils import * #**************************************************************************** #Color schemes for Prompts. -PromptColors = ColorANSI.ColorSchemeTable() -InputColors = ColorANSI.InputTermColors # just a shorthand -Colors = ColorANSI.TermColors # just a shorthand +PromptColors = coloransi.ColorSchemeTable() +InputColors = coloransi.InputTermColors # just a shorthand +Colors = coloransi.TermColors # just a shorthand -PromptColors.add_scheme(ColorANSI.ColorScheme( +PromptColors.add_scheme(coloransi.ColorScheme( 'NoColor', in_prompt = InputColors.NoColor, # Input prompt in_number = InputColors.NoColor, # Input prompt number @@ -50,7 +50,7 @@ PromptColors.add_scheme(ColorANSI.ColorScheme( )) # make some schemes as instances so we can copy them for modification easily: -__PColLinux = ColorANSI.ColorScheme( +__PColLinux = coloransi.ColorScheme( 'Linux', in_prompt = InputColors.Green, in_number = InputColors.LightGreen, @@ -185,7 +185,7 @@ prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}' # with a color name which may begin with a letter used by any other of the # allowed specials. This of course means that \\C will never be allowed for # anything else. -input_colors = ColorANSI.InputTermColors +input_colors = coloransi.InputTermColors for _color in dir(input_colors): if _color[0] != '_': c_name = r'\C_'+_color diff --git a/IPython/PyColorize.py b/IPython/PyColorize.py index 7d463ea..613ae19 100644 --- a/IPython/PyColorize.py +++ b/IPython/PyColorize.py @@ -38,12 +38,11 @@ import cStringIO import keyword import os import optparse -import string import sys import token import tokenize -from IPython.ColorANSI import * +from IPython.utils.coloransi import * ############################################################################# ### Python Source Parser (does Hilighting) diff --git a/IPython/__init__.py b/IPython/__init__.py index 2fb3281..c509ad1 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- """ IPython -- An enhanced Interactive Python diff --git a/IPython/excolors.py b/IPython/excolors.py index 0245eb5..13f67b7 100644 --- a/IPython/excolors.py +++ b/IPython/excolors.py @@ -12,7 +12,7 @@ Color schemes for exception handling code in IPython. #**************************************************************************** # Required modules -from IPython.ColorANSI import ColorSchemeTable, TermColors, ColorScheme +from IPython.utils.coloransi import ColorSchemeTable, TermColors, ColorScheme def exception_colors(): """Return a color table with fields for exception reporting. diff --git a/IPython/frontend/wx/console_widget.py b/IPython/frontend/wx/console_widget.py index 8fcb17a..be20eff 100644 --- a/IPython/frontend/wx/console_widget.py +++ b/IPython/frontend/wx/console_widget.py @@ -105,8 +105,8 @@ ANSI_STYLES = {'0;30': [0, 'BLACK'], '0;31': [1, 'RED'], [13, 'MEDIUM VIOLET RED'], '1;36': [14, 'LIGHT STEEL BLUE'], '1;37': [15, 'YELLOW']} -# XXX: Maybe one day we should factor this code with ColorANSI. Right now -# ColorANSI is hard to reuse and makes our code more complex. +# XXX: Maybe one day we should factor this code with coloransi. Right now +# coloransi is hard to reuse and makes our code more complex. #we define platform specific fonts if wx.Platform == '__WXMSW__': diff --git a/IPython/iplib.py b/IPython/iplib.py index 0de50ec..aae75be 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -31,37 +31,29 @@ import __main__ import __builtin__ import StringIO import bdb -import cPickle as pickle import codeop import exceptions import glob -import inspect import keyword import new import os -import pydoc import re import shutil import string import sys import tempfile -import traceback -import types -from pprint import pprint, pformat # IPython's own modules #import IPython from IPython import Debugger,OInspect,PyColorize,ultraTB -from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names from IPython.Extensions import pickleshare from IPython.FakeModule import FakeModule, init_fakemod_dict -from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns +from IPython.Itpl import ItplNS from IPython.Logger import Logger from IPython.Magic import Magic from IPython.Prompts import CachedOutput from IPython.ipstruct import Struct from IPython.background_jobs import BackgroundJobManager -from IPython.usage import cmd_line_usage,interactive_usage from IPython.genutils import * from IPython.strdispatch import StrDispatch import IPython.ipapi diff --git a/IPython/kernel/core/prompts.py b/IPython/kernel/core/prompts.py index be654ac..8815881 100644 --- a/IPython/kernel/core/prompts.py +++ b/IPython/kernel/core/prompts.py @@ -21,30 +21,26 @@ __docformat__ = "restructuredtext en" # Required modules import __builtin__ -import os import socket import sys -import time # IPython's own from IPython.external.Itpl import ItplNS -from macro import Macro -from IPython import ColorANSI +from IPython.utils import coloransi from IPython import Release from IPython.ipapi import TryNext -from IPython.ipstruct import Struct from IPython.genutils import * #**************************************************************************** #Color schemes for Prompts. -PromptColors = ColorANSI.ColorSchemeTable() -InputColors = ColorANSI.InputTermColors # just a shorthand -Colors = ColorANSI.TermColors # just a shorthand +PromptColors = coloransi.ColorSchemeTable() +InputColors = coloransi.InputTermColors # just a shorthand +Colors = coloransi.TermColors # just a shorthand -__PColNoColor = ColorANSI.ColorScheme( +__PColNoColor = coloransi.ColorScheme( 'NoColor', in_prompt = InputColors.NoColor, # Input prompt in_number = InputColors.NoColor, # Input prompt number @@ -172,7 +168,7 @@ prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}' # with a color name which may begin with a letter used by any other of the # allowed specials. This of course means that \\C will never be allowed for # anything else. -input_colors = ColorANSI.InputTermColors +input_colors = coloransi.InputTermColors for _color in dir(input_colors): if _color[0] != '_': c_name = r'\C_'+_color diff --git a/IPython/kernel/multiengineclient.py b/IPython/kernel/multiengineclient.py index 4281df8..600a877 100644 --- a/IPython/kernel/multiengineclient.py +++ b/IPython/kernel/multiengineclient.py @@ -17,17 +17,14 @@ __docformat__ = "restructuredtext en" #------------------------------------------------------------------------------- import sys -import cPickle as pickle -from types import FunctionType import linecache import warnings -from twisted.internet import reactor -from twisted.python import components, log +from twisted.python import components from twisted.python.failure import Failure from zope.interface import Interface, implements, Attribute -from IPython.ColorANSI import TermColors +from IPython.utils.coloransi import TermColors from IPython.kernel.twistedutil import blockingCallFromThread from IPython.kernel import error @@ -37,10 +34,8 @@ from IPython.kernel.mapper import ( IMultiEngineMapperFactory, IMapper ) -from IPython.kernel import map as Map -from IPython.kernel import multiengine as me -from IPython.kernel.multiengine import (IFullMultiEngine, - IFullSynchronousMultiEngine) + +from IPython.kernel.multiengine import IFullSynchronousMultiEngine #------------------------------------------------------------------------------- @@ -311,7 +306,7 @@ class InteractiveMultiEngineClient(object): def findsource_file(self,f): linecache.checkcache() - s = findsource(f.f_code) + s = findsource(f.f_code) # findsource is not defined! lnum = f.f_lineno wsource = s[0][f.f_lineno:] return strip_whitespace(wsource) diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 02aa77a..094eacf 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -198,7 +198,7 @@ def make_runners(): # XXX: Shell.py is also ommited because of a bug in the skip_doctest # decorator. See ticket https://bugs.launchpad.net/bugs/366209 top_mod = \ - ['background_jobs.py', 'ColorANSI.py', 'completer.py', 'ConfigLoader.py', + ['background_jobs.py', 'coloransi.py', 'completer.py', 'ConfigLoader.py', 'CrashHandler.py', 'Debugger.py', 'deep_reload.py', 'demo.py', 'DPyGetOpt.py', 'dtutils.py', 'excolors.py', 'FakeModule.py', 'generics.py', 'genutils.py', 'history.py', 'hooks.py', 'ipapi.py', diff --git a/IPython/ColorANSI.py b/IPython/utils/coloransi.py similarity index 100% rename from IPython/ColorANSI.py rename to IPython/utils/coloransi.py diff --git a/docs/source/development/reorg.txt b/docs/source/development/reorg.txt index 5484a42..197376d 100644 --- a/docs/source/development/reorg.txt +++ b/docs/source/development/reorg.txt @@ -71,6 +71,17 @@ We propose to create the following new sub-packages: standards, but that we plan on keeping. To be moved out of this sub-package a module needs to have a maintainer, tests and documentation. +Prodecure +========= + +1. Move the file to its new location with its new name. +2. Rename all import statements to reflect the change. +3. Run PyFlakes on each changes module. +3. Add tests/test_imports.py to test it. + +Need to modify iptests to properly skip modules that are no longer top +level modules. + Where things will be moved ==========================