Apply diff2.txt from SF patch http://www.python.org/sf/572113

(with one small bugfix in bgen/bgen/scantools.py)

This replaces string module functions with string methods
for the stuff in the Tools directory. Several uses of
string.letters etc. are still remaining.
This commit is contained in:
Walter Dörwald 2002-09-11 20:36:02 +00:00
parent 6a0477b099
commit aaab30e00c
70 changed files with 271 additions and 346 deletions

View file

@ -131,7 +131,6 @@ class FunctionGenerator(BaseFunctionGenerator):
self.argumentList.append(arg)
def docstring(self):
import string
input = []
output = []
for arg in self.argumentList:
@ -156,11 +155,11 @@ class FunctionGenerator(BaseFunctionGenerator):
if not input:
instr = "()"
else:
instr = "(%s)" % string.joinfields(input, ", ")
instr = "(%s)" % ", ".join(input)
if not output or output == ["void"]:
outstr = "None"
else:
outstr = "(%s)" % string.joinfields(output, ", ")
outstr = "(%s)" % ", ".join(output)
return instr + " -> " + outstr
def functionbody(self):

View file

@ -69,12 +69,11 @@ def VaOutput(format, args):
text = format % args
if _Level > 0:
indent = '\t' * _Level
import string
lines = string.splitfields(text, '\n')
lines = text.split('\n')
for i in range(len(lines)):
if lines[i] and lines[i][0] != '#':
lines[i] = indent + lines[i]
text = string.joinfields(lines, '\n')
text = '\n'.join(lines)
_File.write(text + '\n')
def IndentLevel(by = 1):
@ -168,13 +167,12 @@ def Out(text):
"""
# (Don't you love using triple quotes *inside* triple quotes? :-)
import string
lines = string.splitfields(text, '\n')
lines = text.split('\n')
indent = ""
for line in lines:
if string.strip(line):
if line.strip():
for c in line:
if c not in string.whitespace:
if not c.isspace():
break
indent = indent + c
break

View file

@ -15,7 +15,6 @@ although most Mac specific details are contained in header-specific subclasses.
"""
import re
import string
import sys
import os
import fnmatch
@ -67,8 +66,8 @@ class Scanner:
for type in types:
modes = self.usedtypes[type].keys()
modes.sort()
self.report("%s %s", type, string.join(modes))
self.report("%s %s", type, " ".join(modes))
def gentypetest(self, file):
fp = open(file, "w")
fp.write("types=[\n")
@ -163,9 +162,9 @@ if missing: raise "Missing Types"
while line[-2:] == '\\\n':
line = line[:-2] + ' ' + f.readline()
lineno = lineno + 1
i = string.find(line, '#')
i = line.find('#')
if i >= 0: line = line[:i]
words = map(string.strip, string.splitfields(line, ':'))
words = [s.strip() for s in line.split(':')]
if words == ['']: continue
if len(words) <> 3:
print "Line", startlineno,
@ -179,8 +178,8 @@ if missing: raise "Missing Types"
print "Empty pattern"
print `line`
continue
patparts = map(string.strip, string.splitfields(pat, ','))
repparts = map(string.strip, string.splitfields(rep, ','))
patparts = [s.strip() for s in pat.split(',')]
repparts = [s.strip() for s in rep.split(',')]
patterns = []
for p in patparts:
if not p:
@ -188,7 +187,7 @@ if missing: raise "Missing Types"
print "Empty pattern part"
print `line`
continue
pattern = string.split(p)
pattern = p.split()
if len(pattern) > 3:
print "Line", startlineno,
print "Pattern part has > 3 words"
@ -205,7 +204,7 @@ if missing: raise "Missing Types"
print "Empty replacement part"
print `line`
continue
replacement = string.split(p)
replacement = p.split()
if len(replacement) > 3:
print "Line", startlineno,
print "Pattern part has > 3 words"
@ -502,10 +501,10 @@ if missing: raise "Missing Types"
self.generate(type, name, arglist)
def extractarglist(self, args):
args = string.strip(args)
args = args.strip()
if not args or args == "void":
return []
parts = map(string.strip, string.splitfields(args, ","))
parts = [s.strip() for s in args.split(",")]
arglist = []
for part in parts:
arg = self.extractarg(part)
@ -524,7 +523,7 @@ if missing: raise "Missing Types"
# array matches an optional [] after the argument name
type = type + " ptr "
type = re.sub("\*", " ptr ", type)
type = string.strip(type)
type = type.strip()
type = re.sub("[ \t]+", "_", type)
return self.modifyarg(type, name, mode)
@ -581,7 +580,7 @@ if missing: raise "Missing Types"
if item[i] == '*':
newitem[i] = old[k][i]
elif item[i][:1] == '$':
index = string.atoi(item[i][1:]) - 1
index = int(item[i][1:]) - 1
newitem[i] = old[index][i]
new.append(tuple(newitem))
##self.report("old: %s", `old`)