summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/texi2html.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-08-03 17:06:41 (GMT)
committerCollin Winter <collinw@gmail.com>2007-08-03 17:06:41 (GMT)
commit6afaeb757af0dbd8508a0f2352ade61e41bec84c (patch)
treef1b31bc7138b17ff39791bbb45aa81583c3b6e46 /Tools/scripts/texi2html.py
parente5d0e8431f929cad2da77b63fe1b7dc0ff21a428 (diff)
downloadcpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.zip
cpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.tar.gz
cpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.tar.bz2
Convert print statements to function calls in Tools/.
Diffstat (limited to 'Tools/scripts/texi2html.py')
-rwxr-xr-xTools/scripts/texi2html.py224
1 files changed, 112 insertions, 112 deletions
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index d849d7c..e5e292d 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -275,7 +275,7 @@ class TexinfoParser:
if not self.skip: self.process(accu)
accu = []
if initial_lineno > 0:
- print '*** EOF before @bye'
+ print('*** EOF before @bye')
break
lineno = lineno + 1
mo = cmprog.match(line)
@@ -306,10 +306,10 @@ class TexinfoParser:
accu.append(line)
#
if self.skip:
- print '*** Still skipping at the end'
+ print('*** Still skipping at the end')
if self.stack:
- print '*** Stack not empty at the end'
- print '***', self.stack
+ print('*** Stack not empty at the end')
+ print('***', self.stack)
if self.includedepth == 0:
while self.nodestack:
self.nodestack[-1].finalize()
@@ -338,7 +338,7 @@ class TexinfoParser:
try:
text = ''.join(args)
except:
- print args
+ print(args)
raise TypeError
if self.savetext <> None:
self.savetext = self.savetext + text
@@ -350,7 +350,7 @@ class TexinfoParser:
# Complete the current node -- write footnotes and close file
def endnode(self):
if self.savetext <> None:
- print '*** Still saving text at end of node'
+ print('*** Still saving text at end of node')
dummy = self.collectsavings()
if self.footnotes:
self.writefootnotes()
@@ -382,10 +382,10 @@ class TexinfoParser:
# This mostly distinguishes between menus and normal text
def process(self, accu):
if self.debugging > 1:
- print '!'*self.debugging, 'process:', self.skip, self.stack,
- if accu: print accu[0][:30],
- if accu[0][30:] or accu[1:]: print '...',
- print
+ print('!'*self.debugging, 'process:', self.skip, self.stack, end=' ')
+ if accu: print(accu[0][:30], end=' ')
+ if accu[0][30:] or accu[1:]: print('...', end=' ')
+ print()
if self.inmenu():
# XXX should be done differently
for line in accu:
@@ -461,7 +461,7 @@ class TexinfoParser:
continue
if c == '}':
if not stack:
- print '*** Unmatched }'
+ print('*** Unmatched }')
self.write('}')
continue
cmd = stack[-1]
@@ -509,12 +509,12 @@ class TexinfoParser:
continue
method()
if stack:
- print '*** Stack not empty at para:', stack
+ print('*** Stack not empty at para:', stack)
# --- Handle unknown embedded @-commands ---
def unknown_open(self, cmd):
- print '*** No open func for @' + cmd + '{...}'
+ print('*** No open func for @' + cmd + '{...}')
cmd = cmd + '{'
self.write('@', cmd)
if not self.unknown.has_key(cmd):
@@ -523,7 +523,7 @@ class TexinfoParser:
self.unknown[cmd] = self.unknown[cmd] + 1
def unknown_close(self, cmd):
- print '*** No close func for @' + cmd + '{...}'
+ print('*** No close func for @' + cmd + '{...}')
cmd = '}' + cmd
self.write('}')
if not self.unknown.has_key(cmd):
@@ -532,7 +532,7 @@ class TexinfoParser:
self.unknown[cmd] = self.unknown[cmd] + 1
def unknown_handle(self, cmd):
- print '*** No handler for @' + cmd
+ print('*** No handler for @' + cmd)
self.write('@', cmd)
if not self.unknown.has_key(cmd):
self.unknown[cmd] = 1
@@ -555,9 +555,9 @@ class TexinfoParser:
try:
fp = open(file, 'r')
except IOError as msg:
- print '*** Can\'t open include file', repr(file)
+ print('*** Can\'t open include file', repr(file))
return
- print '!'*self.debugging, '--> file', repr(file)
+ print('!'*self.debugging, '--> file', repr(file))
save_done = self.done
save_skip = self.skip
save_stack = self.stack
@@ -568,7 +568,7 @@ class TexinfoParser:
self.done = save_done
self.skip = save_skip
self.stack = save_stack
- print '!'*self.debugging, '<-- file', repr(file)
+ print('!'*self.debugging, '<-- file', repr(file))
# --- Special Insertions ---
@@ -764,7 +764,7 @@ class TexinfoParser:
elif os.path.exists(imagelocation+'.gif'): # MySQL uses GIF files
filename += '.gif'
else:
- print "*** Cannot find image " + imagelocation
+ print("*** Cannot find image " + imagelocation)
#TODO: what is 'ext'?
self.write('<IMG SRC="', filename, '"', \
width and (' WIDTH="' + width + '"') or "", \
@@ -871,8 +871,8 @@ class TexinfoParser:
cmd = line[a:b]
args = line[b:].strip()
if self.debugging > 1:
- print '!'*self.debugging, 'command:', self.skip, self.stack, \
- '@' + cmd, args
+ print('!'*self.debugging, 'command:', self.skip, self.stack, \
+ '@' + cmd, args)
try:
func = getattr(self, 'do_' + cmd)
except AttributeError:
@@ -890,7 +890,7 @@ class TexinfoParser:
func(args)
def unknown_cmd(self, cmd, args):
- print '*** unknown', '@' + cmd, args
+ print('*** unknown', '@' + cmd, args)
if not self.unknown.has_key(cmd):
self.unknown[cmd] = 1
else:
@@ -899,11 +899,11 @@ class TexinfoParser:
def do_end(self, args):
words = args.split()
if not words:
- print '*** @end w/o args'
+ print('*** @end w/o args')
else:
cmd = words[0]
if not self.stack or self.stack[-1] <> cmd:
- print '*** @end', cmd, 'unexpected'
+ print('*** @end', cmd, 'unexpected')
else:
del self.stack[-1]
try:
@@ -915,7 +915,7 @@ class TexinfoParser:
def unknown_end(self, cmd):
cmd = 'end ' + cmd
- print '*** unknown', '@' + cmd
+ print('*** unknown', '@' + cmd)
if not self.unknown.has_key(cmd):
self.unknown[cmd] = 1
else:
@@ -965,7 +965,7 @@ class TexinfoParser:
self.skip = self.skip - 1
del self.stackinfo[len(self.stack) + 1]
except KeyError:
- print '*** end_ifset: KeyError :', len(self.stack) + 1
+ print('*** end_ifset: KeyError :', len(self.stack) + 1)
def bgn_ifclear(self, args):
if args in self.values.keys() \
@@ -980,7 +980,7 @@ class TexinfoParser:
self.skip = self.skip - 1
del self.stackinfo[len(self.stack) + 1]
except KeyError:
- print '*** end_ifclear: KeyError :', len(self.stack) + 1
+ print('*** end_ifclear: KeyError :', len(self.stack) + 1)
def open_value(self):
self.startsaving()
@@ -990,7 +990,7 @@ class TexinfoParser:
if key in self.values.keys():
self.write(self.values[key])
else:
- print '*** Undefined value: ', key
+ print('*** Undefined value: ', key)
# --- Beginning a file ---
@@ -1052,9 +1052,9 @@ class TexinfoParser:
[name, next, prev, up] = parts[:4]
file = self.dirname + '/' + makefile(name)
if self.filenames.has_key(file):
- print '*** Filename already in use: ', file
+ print('*** Filename already in use: ', file)
else:
- if self.debugging: print '!'*self.debugging, '--- writing', file
+ if self.debugging: print('!'*self.debugging, '--- writing', file)
self.filenames[file] = 1
# self.nodefp = open(file, 'w')
self.nodename = name
@@ -1169,7 +1169,7 @@ class TexinfoParser:
self.expand(args)
self.write('</', type, '>\n')
if self.debugging or self.print_headers:
- print '---', args
+ print('---', args)
def do_contents(self, args):
# pass
@@ -1549,7 +1549,7 @@ class TexinfoParser:
if self.whichindex.has_key(name):
self.index(name, args)
else:
- print '*** No index named', repr(name)
+ print('*** No index named', repr(name))
def do_cindex(self, args): self.index('cp', args)
def do_findex(self, args): self.index('fn', args)
@@ -1565,12 +1565,12 @@ class TexinfoParser:
def do_synindex(self, args):
words = args.split()
if len(words) <> 2:
- print '*** bad @synindex', args
+ print('*** bad @synindex', args)
return
[old, new] = words
if not self.whichindex.has_key(old) or \
not self.whichindex.has_key(new):
- print '*** bad key(s) in @synindex', args
+ print('*** bad key(s) in @synindex', args)
return
if old <> new and \
self.whichindex[old] is not self.whichindex[new]:
@@ -1585,15 +1585,15 @@ class TexinfoParser:
if self.whichindex.has_key(name):
self.prindex(name)
else:
- print '*** No index named', repr(name)
+ print('*** No index named', repr(name))
def prindex(self, name):
iscodeindex = (name not in self.noncodeindices)
index = self.whichindex[name]
if not index: return
if self.debugging:
- print '!'*self.debugging, '--- Generating', \
- self.indextitle[name], 'index'
+ print('!'*self.debugging, '--- Generating', \
+ self.indextitle[name], 'index')
# The node already provides a title
index1 = []
junkprog = re.compile('^(@[a-z]+)?{')
@@ -1616,7 +1616,7 @@ class TexinfoParser:
for sortkey, key, node in index1:
if (key, node) == (prevkey, prevnode):
continue
- if self.debugging > 1: print '!'*self.debugging, key, ':', node
+ if self.debugging > 1: print('!'*self.debugging, key, ':', node)
self.write('<DT>')
if iscodeindex: key = '@code{' + key + '}'
if key != prevkey:
@@ -1629,11 +1629,11 @@ class TexinfoParser:
def report(self):
if self.unknown:
- print '--- Unrecognized commands ---'
+ print('--- Unrecognized commands ---')
cmds = self.unknown.keys()
cmds.sort()
for cmd in cmds:
- print cmd.ljust(20), self.unknown[cmd]
+ print(cmd.ljust(20), self.unknown[cmd])
class TexinfoParserHTML3(TexinfoParser):
@@ -1773,86 +1773,86 @@ class HTMLHelp:
# PROJECT FILE
try:
fp = open(projectfile,'w')
- print>>fp, '[OPTIONS]'
- print>>fp, 'Auto Index=Yes'
- print>>fp, 'Binary TOC=No'
- print>>fp, 'Binary Index=Yes'
- print>>fp, 'Compatibility=1.1'
- print>>fp, 'Compiled file=' + resultfile + ''
- print>>fp, 'Contents file=' + contentfile + ''
- print>>fp, 'Default topic=' + defaulttopic + ''
- print>>fp, 'Error log file=ErrorLog.log'
- print>>fp, 'Index file=' + indexfile + ''
- print>>fp, 'Title=' + title + ''
- print>>fp, 'Display compile progress=Yes'
- print>>fp, 'Full-text search=Yes'
- print>>fp, 'Default window=main'
- print>>fp, ''
- print>>fp, '[WINDOWS]'
- print>>fp, ('main=,"' + contentfile + '","' + indexfile
+ print('[OPTIONS]', file=fp)
+ print('Auto Index=Yes', file=fp)
+ print('Binary TOC=No', file=fp)
+ print('Binary Index=Yes', file=fp)
+ print('Compatibility=1.1', file=fp)
+ print('Compiled file=' + resultfile + '', file=fp)
+ print('Contents file=' + contentfile + '', file=fp)
+ print('Default topic=' + defaulttopic + '', file=fp)
+ print('Error log file=ErrorLog.log', file=fp)
+ print('Index file=' + indexfile + '', file=fp)
+ print('Title=' + title + '', file=fp)
+ print('Display compile progress=Yes', file=fp)
+ print('Full-text search=Yes', file=fp)
+ print('Default window=main', file=fp)
+ print('', file=fp)
+ print('[WINDOWS]', file=fp)
+ print('main=,"' + contentfile + '","' + indexfile
+ '","","",,,,,0x23520,222,0x1046,[10,10,780,560],'
- '0xB0000,,,,,,0')
- print>>fp, ''
- print>>fp, '[FILES]'
- print>>fp, ''
+ '0xB0000,,,,,,0', file=fp)
+ print('', file=fp)
+ print('[FILES]', file=fp)
+ print('', file=fp)
self.dumpfiles(fp)
fp.close()
except IOError as msg:
- print projectfile, ':', msg
+ print(projectfile, ':', msg)
sys.exit(1)
# CONTENT FILE
try:
fp = open(contentfile,'w')
- print>>fp, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'
- print>>fp, '<!-- This file defines the table of contents -->'
- print>>fp, '<HTML>'
- print>>fp, '<HEAD>'
- print>>fp, ('<meta name="GENERATOR"'
- 'content="Microsoft&reg; HTML Help Workshop 4.1">')
- print>>fp, '<!-- Sitemap 1.0 -->'
- print>>fp, '</HEAD>'
- print>>fp, '<BODY>'
- print>>fp, ' <OBJECT type="text/site properties">'
- print>>fp, ' <param name="Window Styles" value="0x800025">'
- print>>fp, ' <param name="comment" value="title:">'
- print>>fp, ' <param name="comment" value="base:">'
- print>>fp, ' </OBJECT>'
+ print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
+ print('<!-- This file defines the table of contents -->', file=fp)
+ print('<HTML>', file=fp)
+ print('<HEAD>', file=fp)
+ print('<meta name="GENERATOR"'
+ 'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
+ print('<!-- Sitemap 1.0 -->', file=fp)
+ print('</HEAD>', file=fp)
+ print('<BODY>', file=fp)
+ print(' <OBJECT type="text/site properties">', file=fp)
+ print(' <param name="Window Styles" value="0x800025">', file=fp)
+ print(' <param name="comment" value="title:">', file=fp)
+ print(' <param name="comment" value="base:">', file=fp)
+ print(' </OBJECT>', file=fp)
self.dumpnodes(fp)
- print>>fp, '</BODY>'
- print>>fp, '</HTML>'
+ print('</BODY>', file=fp)
+ print('</HTML>', file=fp)
fp.close()
except IOError as msg:
- print contentfile, ':', msg
+ print(contentfile, ':', msg)
sys.exit(1)
# INDEX FILE
try:
fp = open(indexfile ,'w')
- print>>fp, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'
- print>>fp, '<!-- This file defines the index -->'
- print>>fp, '<HTML>'
- print>>fp, '<HEAD>'
- print>>fp, ('<meta name="GENERATOR"'
- 'content="Microsoft&reg; HTML Help Workshop 4.1">')
- print>>fp, '<!-- Sitemap 1.0 -->'
- print>>fp, '</HEAD>'
- print>>fp, '<BODY>'
- print>>fp, '<OBJECT type="text/site properties">'
- print>>fp, '</OBJECT>'
+ print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
+ print('<!-- This file defines the index -->', file=fp)
+ print('<HTML>', file=fp)
+ print('<HEAD>', file=fp)
+ print('<meta name="GENERATOR"'
+ 'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
+ print('<!-- Sitemap 1.0 -->', file=fp)
+ print('</HEAD>', file=fp)
+ print('<BODY>', file=fp)
+ print('<OBJECT type="text/site properties">', file=fp)
+ print('</OBJECT>', file=fp)
self.dumpindex(fp)
- print>>fp, '</BODY>'
- print>>fp, '</HTML>'
+ print('</BODY>', file=fp)
+ print('</HTML>', file=fp)
fp.close()
except IOError as msg:
- print indexfile , ':', msg
+ print(indexfile , ':', msg)
sys.exit(1)
def dumpfiles(self, outfile=sys.stdout):
filelist = self.filenames.values()
filelist.sort()
for filename in filelist:
- print>>outfile, filename
+ print(filename, file=outfile)
def dumpnodes(self, outfile=sys.stdout):
self.dumped = {}
@@ -1860,10 +1860,10 @@ class HTMLHelp:
nodename, dummy, dummy, dummy, dummy = self.nodelist[0]
self.topnode = nodename
- print>>outfile, '<UL>'
+ print('<UL>', file=outfile)
for node in self.nodelist:
self.dumpnode(node,0,outfile)
- print>>outfile, '</UL>'
+ print('</UL>', file=outfile)
def dumpnode(self, node, indent=0, outfile=sys.stdout):
if node:
@@ -1877,11 +1877,11 @@ class HTMLHelp:
self.dumped[nodename] = 1
# Print info for this node
- print>>outfile, ' '*indent,
- print>>outfile, '<LI><OBJECT type="text/sitemap">',
- print>>outfile, '<param name="Name" value="' + nodename +'">',
- print>>outfile, '<param name="Local" value="'+ filename +'">',
- print>>outfile, '</OBJECT>'
+ print(' '*indent, end=' ', file=outfile)
+ print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
+ print('<param name="Name" value="' + nodename +'">', end=' ', file=outfile)
+ print('<param name="Local" value="'+ filename +'">', end=' ', file=outfile)
+ print('</OBJECT>', file=outfile)
# Does this node have menu items?
try:
@@ -1894,13 +1894,13 @@ class HTMLHelp:
if menu:
currentnode = self.current
if currentnode != self.topnode: # XXX this is a hack
- print>>outfile, ' '*indent + '<UL>'
+ print(' '*indent + '<UL>', file=outfile)
indent += 2
for item in menu:
menunode = self.getnode(item)
self.dumpnode(menunode,indent,outfile)
if currentnode != self.topnode: # XXX this is a hack
- print>>outfile, ' '*indent + '</UL>'
+ print(' '*indent + '</UL>', file=outfile)
indent -= 2
def getnode(self, nodename):
@@ -1914,16 +1914,16 @@ class HTMLHelp:
# (args,nodename) == (key,location)
def dumpindex(self, outfile=sys.stdout):
- print>>outfile, '<UL>'
+ print('<UL>', file=outfile)
for (key,location) in self.indexlist:
key = self.codeexpand(key)
location = makefile(location)
location = self.dirname + '/' + location
- print>>outfile, '<LI><OBJECT type="text/sitemap">',
- print>>outfile, '<param name="Name" value="' + key + '">',
- print>>outfile, '<param name="Local" value="' + location + '">',
- print>>outfile, '</OBJECT>'
- print>>outfile, '</UL>'
+ print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
+ print('<param name="Name" value="' + key + '">', end=' ', file=outfile)
+ print('<param name="Local" value="' + location + '">', end=' ', file=outfile)
+ print('</OBJECT>', file=outfile)
+ print('</UL>', file=outfile)
def codeexpand(self, line):
co = self.codeprog.match(line)
@@ -2041,8 +2041,8 @@ def test():
helpbase = sys.argv[2]
del sys.argv[1:3]
if len(sys.argv) <> 3:
- print 'usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
- 'inputfile outputdirectory'
+ print('usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
+ 'inputfile outputdirectory')
sys.exit(2)
if html3:
@@ -2064,7 +2064,7 @@ def test():
try:
fp = open(file, 'r')
except IOError as msg:
- print file, ':', msg
+ print(file, ':', msg)
sys.exit(1)
parser.parse(fp)