summaryrefslogtreecommitdiffstats
path: root/Tools/bgen
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-09-11 20:36:02 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-09-11 20:36:02 (GMT)
commitaaab30e00cc3e8d90c71b8657c284feeb4ac1413 (patch)
treed055e0bd374770014d9afdff1b961418b1828584 /Tools/bgen
parent6a0477b099560a452e37fe77c3850bf232487c16 (diff)
downloadcpython-aaab30e00cc3e8d90c71b8657c284feeb4ac1413.zip
cpython-aaab30e00cc3e8d90c71b8657c284feeb4ac1413.tar.gz
cpython-aaab30e00cc3e8d90c71b8657c284feeb4ac1413.tar.bz2
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.
Diffstat (limited to 'Tools/bgen')
-rw-r--r--Tools/bgen/bgen/bgenGenerator.py5
-rw-r--r--Tools/bgen/bgen/bgenOutput.py12
-rw-r--r--Tools/bgen/bgen/scantools.py25
3 files changed, 19 insertions, 23 deletions
diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py
index aa39668..1c19388 100644
--- a/Tools/bgen/bgen/bgenGenerator.py
+++ b/Tools/bgen/bgen/bgenGenerator.py
@@ -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):
diff --git a/Tools/bgen/bgen/bgenOutput.py b/Tools/bgen/bgen/bgenOutput.py
index a269585..c7e560c 100644
--- a/Tools/bgen/bgen/bgenOutput.py
+++ b/Tools/bgen/bgen/bgenOutput.py
@@ -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
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index 205a1ce..61c2f37 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -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`)