mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
massive import cleaning in Distutils
This commit is contained in:
parent
2421d56e02
commit
2b66da7d15
24 changed files with 97 additions and 121 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue