[Python-checkins] python/dist/src/Tools/scripts texi2html.py,1.14,1.15
fdrake@users.sourceforge.net
fdrake@users.sourceforge.net
Tue, 18 Jun 2002 08:37:08 -0700
Update of /cvsroot/python/python/dist/src/Tools/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv29988
Modified Files:
texi2html.py
Log Message:
Mechanically translated string method calls to string methods.
Instead of splitting a string and looping over it to call s.split(),
use list comprehensions for readability.
Index: texi2html.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texi2html.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** texi2html.py 18 Jun 2002 15:21:21 -0000 1.14
--- texi2html.py 18 Jun 2002 15:37:05 -0000 1.15
***************
*** 126,130 ****
def link(self, label, nodename, rel=None, rev=None):
if nodename:
! if string.lower(nodename) == '(dir)':
addr = '../dir.html'
title = ''
--- 126,130 ----
def link(self, label, nodename, rel=None, rev=None):
if nodename:
! if nodename.lower() == '(dir)':
addr = '../dir.html'
title = ''
***************
*** 139,150 ****
def finalize(self):
length = len(self.lines)
! self.text = string.joinfields(self.lines, '')
self.lines = []
self.open_links()
self.output_links()
self.close_links()
! links = string.joinfields(self.lines, '')
self.lines = []
-
self.prologue = (
self.DOCTYPE +
--- 139,149 ----
def finalize(self):
length = len(self.lines)
! self.text = ''.join(self.lines)
self.lines = []
self.open_links()
self.output_links()
self.close_links()
! links = ''.join(self.lines)
self.lines = []
self.prologue = (
self.DOCTYPE +
***************
*** 338,342 ****
def write(self, *args):
try:
! text = string.joinfields(args, '')
except:
print args
--- 337,341 ----
def write(self, *args):
try:
! text = ''.join(args)
except:
print args
***************
*** 393,397 ****
mo = miprog.match(line)
if not mo:
! line = string.strip(line) + '\n'
self.expand(line)
continue
--- 392,396 ----
mo = miprog.match(line)
if not mo:
! line = line.strip() + '\n'
self.expand(line)
continue
***************
*** 413,417 ****
self.expand(line[end:])
else:
! text = string.joinfields(accu, '')
self.expand(text)
--- 412,416 ----
self.expand(line[end:])
else:
! text = ''.join(accu)
self.expand(text)
***************
*** 700,707 ****
def close_inforef(self):
text = self.collectsavings()
! args = string.splitfields(text, ',')
! n = len(args)
! for i in range(n):
! args[i] = string.strip(args[i])
while len(args) < 3: args.append('')
node = args[0]
--- 699,703 ----
def close_inforef(self):
text = self.collectsavings()
! args = [s.strip() for s in text.split(',')]
while len(args) < 3: args.append('')
node = args[0]
***************
*** 711,718 ****
def makeref(self):
text = self.collectsavings()
! args = string.splitfields(text, ',')
! n = len(args)
! for i in range(n):
! args[i] = string.strip(args[i])
while len(args) < 5: args.append('')
nodename = label = args[0]
--- 707,711 ----
def makeref(self):
text = self.collectsavings()
! args = [s.strip() for s in text.split(',')]
while len(args) < 5: args.append('')
nodename = label = args[0]
***************
*** 730,737 ****
def close_uref(self):
text = self.collectsavings()
! args = string.splitfields(text, ',')
! n = len(args)
! for i in range(n):
! args[i] = string.strip(args[i])
while len(args) < 2: args.append('')
href = args[0]
--- 723,727 ----
def close_uref(self):
text = self.collectsavings()
! args = [s.strip() for s in text.split(',')]
while len(args) < 2: args.append('')
href = args[0]
***************
*** 753,760 ****
def makeimage(self):
text = self.collectsavings()
! args = string.splitfields(text, ',')
! n = len(args)
! for i in range(n):
! args[i] = string.strip(args[i])
while len(args) < 5: args.append('')
filename = args[0]
--- 743,747 ----
def makeimage(self):
text = self.collectsavings()
! args = [s.strip() for s in text.split(',')]
while len(args) < 5: args.append('')
filename = args[0]
***************
*** 883,887 ****
a, b = mo.span(1)
cmd = line[a:b]
! args = string.strip(line[b:])
if self.debugging > 1:
print '!'*self.debugging, 'command:', self.skip, self.stack, \
--- 870,874 ----
a, b = mo.span(1)
cmd = line[a:b]
! args = line[b:].strip()
if self.debugging > 1:
print '!'*self.debugging, 'command:', self.skip, self.stack, \
***************
*** 911,915 ****
def do_end(self, args):
! words = string.split(args)
if not words:
print '*** @end w/o args'
--- 898,902 ----
def do_end(self, args):
! words = args.split()
if not words:
print '*** @end w/o args'
***************
*** 955,964 ****
def do_set(self, args):
! fields = string.splitfields(args, ' ')
key = fields[0]
if len(fields) == 1:
value = 1
else:
! value = string.joinfields(fields[1:], ' ')
self.values[key] = value
--- 942,951 ----
def do_set(self, args):
! fields = args.split(' ')
key = fields[0]
if len(fields) == 1:
value = 1
else:
! value = ' '.join(fields[1:])
self.values[key] = value
***************
*** 1060,1066 ****
self.endnode()
self.nodelineno = 0
! parts = string.splitfields(args, ',')
while len(parts) < 4: parts.append('')
- for i in range(4): parts[i] = string.strip(parts[i])
self.nodelinks = parts
[name, next, prev, up] = parts[:4]
--- 1047,1052 ----
self.endnode()
self.nodelineno = 0
! parts = [s.strip() for s in args.split(',')]
while len(parts) < 4: parts.append('')
self.nodelinks = parts
[name, next, prev, up] = parts[:4]
***************
*** 1084,1088 ****
def link(self, label, nodename):
if nodename:
! if string.lower(nodename) == '(dir)':
addr = '../dir.html'
else:
--- 1070,1074 ----
def link(self, label, nodename):
if nodename:
! if nodename.lower() == '(dir)':
addr = '../dir.html'
else:
***************
*** 1578,1582 ****
def do_synindex(self, args):
! words = string.split(args)
if len(words) <> 2:
print '*** bad @synindex', args
--- 1564,1568 ----
def do_synindex(self, args):
! words = args.split()
if len(words) <> 2:
print '*** bad @synindex', args
***************
*** 1595,1599 ****
def do_printindex(self, args):
! words = string.split(args)
for name in words:
if self.whichindex.has_key(name):
--- 1581,1585 ----
def do_printindex(self, args):
! words = args.split()
for name in words:
if self.whichindex.has_key(name):
***************
*** 1613,1617 ****
junkprog = re.compile('^(@[a-z]+)?{')
for key, node in index:
! sortkey = string.lower(key)
# Remove leading `@cmd{' from sort key
# -- don't bother about the matching `}'
--- 1599,1603 ----
junkprog = re.compile('^(@[a-z]+)?{')
for key, node in index:
! sortkey = key.lower()
# Remove leading `@cmd{' from sort key
# -- don't bother about the matching `}'
***************
*** 1648,1652 ****
cmds.sort()
for cmd in cmds:
! print string.ljust(cmd, 20), self.unknown[cmd]
--- 1634,1638 ----
cmds.sort()
for cmd in cmds:
! print cmd.ljust(20), self.unknown[cmd]
***************
*** 1989,1993 ****
# Convert a node name into a file name
def makefile(nodename):
! nodename = string.strip(nodename)
return fixfunnychars(nodename) + '.html'
--- 1975,1979 ----
# Convert a node name into a file name
def makefile(nodename):
! nodename = nodename.strip()
return fixfunnychars(nodename) + '.html'
***************
*** 2018,2022 ****
lastc = s[-1]
if lastc in sequence:
! i = string.index(sequence, lastc) + 1
if i >= len(sequence):
if len(s) == 1:
--- 2004,2008 ----
lastc = s[-1]
if lastc in sequence:
! i = sequence.index(lastc) + 1
if i >= len(sequence):
if len(s) == 1: