From 572a8cc908b671101b50871cd74178ca92357b0c 2005-12-27 23:17:51 From: fperez Date: 2005-12-27 23:17:51 Subject: [PATCH] Cosmetic cleanups: put all imports in a single line, and sort them alphabetically. This will make it easier to see/clean dependencies as we start copying stuff into chainsaw. --- diff --git a/IPython/ConfigLoader.py b/IPython/ConfigLoader.py index 192a92e..b4b1e3e 100644 --- a/IPython/ConfigLoader.py +++ b/IPython/ConfigLoader.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Configuration loader -$Id: ConfigLoader.py 525 2005-02-19 10:53:12Z fperez $""" +$Id: ConfigLoader.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -14,9 +14,9 @@ from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = Release.license +import exceptions import os from pprint import pprint -import exceptions from IPython import ultraTB from IPython.Struct import Struct diff --git a/IPython/CrashHandler.py b/IPython/CrashHandler.py index 056a296..cdf11ef 100644 --- a/IPython/CrashHandler.py +++ b/IPython/CrashHandler.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """sys.excepthook for IPython itself, leaves a detailed report on disk. -$Id: CrashHandler.py 951 2005-12-25 00:57:24Z fperez $""" +$Id: CrashHandler.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -19,7 +19,8 @@ __version__ = Release.version # Required modules # From the standard library -import os,sys +import os +import sys from pprint import pprint,pformat # Homebrewed diff --git a/IPython/DPyGetOpt.py b/IPython/DPyGetOpt.py index 75a7461..0dcc7ea 100644 --- a/IPython/DPyGetOpt.py +++ b/IPython/DPyGetOpt.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """DPyGetOpt -- Demiurge Python GetOptions Module - $Id: DPyGetOpt.py 389 2004-10-09 07:59:30Z fperez $ + $Id: DPyGetOpt.py 958 2005-12-27 23:17:51Z fperez $ This module is modeled after perl's Getopt::Long module-- which is, in turn, modeled after GNU's extended getopt() function. @@ -33,7 +33,7 @@ and -baz options that appear on within the parsed argument list must have a real number argument and that the accumulated list of values will be available under the name 'foo' -$Id: DPyGetOpt.py 389 2004-10-09 07:59:30Z fperez $""" +$Id: DPyGetOpt.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # @@ -69,8 +69,8 @@ __version__ = '1.2' # Modified to use re instead of regex and regsub modules. # 2001/5/7, Jonathan Hogg -import string import re +import string import sys import types diff --git a/IPython/Debugger.py b/IPython/Debugger.py index 6ab35b2..bae4cae 100644 --- a/IPython/Debugger.py +++ b/IPython/Debugger.py @@ -15,13 +15,19 @@ details on the PSF (Python Software Foundation) standard license, see: http://www.python.org/2.2.3/license.html -$Id: Debugger.py 951 2005-12-25 00:57:24Z fperez $""" +$Id: Debugger.py 958 2005-12-27 23:17:51Z fperez $""" from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = 'Python' -import pdb,bdb,cmd,os,sys,linecache +import bdb +import cmd +import linecache +import os +import pdb +import sys + from IPython import PyColorize, ColorANSI from IPython.genutils import Term from IPython.excolors import ExceptionColors diff --git a/IPython/Gnuplot2.py b/IPython/Gnuplot2.py index 4fe431f..080717c 100644 --- a/IPython/Gnuplot2.py +++ b/IPython/Gnuplot2.py @@ -13,14 +13,19 @@ Gnuplot, so it should be safe to do: import IPython.Gnuplot2 as Gnuplot -$Id: Gnuplot2.py 392 2004-10-09 22:01:51Z fperez $""" +$Id: Gnuplot2.py 958 2005-12-27 23:17:51Z fperez $""" -import string,os,time,types import cStringIO +import os +import string import sys import tempfile -import Numeric +import time +import types + import Gnuplot as Gnuplot_ori +import Numeric + from IPython.genutils import popkey,xsys # needed by hardcopy(): diff --git a/IPython/Itpl.py b/IPython/Itpl.py index a551dac..480d859 100644 --- a/IPython/Itpl.py +++ b/IPython/Itpl.py @@ -44,7 +44,7 @@ each time the instance is evaluated with str(instance). For example: foo = "bar" print str(s) -$Id: Itpl.py 638 2005-07-18 03:01:41Z fperez $ +$Id: Itpl.py 958 2005-12-27 23:17:51Z fperez $ """ # ' -> close an open quote for stupid emacs #***************************************************************************** @@ -77,9 +77,10 @@ $Id: Itpl.py 638 2005-07-18 03:01:41Z fperez $ __author__ = 'Ka-Ping Yee ' __license__ = 'MIT' -import sys, string -from types import StringType +import string +import sys from tokenize import tokenprog +from types import StringType class ItplError(ValueError): def __init__(self, text, pos): diff --git a/IPython/Logger.py b/IPython/Logger.py index ae721aa..45f31cc 100644 --- a/IPython/Logger.py +++ b/IPython/Logger.py @@ -2,7 +2,7 @@ """ Logger class for IPython's logging facilities. -$Id: Logger.py 430 2004-11-30 08:52:05Z fperez $ +$Id: Logger.py 958 2005-12-27 23:17:51Z fperez $ """ #***************************************************************************** @@ -22,7 +22,9 @@ __author__ = '%s <%s>\n%s <%s>' % \ __license__ = Release.license # Python standard modules -import os,sys,glob +import glob +import os +import sys # Homebrewed from IPython.genutils import * diff --git a/IPython/Magic.py b/IPython/Magic.py index 1fb7eba..457be06 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 951 2005-12-25 00:57:24Z fperez $""" +$Id: Magic.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -21,11 +21,18 @@ __license__ = Release.license # Python standard modules import __builtin__ -import os,sys,inspect,pydoc,re,tempfile,pdb,bdb,time -import Debugger +import bdb +import inspect +import os +import pdb +import pydoc +import sys +import re +import tempfile +import time +from cStringIO import StringIO from getopt import getopt from pprint import pprint, pformat -from cStringIO import StringIO # profile isn't bundled by default in Debian for license reasons try: @@ -34,12 +41,11 @@ except ImportError: profile = pstats = None # Homebrewed -from IPython.Struct import Struct -from IPython.Itpl import Itpl, itpl, printpl,itplns +from IPython import Debugger, OInspect, wildcard from IPython.FakeModule import FakeModule +from IPython.Itpl import Itpl, itpl, printpl,itplns from IPython.PyColorize import Parser -from IPython import OInspect -from IPython import wildcard +from IPython.Struct import Struct from IPython.genutils import * # Globals to be set later by Magic constructor diff --git a/IPython/OInspect.py b/IPython/OInspect.py index aa7b5c0..7c975a9 100644 --- a/IPython/OInspect.py +++ b/IPython/OInspect.py @@ -6,7 +6,7 @@ Uses syntax highlighting for presenting the various information elements. Similar in spirit to the inspect module, but all calls take a name argument to reference the name under which an object is being read. -$Id: OInspect.py 923 2005-11-15 08:51:15Z fperez $ +$Id: OInspect.py 958 2005-12-27 23:17:51Z fperez $ """ #***************************************************************************** @@ -24,13 +24,17 @@ __all__ = ['Inspector','InspectColors'] # stdlib modules import __builtin__ -import inspect,linecache,types,StringIO,string +import inspect +import linecache +import string +import StringIO +import types # IPython's own from IPython import PyColorize +from IPython.genutils import page,indent,Term,mkdict from IPython.Itpl import itpl from IPython.wildcard import list_namespace -from IPython.genutils import page,indent,Term,mkdict from IPython.ColorANSI import * #**************************************************************************** diff --git a/IPython/OutputTrap.py b/IPython/OutputTrap.py index 670aa5a..d60216a 100644 --- a/IPython/OutputTrap.py +++ b/IPython/OutputTrap.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Class to trap stdout and stderr and log them separately. -$Id: OutputTrap.py 542 2005-03-18 09:16:04Z fperez $""" +$Id: OutputTrap.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -14,7 +14,8 @@ from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = Release.license -import exceptions,sys +import exceptions +import sys from cStringIO import StringIO class OutputTrapError(exceptions.Exception): diff --git a/IPython/Prompts.py b/IPython/Prompts.py index e872ca6..10befc5 100644 --- a/IPython/Prompts.py +++ b/IPython/Prompts.py @@ -2,7 +2,7 @@ """ Classes for handling input/output prompts. -$Id: Prompts.py 951 2005-12-25 00:57:24Z fperez $""" +$Id: Prompts.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -19,7 +19,9 @@ __version__ = Release.version #**************************************************************************** # Required modules import __builtin__ -import os,sys,socket +import os +import socket +import sys import time from pprint import pprint,pformat diff --git a/IPython/PyColorize.py b/IPython/PyColorize.py index 1481725..ed20759 100755 --- a/IPython/PyColorize.py +++ b/IPython/PyColorize.py @@ -28,15 +28,20 @@ scan Python source code and re-emit it with no changes to its original formatting (which is the hard part). - $Id: PyColorize.py 485 2005-01-27 19:15:39Z fperez $""" + $Id: PyColorize.py 958 2005-12-27 23:17:51Z fperez $""" __all__ = ['ANSICodeColors','Parser'] _scheme_default = 'Linux' # Imports -import string, sys, os, cStringIO -import keyword, token, tokenize +import cStringIO +import keyword +import os +import string +import sys +import token +import tokenize from IPython.ColorANSI import * diff --git a/IPython/Shell.py b/IPython/Shell.py index ca7229f..9c46fa8 100644 --- a/IPython/Shell.py +++ b/IPython/Shell.py @@ -4,7 +4,7 @@ All the matplotlib support code was co-developed with John Hunter, matplotlib's author. -$Id: Shell.py 952 2005-12-26 17:51:33Z fperez $""" +$Id: Shell.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -20,19 +20,18 @@ __license__ = Release.license # Code begins import __main__ import __builtin__ -import sys import os -import code -import threading +import sys import signal +import threading import IPython +from IPython import ultraTB +from IPython.genutils import Term,warn,error,flag_calls from IPython.iplib import InteractiveShell from IPython.ipmaker import make_IPython -from IPython.genutils import Term,warn,error,flag_calls -from IPython.Struct import Struct from IPython.Magic import Magic -from IPython import ultraTB +from IPython.Struct import Struct # global flag to pass around information about Ctrl-C without exceptions KBINT = False diff --git a/IPython/Struct.py b/IPython/Struct.py index 4c4f125..d3971d7 100644 --- a/IPython/Struct.py +++ b/IPython/Struct.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Mimic C structs with lots of extra functionality. -$Id: Struct.py 638 2005-07-18 03:01:41Z fperez $""" +$Id: Struct.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -17,6 +17,7 @@ __license__ = Release.license __all__ = ['Struct'] import types + from IPython.genutils import list2dict2 class Struct: diff --git a/IPython/background_jobs.py b/IPython/background_jobs.py index e428b47..904dc10 100644 --- a/IPython/background_jobs.py +++ b/IPython/background_jobs.py @@ -18,7 +18,7 @@ http://folk.uio.no/hpl/scripting (although ultimately no code from this text was used, as IPython's system is a separate implementation). -$Id: background_jobs.py 638 2005-07-18 03:01:41Z fperez $ +$Id: background_jobs.py 958 2005-12-27 23:17:51Z fperez $ """ #***************************************************************************** @@ -33,7 +33,8 @@ __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = Release.license # Code begins -import threading,sys +import sys +import threading from IPython.ultraTB import AutoFormattedTB from IPython.genutils import warn,error diff --git a/IPython/completer.py b/IPython/completer.py index 2454a88..d8f340c 100644 --- a/IPython/completer.py +++ b/IPython/completer.py @@ -77,10 +77,10 @@ from IPython.genutils import shlex_split __all__ = ['Completer','IPCompleter'] -def get_class_members(klass): - ret = dir(klass) - if hasattr(klass,'__bases__'): - for base in klass.__bases__: +def get_class_members(cls): + ret = dir(cls) + if hasattr(cls,'__bases__'): + for base in cls.__bases__: ret.extend(get_class_members(base)) return ret diff --git a/IPython/deep_reload.py b/IPython/deep_reload.py index eb8dd11..f8da73c 100644 --- a/IPython/deep_reload.py +++ b/IPython/deep_reload.py @@ -12,7 +12,7 @@ Alternatively, you can add a dreload builtin alongside normal reload with: This code is almost entirely based on knee.py from the standard library. -$Id: deep_reload.py 410 2004-11-04 07:58:17Z fperez $""" +$Id: deep_reload.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Nathaniel Gray @@ -27,7 +27,9 @@ __license__ = Release.license __version__ = "0.5" __date__ = "21 August 2001" -import sys, imp, __builtin__ +import __builtin__ +import imp +import sys # Replacement for __import__() def deep_import_hook(name, globals=None, locals=None, fromlist=None): diff --git a/IPython/demo.py b/IPython/demo.py index af39a85..d1ed570 100644 --- a/IPython/demo.py +++ b/IPython/demo.py @@ -107,9 +107,9 @@ environments. # #***************************************************************************** -import sys import exceptions import re +import sys from IPython.PyColorize import Parser from IPython.genutils import marquee, shlex_split, file_read diff --git a/IPython/genutils.py b/IPython/genutils.py index 64be144..f4717c6 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -5,7 +5,7 @@ General purpose utilities. This is a grab-bag of stuff I find useful in most programs I write. Some of these things are also convenient when working at the command line. -$Id: genutils.py 908 2005-09-26 16:05:48Z fperez $""" +$Id: genutils.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -21,11 +21,19 @@ __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = Release.license #**************************************************************************** -# required modules +# required modules from the Python standard library import __main__ -import types,commands,time,sys,os,re,shutil +import commands +import os +import re import shlex +import shutil +import sys import tempfile +import time +import types + +# Other IPython utilities from IPython.Itpl import Itpl,itpl,printpl from IPython import DPyGetOpt diff --git a/IPython/iplib.py b/IPython/iplib.py index a135f92..8847f44 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.1 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 957 2005-12-27 22:33:22Z fperez $ +$Id: iplib.py 958 2005-12-27 23:17:51Z fperez $ """ #***************************************************************************** @@ -64,18 +64,15 @@ from pprint import pprint, pformat import IPython from IPython import OInspect,PyColorize,ultraTB from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names +from IPython.FakeModule import FakeModule +from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns from IPython.Logger import Logger from IPython.Magic import Magic,magic2python -from IPython.usage import cmd_line_usage,interactive_usage from IPython.Struct import Struct -from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns -from IPython.FakeModule import FakeModule from IPython.background_jobs import BackgroundJobManager -from IPython.PyColorize import Parser +from IPython.usage import cmd_line_usage,interactive_usage from IPython.genutils import * -# Global pointer to the running - # store the builtin raw_input globally, and use this always, in case user code # overwrites it (like wx.py.PyShell does) raw_input_original = raw_input @@ -396,12 +393,12 @@ class InteractiveShell(Logger, Magic): __builtin__.jobs = self.jobs # escapes for automatic behavior on the command line - self.ESC_SHELL = '!' - self.ESC_HELP = '?' - self.ESC_MAGIC = '%' - self.ESC_QUOTE = ',' + self.ESC_SHELL = '!' + self.ESC_HELP = '?' + self.ESC_MAGIC = '%' + self.ESC_QUOTE = ',' self.ESC_QUOTE2 = ';' - self.ESC_PAREN = '/' + self.ESC_PAREN = '/' # And their associated handlers self.esc_handlers = {self.ESC_PAREN:self.handle_auto, @@ -421,7 +418,7 @@ class InteractiveShell(Logger, Magic): Magic.set_shell(self,self) # Python source parser/formatter for syntax highlighting - pyformat = Parser().format + pyformat = PyColorize.Parser().format self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) # hooks holds pointers used for user-side customizations @@ -553,9 +550,9 @@ class InteractiveShell(Logger, Magic): self.set_custom_exc(*custom_exceptions) # Object inspector - ins_colors = OInspect.InspectColors - code_colors = PyColorize.ANSICodeColors - self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor') + self.inspector = OInspect.Inspector(OInspect.InspectColors, + PyColorize.ANSICodeColors, + 'NoColor') self.autoindent = False # Make some aliases automatically @@ -1440,8 +1437,7 @@ want to merge them back into the new files.""" % locals() """ self.buffer.append(line) - source = "\n".join(self.buffer) - more = self.runsource(source, self.filename) + more = self.runsource('\n'.join(self.buffer), self.filename) if not more: self.resetbuffer() return more diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index 2f6ff75..80b28ea 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -6,7 +6,7 @@ Requires Python 2.1 or better. This file contains the main make_IPython() starter function. -$Id: ipmaker.py 925 2005-11-15 20:39:39Z fperez $""" +$Id: ipmaker.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -36,8 +36,12 @@ All Rights Reserved.""" # Required modules # From the standard library -import __main__, __builtin__ -import os,sys,types,re +import __main__ +import __builtin__ +import os +import re +import sys +import types from pprint import pprint,pformat # Our own diff --git a/IPython/numutils.py b/IPython/numutils.py index 4d924e9..d809277 100644 --- a/IPython/numutils.py +++ b/IPython/numutils.py @@ -5,7 +5,7 @@ A set of convenient utilities for numerical work. Most of this module requires Numerical Python or is meant to be used with it. See http://www.pfdubois.com/numpy for details. -$Id: numutils.py 486 2005-01-27 19:34:21Z fperez $""" +$Id: numutils.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2005 Fernando Perez @@ -29,8 +29,10 @@ __all__ = ['sum_flat','mean_flat','rms_flat','base_repr','binary_repr', #**************************************************************************** # required modules import __main__ -import sys,operator import math +import operator +import sys + import Numeric from Numeric import * diff --git a/IPython/ultraTB.py b/IPython/ultraTB.py index db50c48..b052331 100644 --- a/IPython/ultraTB.py +++ b/IPython/ultraTB.py @@ -60,7 +60,7 @@ You can implement other color schemes easily, the syntax is fairly self-explanatory. Please send back new schemes you develop to the author for possible inclusion in future releases. -$Id: ultraTB.py 954 2005-12-26 19:40:50Z fperez $""" +$Id: ultraTB.py 958 2005-12-27 23:17:51Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Nathaniel Gray @@ -76,17 +76,24 @@ __author__ = '%s <%s>\n%s <%s>' % (Release.authors['Nathan']+ __license__ = Release.license # Required modules -import sys, os, traceback, types, string, time -import keyword, tokenize, linecache, inspect, pydoc -from UserDict import UserDict +import inspect +import keyword +import linecache +import os +import pydoc +import string +import sys +import time +import tokenize +import traceback +import types # IPython's own modules # Modified pdb which doesn't damage IPython's readline handling from IPython import Debugger - from IPython.Struct import Struct -from IPython.genutils import Term,uniq_stable,error,info from IPython.excolors import ExceptionColors +from IPython.genutils import Term,uniq_stable,error,info #--------------------------------------------------------------------------- # Code begins diff --git a/IPython/wildcard.py b/IPython/wildcard.py index c7fb2ff..5236a8d 100644 --- a/IPython/wildcard.py +++ b/IPython/wildcard.py @@ -16,11 +16,11 @@ __author__ = "Jörgen Stenarson " __license__ = Release.license import __builtin__ -import types -import re -import pprint import exceptions import pdb +import pprint +import re +import types def create_typestr2type_dicts(dont_include_in_type2type2str=["lambda"]): """Return dictionaries mapping lower case typename to type objects, from