[Python-checkins] python/dist/src/Tools/bgen/bgen bgenGenerator.py,1.13,1.14 bgenOutput.py,1.3,1.4 scantools.py,1.31,1.32

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Wed, 11 Sep 2002 13:36:02 -0700


Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen
In directory usw-pr-cvs1:/tmp/cvs-serv827/bgen/bgen

Modified Files:
	bgenGenerator.py bgenOutput.py scantools.py 
Log Message:
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.


Index: bgenGenerator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenGenerator.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** bgenGenerator.py	16 Aug 2002 09:07:42 -0000	1.13
--- bgenGenerator.py	11 Sep 2002 20:36:00 -0000	1.14
***************
*** 132,136 ****
  	
  	def docstring(self):
- 		import string
  		input = []
  		output = []
--- 132,135 ----
***************
*** 157,165 ****
  			instr = "()"
  		else:
! 			instr = "(%s)" % string.joinfields(input, ", ")
  		if not output or output == ["void"]:
  			outstr = "None"
  		else:
! 			outstr = "(%s)" % string.joinfields(output, ", ")
  		return instr + " -> " + outstr
  	
--- 156,164 ----
  			instr = "()"
  		else:
! 			instr = "(%s)" % ", ".join(input)
  		if not output or output == ["void"]:
  			outstr = "None"
  		else:
! 			outstr = "(%s)" % ", ".join(output)
  		return instr + " -> " + outstr
  	

Index: bgenOutput.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenOutput.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** bgenOutput.py	27 Aug 2001 14:30:55 -0000	1.3
--- bgenOutput.py	11 Sep 2002 20:36:00 -0000	1.4
***************
*** 70,79 ****
  	if _Level > 0:
  		indent = '\t' * _Level
! 		import string
! 		lines = string.splitfields(text, '\n')
  		for i in range(len(lines)):
  			if lines[i] and lines[i][0] != '#':
  				lines[i] = indent + lines[i]
! 		text = string.joinfields(lines, '\n')
  	_File.write(text + '\n')
  
--- 70,78 ----
  	if _Level > 0:
  		indent = '\t' * _Level
! 		lines = text.split('\n')
  		for i in range(len(lines)):
  			if lines[i] and lines[i][0] != '#':
  				lines[i] = indent + lines[i]
! 		text = '\n'.join(lines)
  	_File.write(text + '\n')
  
***************
*** 169,179 ****
  	# (Don't you love using triple quotes *inside* triple quotes? :-)
  	
! 	import string
! 	lines = string.splitfields(text, '\n')
  	indent = ""
  	for line in lines:
! 		if string.strip(line):
  			for c in line:
! 				if c not in string.whitespace:
  					break
  				indent = indent + c
--- 168,177 ----
  	# (Don't you love using triple quotes *inside* triple quotes? :-)
  	
! 	lines = text.split('\n')
  	indent = ""
  	for line in lines:
! 		if line.strip():
  			for c in line:
! 				if not c.isspace():
  					break
  				indent = indent + c

Index: scantools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** scantools.py	5 Aug 2002 21:15:22 -0000	1.31
--- scantools.py	11 Sep 2002 20:36:00 -0000	1.32
***************
*** 16,20 ****
  
  import re
- import string
  import sys
  import os
--- 16,19 ----
***************
*** 68,73 ****
  			modes = self.usedtypes[type].keys()
  			modes.sort()
! 			self.report("%s %s", type, string.join(modes))
! 			
  	def gentypetest(self, file):
  		fp = open(file, "w")
--- 67,72 ----
  			modes = self.usedtypes[type].keys()
  			modes.sort()
! 			self.report("%s %s", type, " ".join(modes))
! 
  	def gentypetest(self, file):
  		fp = open(file, "w")
***************
*** 164,170 ****
  				line = line[:-2] + ' ' + f.readline()
  				lineno = lineno + 1
! 			i = string.find(line, '#')
  			if i >= 0: line = line[:i]
! 			words = map(string.strip, string.splitfields(line, ':'))
  			if words == ['']: continue
  			if len(words) <> 3:
--- 163,169 ----
  				line = line[:-2] + ' ' + f.readline()
  				lineno = lineno + 1
! 			i = line.find('#')
  			if i >= 0: line = line[:i]
! 			words = [s.strip() for s in line.split(':')]
  			if words == ['']: continue
  			if len(words) <> 3:
***************
*** 180,185 ****
  				print `line`
  				continue
! 			patparts = map(string.strip, string.splitfields(pat, ','))
! 			repparts = map(string.strip, string.splitfields(rep, ','))
  			patterns = []
  			for p in patparts:
--- 179,184 ----
  				print `line`
  				continue
! 			patparts = [s.strip() for s in pat.split(',')]
! 			repparts = [s.strip() for s in rep.split(',')]
  			patterns = []
  			for p in patparts:
***************
*** 189,193 ****
  					print `line`
  					continue
! 				pattern = string.split(p)
  				if len(pattern) > 3:
  					print "Line", startlineno,
--- 188,192 ----
  					print `line`
  					continue
! 				pattern = p.split()
  				if len(pattern) > 3:
  					print "Line", startlineno,
***************
*** 206,210 ****
  					print `line`
  					continue
! 				replacement = string.split(p)
  				if len(replacement) > 3:
  					print "Line", startlineno,
--- 205,209 ----
  					print `line`
  					continue
! 				replacement = p.split()
  				if len(replacement) > 3:
  					print "Line", startlineno,
***************
*** 503,510 ****
  
  	def extractarglist(self, args):
! 		args = string.strip(args)
  		if not args or args == "void":
  			return []
! 		parts = map(string.strip, string.splitfields(args, ","))
  		arglist = []
  		for part in parts:
--- 502,509 ----
  
  	def extractarglist(self, args):
! 		args = args.strip()
  		if not args or args == "void":
  			return []
! 		parts = [s.strip() for s in args.split(",")]
  		arglist = []
  		for part in parts:
***************
*** 525,529 ****
  			type = type + " ptr "
  		type = re.sub("\*", " ptr ", type)
! 		type = string.strip(type)
  		type = re.sub("[ \t]+", "_", type)
  		return self.modifyarg(type, name, mode)
--- 524,528 ----
  			type = type + " ptr "
  		type = re.sub("\*", " ptr ", type)
! 		type = type.strip()
  		type = re.sub("[ \t]+", "_", type)
  		return self.modifyarg(type, name, mode)
***************
*** 582,586 ****
  					newitem[i] = old[k][i]
  				elif item[i][:1] == '$':
! 					index = string.atoi(item[i][1:]) - 1
  					newitem[i] = old[index][i]
  			new.append(tuple(newitem))
--- 581,585 ----
  					newitem[i] = old[k][i]
  				elif item[i][:1] == '$':
! 					index = int(item[i][1:]) - 1
  					newitem[i] = old[index][i]
  			new.append(tuple(newitem))