]> granicus.if.org Git - python/commitdiff
massive import cleaning in Distutils
authorTarek Ziadé <ziade.tarek@gmail.com>
Mon, 21 Dec 2009 01:22:46 +0000 (01:22 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Mon, 21 Dec 2009 01:22:46 +0000 (01:22 +0000)
24 files changed:
Lib/distutils/bcppcompiler.py
Lib/distutils/ccompiler.py
Lib/distutils/command/bdist.py
Lib/distutils/command/bdist_msi.py
Lib/distutils/command/bdist_rpm.py
Lib/distutils/command/bdist_wininst.py
Lib/distutils/command/build_clib.py
Lib/distutils/command/build_ext.py
Lib/distutils/command/build_py.py
Lib/distutils/command/config.py
Lib/distutils/command/register.py
Lib/distutils/command/sdist.py
Lib/distutils/command/upload.py
Lib/distutils/config.py
Lib/distutils/core.py
Lib/distutils/cygwinccompiler.py
Lib/distutils/dir_util.py
Lib/distutils/dist.py
Lib/distutils/emxccompiler.py
Lib/distutils/extension.py
Lib/distutils/fancy_getopt.py
Lib/distutils/msvc9compiler.py
Lib/distutils/msvccompiler.py
Lib/distutils/text_file.py

index 5a0fa727cd82433cc48f60e3b088c4248b10034f..f26e7ae4673bd4bb477a4a0e117d8e30c4f62126 100644 (file)
@@ -13,13 +13,11 @@ for the Borland C++ compiler.
 
 __revision__ = "$Id$"
 
-
 import os
-from distutils.errors import \
-     DistutilsExecError, DistutilsPlatformError, \
-     CompileError, LibError, LinkError, UnknownFileError
-from distutils.ccompiler import \
-     CCompiler, gen_preprocess_options, gen_lib_options
+
+from distutils.errors import (DistutilsExecError, CompileError, LibError,
+                              LinkError, UnknownFileError)
+from distutils.ccompiler import CCompiler, gen_preprocess_options
 from distutils.file_util import write_file
 from distutils.dep_util import newer
 from distutils import log
index e093eef2e864a3aa5507f6548291a84c08a29b32..c046915153a288f22c17a4353a06ddb934c32fdd 100644 (file)
@@ -5,9 +5,11 @@ for the Distutils compiler abstraction model."""
 
 __revision__ = "$Id$"
 
-import sys, os, re
-from types import *
-from distutils.errors import *
+import sys
+import os
+import re
+
+from distutils.errors import CompileError, LinkError, UnknownFileError
 from distutils.spawn import spawn
 from distutils.file_util import move_file
 from distutils.dir_util import mkpath
@@ -165,7 +167,7 @@ class CCompiler:
     # set_executables ()
 
     def set_executable(self, key, value):
-        if type(value) is StringType:
+        if isinstance(value, str):
             setattr(self, key, split_quoted(value))
         else:
             setattr(self, key, value)
@@ -187,11 +189,11 @@ class CCompiler:
         nothing if all definitions are OK, raise TypeError otherwise.
         """
         for defn in definitions:
-            if not (type (defn) is TupleType and
+            if not (isinstance(defn, tuple) and
                     (len (defn) == 1 or
                      (len (defn) == 2 and
-                      (type (defn[1]) is StringType or defn[1] is None))) and
-                    type (defn[0]) is StringType):
+                      (isinstance(defn[1], str) or defn[1] is None))) and
+                    isinstance(defn[0], str)):
                 raise TypeError, \
                       ("invalid macro definition '%s': " % defn) + \
                       "must be tuple (string,), (string, string), or " + \
@@ -341,19 +343,19 @@ class CCompiler:
         """
         if outdir is None:
             outdir = self.output_dir
-        elif type(outdir) is not StringType:
+        elif not isinstance(outdir, str):
             raise TypeError, "'output_dir' must be a string or None"
 
         if macros is None:
             macros = self.macros
-        elif type(macros) is ListType:
+        elif isinstance(macros, list):
             macros = macros + (self.macros or [])
         else:
             raise TypeError, "'macros' (if supplied) must be a list of tuples"
 
         if incdirs is None:
             incdirs = self.include_dirs
-        elif type(incdirs) in (ListType, TupleType):
+        elif isinstance(incdirs, (list, tuple)):
             incdirs = list(incdirs) + (self.include_dirs or [])
         else:
             raise TypeError, \
@@ -444,14 +446,14 @@ class CCompiler:
 
         if macros is None:
             macros = self.macros
-        elif type (macros) is ListType:
+        elif isinstance(macros, list):
             macros = macros + (self.macros or [])
         else:
             raise TypeError, "'macros' (if supplied) must be a list of tuples"
 
         if include_dirs is None:
             include_dirs = self.include_dirs
-        elif type (include_dirs) in (ListType, TupleType):
+        elif isinstance(include_dirs, (list, tuple)):
             include_dirs = list (include_dirs) + (self.include_dirs or [])
         else:
             raise TypeError, \
@@ -517,14 +519,14 @@ class CCompiler:
         None, replace with self.output_dir.  Return fixed versions of
         'objects' and 'output_dir'.
         """
-        if type (objects) not in (ListType, TupleType):
+        if not isinstance(objects, (list, tuple)):
             raise TypeError, \
                   "'objects' must be a list or tuple of strings"
         objects = list (objects)
 
         if output_dir is None:
             output_dir = self.output_dir
-        elif type (output_dir) is not StringType:
+        elif not isinstance(output_dir, str):
             raise TypeError, "'output_dir' must be a string or None"
 
         return (objects, output_dir)
@@ -539,7 +541,7 @@ class CCompiler:
         """
         if libraries is None:
             libraries = self.libraries
-        elif type (libraries) in (ListType, TupleType):
+        elif isinstance(libraries, (list, tuple)):
             libraries = list (libraries) + (self.libraries or [])
         else:
             raise TypeError, \
@@ -547,7 +549,7 @@ class CCompiler:
 
         if library_dirs is None:
             library_dirs = self.library_dirs
-        elif type (library_dirs) in (ListType, TupleType):
+        elif isinstance(library_dirs, (list, tuple)):
             library_dirs = list (library_dirs) + (self.library_dirs or [])
         else:
             raise TypeError, \
@@ -555,7 +557,7 @@ class CCompiler:
 
         if runtime_library_dirs is None:
             runtime_library_dirs = self.runtime_library_dirs
-        elif type (runtime_library_dirs) in (ListType, TupleType):
+        elif isinstance(runtime_library_dirs, (list, tuple)):
             runtime_library_dirs = (list (runtime_library_dirs) +
                                     (self.runtime_library_dirs or []))
         else:
@@ -587,7 +589,7 @@ class CCompiler:
         """Detect the language of a given file, or list of files. Uses
         language_map, and language_order to do the job.
         """
-        if type(sources) is not ListType:
+        if not isinstance(sources, list):
             sources = [sources]
         lang = None
         index = len(self.language_order)
@@ -1194,7 +1196,7 @@ def gen_preprocess_options (macros, include_dirs):
     pp_opts = []
     for macro in macros:
 
-        if not (type (macro) is TupleType and
+        if not (isinstance(macro, tuple) and
                 1 <= len (macro) <= 2):
             raise TypeError, \
                   ("bad macro definition '%s': " +
index 8e0ad080b916f1514a55106a69170bb56d8f3ef9..8cd69701cf731180e806f24e75c118cd1ce5e153 100644 (file)
@@ -6,9 +6,9 @@ distribution)."""
 __revision__ = "$Id$"
 
 import os
-from types import *
+
 from distutils.core import Command
-from distutils.errors import *
+from distutils.errors import DistutilsPlatformError, DistutilsOptionError
 from distutils.util import get_platform
 
 
@@ -16,7 +16,7 @@ def show_formats():
     """Print list of available formats (arguments to "--format" option).
     """
     from distutils.fancy_getopt import FancyGetopt
-    formats=[]
+    formats = []
     for format in bdist.format_commands:
         formats.append(("formats=" + format, None,
                         bdist.format_command[format][1]))
index 7a5ca807a60e8840cffb990620741385fa2db667..f3791bedfe027a8415bd906a68c18cc9c9467956 100644 (file)
@@ -28,7 +28,6 @@ class PyDialog(Dialog):
         default, cancel, bitmap=true)"""
         Dialog.__init__(self, *args)
         ruler = self.h - 36
-        bmwidth = 152*ruler/328
         #if kw.get("bitmap", True):
         #    self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
         self.line("BottomLine", 0, ruler, self.w, 0)
@@ -420,7 +419,6 @@ class bdist_msi (Command):
         # see "Dialog Style Bits"
         modal = 3      # visible | modal
         modeless = 1   # visible
-        track_disk_space = 32
 
         # UI customization properties
         add_data(db, "Property",
index 1eccc6a48a9a73cbb3cdd9f13677163d508bbe5a..6d9d47d2eb36739d365470f145273df7071e2292 100644 (file)
@@ -5,14 +5,15 @@ distributions)."""
 
 __revision__ = "$Id$"
 
-import sys, os, string
-from types import *
+import sys
+import os
+import string
+
 from distutils.core import Command
 from distutils.debug import DEBUG
-from distutils.util import get_platform
 from distutils.file_util import write_file
-from distutils.errors import *
-from distutils.sysconfig import get_python_version
+from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
+                              DistutilsFileError, DistutilsExecError)
 from distutils import log
 
 class bdist_rpm (Command):
@@ -225,7 +226,7 @@ class bdist_rpm (Command):
                                         self.distribution.get_contact_email()))
         self.ensure_string('packager')
         self.ensure_string_list('doc_files')
-        if type(self.doc_files) is ListType:
+        if isinstance(self.doc_files, list):
             for readme in ('README', 'README.txt'):
                 if os.path.exists(readme) and readme not in self.doc_files:
                     self.doc_files.append(readme)
@@ -444,7 +445,7 @@ class bdist_rpm (Command):
                       'Obsoletes',
                       ):
             val = getattr(self, string.lower(field))
-            if type(val) is ListType:
+            if isinstance(val, list):
                 spec_file.append('%s: %s' % (field, string.join(val)))
             elif val is not None:
                 spec_file.append('%s: %s' % (field, val))
index 8a6eca59d837bff19caa4fc9daef897cdf9f861a..cf4282d83fe7b201c3681ea906225e068a88e0f9 100644 (file)
@@ -5,11 +5,14 @@ exe-program."""
 
 __revision__ = "$Id$"
 
-import sys, os, string
+import sys
+import os
+import string
+
 from distutils.core import Command
 from distutils.util import get_platform
-from distutils.dir_util import create_tree, remove_tree
-from distutils.errors import *
+from distutils.dir_util import remove_tree
+from distutils.errors import DistutilsOptionError, DistutilsPlatformError
 from distutils.sysconfig import get_python_version
 from distutils import log
 
index 9545b27ad06b2c51e25c2cf19060664735e447a3..50b64dba251a48b891e83ccec68d97df6b308bb5 100644 (file)
@@ -18,7 +18,7 @@ __revision__ = "$Id$"
 
 import os
 from distutils.core import Command
-from distutils.errors import *
+from distutils.errors import DistutilsSetupError
 from distutils.sysconfig import customize_compiler
 from distutils import log
 
index 0c79476bac1fa59f26b55da673e31d36cc18220c..ff1a4be31546688fff575dd952a7d838c7b58e69 100644 (file)
@@ -10,7 +10,8 @@ import sys, os, re
 from warnings import warn
 
 from distutils.core import Command
-from distutils.errors import *
+from distutils.errors import (CCompilerError, DistutilsError, CompileError,
+                              DistutilsSetupError, DistutilsPlatformError)
 from distutils.sysconfig import customize_compiler, get_python_version
 from distutils.dep_util import newer_group
 from distutils.extension import Extension
index 5c7b473b045d7708001492cc2770a175333eb06f..04c455f0eb9a2efda0d6d199010f96bff26f3fe5 100644 (file)
@@ -133,7 +133,6 @@ class build_py(Command):
 
     def build_package_data(self):
         """Copy data files into build directory"""
-        lastdir = None
         for package, src_dir, build_dir, filenames in self.data_files:
             for filename in filenames:
                 target = os.path.join(build_dir, filename)
index 134fa3892dd57fa2d519f6b0b8d20927144afa2c..b084913563a3e234521a746be24b4fb2b4837c4a 100644 (file)
@@ -11,7 +11,8 @@ this header file lives".
 
 __revision__ = "$Id$"
 
-import sys, os, re
+import os
+import re
 
 from distutils.core import Command
 from distutils.errors import DistutilsExecError
index 3b5b2080ecf08508df0f1f7bb67eff6ee27c008f..fb547c93a8c8e38f87c41edb69b81267a5d81d5f 100644 (file)
@@ -7,12 +7,13 @@ Implements the Distutils 'register' command (register with the repository).
 
 __revision__ = "$Id$"
 
-import os, string, urllib2, getpass, urlparse
+import urllib2
+import getpass
+import urlparse
 import StringIO
 from warnings import warn
 
 from distutils.core import PyPIRCCommand
-from distutils.errors import *
 from distutils import log
 
 class register(PyPIRCCommand):
index 5c74e5329fc5df7fac0245c594ad9c8ba3e50423..f1335e6a366155348e9da83ca5944d84df58e0fd 100644 (file)
@@ -4,16 +4,17 @@ Implements the Distutils 'sdist' command (create a source distribution)."""
 
 __revision__ = "$Id$"
 
-import os, string
+import os
+import string
 import sys
-from types import *
 from glob import glob
 from warnings import warn
 
 from distutils.core import Command
 from distutils import dir_util, dep_util, file_util, archive_util
 from distutils.text_file import TextFile
-from distutils.errors import *
+from distutils.errors import (DistutilsPlatformError, DistutilsOptionError,
+                              DistutilsTemplateError)
 from distutils.filelist import FileList
 from distutils import log
 from distutils.util import convert_path
@@ -256,7 +257,7 @@ class sdist(Command):
 
         standards = [('README', 'README.txt'), self.distribution.script_name]
         for fn in standards:
-            if type(fn) is TupleType:
+            if isinstance(fn, tuple):
                 alts = fn
                 got_it = 0
                 for fn in alts:
index 5d6ebcfa4cb78215e5e361bcb3d3061208329164..3e18aeaad61bf2ec27e6248f99d3701dc1a61e1f 100644 (file)
@@ -1,7 +1,6 @@
 """distutils.command.upload
 
 Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
-import sys
 import os
 import socket
 import platform
@@ -9,10 +8,9 @@ from urllib2 import urlopen, Request, HTTPError
 from base64 import standard_b64encode
 import urlparse
 import cStringIO as StringIO
-from ConfigParser import ConfigParser
 from hashlib import md5
 
-from distutils.errors import *
+from distutils.errors import DistutilsOptionError
 from distutils.core import PyPIRCCommand
 from distutils.spawn import spawn
 from distutils import log
index 9166199ea9f9df8be24ff31f7ad0231dbbbe4493..afa403f2daae6af7b110a860b3a6e4a3e15237d6 100644 (file)
@@ -4,7 +4,6 @@ Provides the PyPIRCCommand class, the base class for the command classes
 that uses .pypirc in the distutils.command package.
 """
 import os
-import sys
 from ConfigParser import ConfigParser
 
 from distutils.cmd import Command
@@ -60,8 +59,6 @@ class PyPIRCCommand(Command):
         if os.path.exists(rc):
             self.announce('Using PyPI login from %s' % rc)
             repository = self.repository or self.DEFAULT_REPOSITORY
-            realm = self.realm or self.DEFAULT_REALM
-
             config = ConfigParser()
             config.read(rc)
             sections = config.sections()
index 8073a6bc2ab5c670f6f1b82c3fe31a6a8d99bec8..0b725ff09d9456736dbd4814f339ee19ba32624e 100644 (file)
@@ -8,10 +8,12 @@ really defined in distutils.dist and distutils.cmd.
 
 __revision__ = "$Id$"
 
-import sys, os
+import sys
+import os
 
 from distutils.debug import DEBUG
-from distutils.errors import *
+from distutils.errors import (DistutilsSetupError, DistutilsArgError,
+                              DistutilsError, CCompilerError)
 from distutils.util import grok_environment_error
 
 # Mainly import these so setup scripts can "from distutils.core import" them.
@@ -31,7 +33,7 @@ usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
    or: %(script)s cmd --help
 """
 
-def gen_usage (script_name):
+def gen_usage(script_name):
     script = os.path.basename(script_name)
     return USAGE % vars()
 
@@ -56,7 +58,7 @@ extension_keywords = ('name', 'sources', 'include_dirs',
                       'extra_objects', 'extra_compile_args', 'extra_link_args',
                       'swig_opts', 'export_symbols', 'depends', 'language')
 
-def setup (**attrs):
+def setup(**attrs):
     """The gateway to the Distutils: do everything your setup script needs
     to do, in a highly flexible and user-driven way.  Briefly: create a
     Distribution instance; find and parse config files; parse the command
@@ -168,10 +170,8 @@ def setup (**attrs):
 
     return dist
 
-# setup ()
 
-
-def run_setup (script_name, script_args=None, stop_after="run"):
+def run_setup(script_name, script_args=None, stop_after="run"):
     """Run a setup script in a somewhat controlled environment, and
     return the Distribution instance that drives things.  This is useful
     if you need to find out the distribution meta-data (passed as
@@ -235,7 +235,4 @@ def run_setup (script_name, script_args=None, stop_after="run"):
 
     # I wonder if the setup script's namespace -- g and l -- would be of
     # any interest to callers?
-    #print "_setup_distribution:", _setup_distribution
     return _setup_distribution
-
-# run_setup ()
index a8476e6579c794559da00a999b9b35c61c3611b0..eed9c321afb72a3d934f4be51251f77628027e1b 100644 (file)
@@ -53,11 +53,9 @@ import copy
 import re
 from warnings import warn
 
-from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
 from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
-from distutils import log
 from distutils.util import get_compiler_versions
 
 def get_msvcr():
index 3e2cd353857b6ddc5216a0fc16c13fc9e6540d96..9b4d2adb5c0332294709aecac19d351ffbbbb31b 100644 (file)
@@ -4,7 +4,7 @@ Utility functions for manipulating directories and directory trees."""
 
 __revision__ = "$Id$"
 
-import os, sys
+import os
 from distutils.errors import DistutilsFileError, DistutilsInternalError
 from distutils import log
 
index ee2cec90887725185be8c49ef77a1dfc5ec66425..f20a92a21d631d0b339c65da08eca02963b413d9 100644 (file)
@@ -14,7 +14,8 @@ try:
 except ImportError:
     warnings = None
 
-from distutils.errors import *
+from distutils.errors import (DistutilsOptionError, DistutilsArgError,
+                              DistutilsModuleError, DistutilsClassError)
 from distutils.fancy_getopt import FancyGetopt, translate_longopt
 from distutils.util import check_environ, strtobool, rfc822_escape
 from distutils import log
index a5a2ef88fe0690e80d0bbbcc8e46471ffbe4facd..f2f77e52d1edea0ba8165fdbfebc4f937c8a3adc 100644 (file)
@@ -24,11 +24,9 @@ __revision__ = "$Id$"
 import os, sys, copy
 from warnings import warn
 
-from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
 from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
-from distutils import log
 from distutils.util import get_compiler_versions
 
 class EMXCCompiler (UnixCCompiler):
index 6af18108012df751f8914f6d5f2b00adfb80b992..9988ec0c2c73130db0970b0047c464cde8f5da2b 100644 (file)
@@ -6,7 +6,6 @@ modules in setup scripts."""
 __revision__ = "$Id$"
 
 import os
-import sys
 import warnings
 
 # This class is really only used by the "build_ext" command, so it might
index e19319ae9d0a8a8285818f20580f721f40aec3be..2dea948025936bf842acbfb26385b8f965a571e8 100644 (file)
@@ -10,10 +10,11 @@ additional features:
 
 __revision__ = "$Id$"
 
-import sys, string, re
-from types import *
+import sys
+import string
+import re
 import getopt
-from distutils.errors import *
+from distutils.errors import DistutilsGetoptError, DistutilsArgError
 
 # Much like command_re in distutils.core, this is close to but not quite
 # the same as a Python NAME -- except, in the spirit of most GNU
@@ -117,7 +118,7 @@ class FancyGetopt:
 
 
     def _check_alias_dict (self, aliases, what):
-        assert type(aliases) is DictionaryType
+        assert isinstance(aliases, dict)
         for (alias, opt) in aliases.items():
             if alias not in self.option_index:
                 raise DistutilsGetoptError, \
@@ -164,13 +165,13 @@ class FancyGetopt:
                 raise ValueError, "invalid option tuple: %r" % (option,)
 
             # Type- and value-check the option names
-            if type(long) is not StringType or len(long) < 2:
+            if not isinstance(long, str) or len(long) < 2:
                 raise DistutilsGetoptError, \
                       ("invalid long option '%s': "
                        "must be a string of length >= 2") % long
 
             if (not ((short is None) or
-                     (type(short) is StringType and len(short) == 1))):
+                     (isinstance(short, str) and len(short) == 1))):
                 raise DistutilsGetoptError, \
                       ("invalid short option '%s': "
                        "must a single character or None") % short
@@ -464,10 +465,8 @@ def wrap_text (text, width):
 
     return lines
 
-# wrap_text ()
 
-
-def translate_longopt (opt):
+def translate_longopt(opt):
     """Convert a long option name to a valid Python identifier by
     changing "-" to "_".
     """
@@ -483,18 +482,3 @@ class OptionDummy:
         'options' will be initialized to None."""
         for opt in options:
             setattr(self, opt, None)
-
-# class OptionDummy
-
-
-if __name__ == "__main__":
-    text = """\
-Tra-la-la, supercalifragilisticexpialidocious.
-How *do* you spell that odd word, anyways?
-(Someone ask Mary -- she'll know [or she'll
-say, "How should I know?"].)"""
-
-    for w in (10, 20, 30, 40):
-        print "width: %d" % w
-        print string.join(wrap_text(text, w), "\n")
-        print
index c2287d9291618ffa122055a28b86de49b4ccf883..2309d894888776b913bf3f67c8a0fe416619a0e1 100644 (file)
@@ -19,10 +19,9 @@ import subprocess
 import sys
 import re
 
-from distutils.errors import DistutilsExecError, DistutilsPlatformError, \
-                             CompileError, LibError, LinkError
-from distutils.ccompiler import CCompiler, gen_preprocess_options, \
-                                gen_lib_options
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
+                              CompileError, LibError, LinkError)
+from distutils.ccompiler import CCompiler, gen_lib_options
 from distutils import log
 from distutils.util import get_platform
 
index d38afb72238d3bb1ad8e03f489008cc3cf276af2..0e69fd368cac78f3967f16336731c7bd6dc87151 100644 (file)
@@ -10,12 +10,13 @@ for the Microsoft Visual Studio.
 
 __revision__ = "$Id$"
 
-import sys, os, string
-from distutils.errors import \
-     DistutilsExecError, DistutilsPlatformError, \
-     CompileError, LibError, LinkError
-from distutils.ccompiler import \
-     CCompiler, gen_preprocess_options, gen_lib_options
+import sys
+import os
+import string
+
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
+                              CompileError, LibError, LinkError)
+from distutils.ccompiler import CCompiler, gen_lib_options
 from distutils import log
 
 _can_read_reg = 0
@@ -127,7 +128,7 @@ class MacroExpander:
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
             else:
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
-        except KeyError, exc: #
+        except KeyError:
             raise DistutilsPlatformError, \
                   ("""Python was built with Visual Studio 2003;
 extensions must be built with a compiler than can generate compatible binaries.
index 931f0bac196ae292e8f7a27b3ebc78300476c46e..09a798b1902d773ea98765f3dd58dba3ca64b878 100644 (file)
@@ -6,8 +6,7 @@ lines, and joining lines with backslashes."""
 
 __revision__ = "$Id$"
 
-from types import *
-import sys, os, string
+import sys
 
 
 class TextFile:
@@ -137,12 +136,12 @@ class TextFile:
         if line is None:
             line = self.current_line
         outmsg.append(self.filename + ", ")
-        if type (line) in (ListType, TupleType):
+        if isinstance(line, (list, tuple)):
             outmsg.append("lines %d-%d: " % tuple (line))
         else:
             outmsg.append("line %d: " % line)
         outmsg.append(str(msg))
-        return string.join(outmsg, "")
+        return ''.join(outmsg)
 
 
     def error (self, msg, line=None):
@@ -196,7 +195,7 @@ class TextFile:
                 # unescape it (and any other escaped "#"'s that might be
                 # lurking in there) and otherwise leave the line alone.
 
-                pos = string.find (line, "#")
+                pos = line.find("#")
                 if pos == -1:           # no "#" -- no comments
                     pass
 
@@ -219,11 +218,11 @@ class TextFile:
                     #   # comment that should be ignored
                     #   there
                     # result in "hello there".
-                    if string.strip(line) == "":
+                    if line.strip() == "":
                         continue
 
                 else:                   # it's an escaped "#"
-                    line = string.replace (line, "\\#", "#")
+                    line = line.replace("\\#", "#")
 
 
             # did previous line end with a backslash? then accumulate
@@ -235,11 +234,11 @@ class TextFile:
                     return buildup_line
 
                 if self.collapse_join:
-                    line = string.lstrip (line)
+                    line = line.lstrip()
                 line = buildup_line + line
 
                 # careful: pay attention to line number when incrementing it
-                if type (self.current_line) is ListType:
+                if isinstance(self.current_line, list):
                     self.current_line[1] = self.current_line[1] + 1
                 else:
                     self.current_line = [self.current_line,
@@ -250,7 +249,7 @@ class TextFile:
                     return None
 
                 # still have to be careful about incrementing the line number!
-                if type (self.current_line) is ListType:
+                if isinstance(self.current_line, list):
                     self.current_line = self.current_line[1] + 1
                 else:
                     self.current_line = self.current_line + 1
@@ -259,11 +258,11 @@ class TextFile:
             # strip whitespace however the client wants (leading and
             # trailing, or one or the other, or neither)
             if self.lstrip_ws and self.rstrip_ws:
-                line = string.strip (line)
+                line = line.strip()
             elif self.lstrip_ws:
-                line = string.lstrip (line)
+                line = line.lstrip()
             elif self.rstrip_ws:
-                line = string.rstrip (line)
+                line = line.rstrip()
 
             # blank line (whether we rstrip'ed or not)? skip to next line
             # if appropriate