massive import cleaning in Distutils
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 931f0ba..09a798b 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -6,8 +6,7 @@
__revision__ = "$Id$"
-from types import *
-import sys, os, string
+import sys
class TextFile:
@@ -137,12 +136,12 @@
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 @@
# 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 @@
# # 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 @@
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 @@
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 @@
# 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