Skip to content

Commit 6afaeb7

Browse files
committed
Convert print statements to function calls in Tools/.
1 parent e5d0e84 commit 6afaeb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+778
-780
lines changed

Tools/audiopy/audiopy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ class Helpwin:
401401

402402

403403
def usage(code, msg=''):
404-
print __doc__ % globals()
404+
print(__doc__ % globals())
405405
if msg:
406-
print msg
406+
print(msg)
407407
sys.exit(code)
408408

409409

@@ -455,11 +455,11 @@ def main():
455455
i = i + 1
456456
continue
457457
elif arg in ('-v', '--version'):
458-
print '''\
458+
print('''\
459459
audiopy -- a program to control the Solaris audio device.
460460
Contact: Barry Warsaw
461461
Email: bwarsaw@python.org
462-
Version: %s''' % __version__
462+
Version: %s''' % __version__)
463463
sys.exit(0)
464464
for long, short, io, mask in options:
465465
if arg in (long, short):

Tools/bgen/bgen/bgenGenerator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class BaseFunctionGenerator:
1717

1818
def __init__(self, name, condition=None, callname=None, modifiers=None):
19-
if DEBUG: print "<--", name
19+
if DEBUG: print("<--", name)
2020
self.name = name
2121
if callname:
2222
self.callname = callname
@@ -36,7 +36,7 @@ def checkgenerate(self):
3636
def generate(self):
3737
if not self.checkgenerate():
3838
return
39-
if DEBUG: print "-->", self.name
39+
if DEBUG: print("-->", self.name)
4040
if self.condition:
4141
Output()
4242
Output(self.condition)
@@ -157,7 +157,7 @@ def docstring(self):
157157
continue
158158
else:
159159
typeName = "?"
160-
print "Nameless type", arg.type
160+
print("Nameless type", arg.type)
161161

162162
str = typeName + ' ' + arg.name
163163
if arg.mode in (InMode, InOutMode):
@@ -294,7 +294,7 @@ def _test():
294294
(int, 'status', ErrorMode),
295295
)
296296
eggs.setprefix("spam")
297-
print "/* START */"
297+
print("/* START */")
298298
eggs.generate()
299299

300300

Tools/bgen/bgen/bgenGeneratorGroup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, prefix):
99
def add(self, g, dupcheck=0):
1010
if dupcheck:
1111
if g in self.generators:
12-
print 'DUP', g.name
12+
print('DUP', g.name)
1313
return
1414
g.setprefix(self.prefix)
1515
self.generators.append(g)
@@ -33,7 +33,7 @@ def _test():
3333
group = GeneratorGroup("spam")
3434
eggs = FunctionGenerator(void, "eggs")
3535
group.add(eggs)
36-
print "/* START */"
36+
print("/* START */")
3737
group.generate()
3838

3939
if __name__ == "__main__":

Tools/bgen/bgen/scantools.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ def initsilent(self):
162162

163163
def error(self, format, *args):
164164
if self.silent >= 0:
165-
print format%args
165+
print(format%args)
166166

167167
def report(self, format, *args):
168168
if not self.silent:
169-
print format%args
169+
print(format%args)
170170

171171
def writeinitialdefs(self):
172172
pass
@@ -221,7 +221,7 @@ def makerepairinstructions(self):
221221
"""
222222
f = self.openrepairfile()
223223
if not f: return []
224-
print "Reading repair file", repr(f.name), "..."
224+
print("Reading repair file", repr(f.name), "...")
225225
list = []
226226
lineno = 0
227227
while 1:
@@ -237,31 +237,31 @@ def makerepairinstructions(self):
237237
words = [s.strip() for s in line.split(':')]
238238
if words == ['']: continue
239239
if len(words) <> 3:
240-
print "Line", startlineno,
241-
print ": bad line (not 3 colon-separated fields)"
242-
print repr(line)
240+
print("Line", startlineno, end=' ')
241+
print(": bad line (not 3 colon-separated fields)")
242+
print(repr(line))
243243
continue
244244
[fpat, pat, rep] = words
245245
if not fpat: fpat = "*"
246246
if not pat:
247-
print "Line", startlineno,
248-
print "Empty pattern"
249-
print repr(line)
247+
print("Line", startlineno, end=' ')
248+
print("Empty pattern")
249+
print(repr(line))
250250
continue
251251
patparts = [s.strip() for s in pat.split(',')]
252252
repparts = [s.strip() for s in rep.split(',')]
253253
patterns = []
254254
for p in patparts:
255255
if not p:
256-
print "Line", startlineno,
257-
print "Empty pattern part"
258-
print repr(line)
256+
print("Line", startlineno, end=' ')
257+
print("Empty pattern part")
258+
print(repr(line))
259259
continue
260260
pattern = p.split()
261261
if len(pattern) > 3:
262-
print "Line", startlineno,
263-
print "Pattern part has > 3 words"
264-
print repr(line)
262+
print("Line", startlineno, end=' ')
263+
print("Pattern part has > 3 words")
264+
print(repr(line))
265265
pattern = pattern[:3]
266266
else:
267267
while len(pattern) < 3:
@@ -270,15 +270,15 @@ def makerepairinstructions(self):
270270
replacements = []
271271
for p in repparts:
272272
if not p:
273-
print "Line", startlineno,
274-
print "Empty replacement part"
275-
print repr(line)
273+
print("Line", startlineno, end=' ')
274+
print("Empty replacement part")
275+
print(repr(line))
276276
continue
277277
replacement = p.split()
278278
if len(replacement) > 3:
279-
print "Line", startlineno,
280-
print "Pattern part has > 3 words"
281-
print repr(line)
279+
print("Line", startlineno, end=' ')
280+
print("Pattern part has > 3 words")
281+
print(repr(line))
282282
replacement = replacement[:3]
283283
else:
284284
while len(replacement) < 3:
@@ -294,8 +294,8 @@ def openrepairfile(self, filename = "REPAIR"):
294294
try:
295295
return open(filename, "rU")
296296
except IOError as msg:
297-
print repr(filename), ":", msg
298-
print "Cannot open repair file -- assume no repair needed"
297+
print(repr(filename), ":", msg)
298+
print("Cannot open repair file -- assume no repair needed")
299299
return None
300300

301301
def initfiles(self):

Tools/faqwiz/faqw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
sys.exit(n)
2929
except:
3030
t, v, tb = sys.exc_info()
31-
print
31+
print()
3232
import cgi
3333
cgi.print_exception(t, v, tb)

Tools/faqwiz/faqwiz.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def send_my_cookie(ui):
158158
then = now + COOKIE_LIFETIME
159159
gmt = time.gmtime(then)
160160
path = os.environ.get('SCRIPT_NAME', '/cgi-bin/')
161-
print "Set-Cookie: %s=%s; path=%s;" % (name, value, path),
162-
print time.strftime("expires=%a, %d-%b-%y %X GMT", gmt)
161+
print("Set-Cookie: %s=%s; path=%s;" % (name, value, path), end=' ')
162+
print(time.strftime("expires=%a, %d-%b-%y %X GMT", gmt))
163163

164164
class MagicDict:
165165

@@ -273,39 +273,39 @@ def show(self, edit=1):
273273
raw = 0
274274
continue
275275
if raw:
276-
print line
276+
print(line)
277277
continue
278278
if not line.strip():
279279
if pre:
280-
print '</PRE>'
280+
print('</PRE>')
281281
pre = 0
282282
else:
283-
print '<P>'
283+
print('<P>')
284284
else:
285285
if not line[0].isspace():
286286
if pre:
287-
print '</PRE>'
287+
print('</PRE>')
288288
pre = 0
289289
else:
290290
if not pre:
291-
print '<PRE>'
291+
print('<PRE>')
292292
pre = 1
293293
if '/' in line or '@' in line:
294294
line = translate(line, pre)
295295
elif '<' in line or '&' in line:
296296
line = escape(line)
297297
if not pre and '*' in line:
298298
line = emphasize(line)
299-
print line
299+
print(line)
300300
if pre:
301-
print '</PRE>'
301+
print('</PRE>')
302302
pre = 0
303303
if edit:
304-
print '<P>'
304+
print('<P>')
305305
emit(ENTRY_FOOTER, self)
306306
if self.last_changed_date:
307307
emit(ENTRY_LOGINFO, self)
308-
print '<P>'
308+
print('<P>')
309309

310310
class FaqDir:
311311

@@ -377,7 +377,7 @@ def __init__(self):
377377
self.dir = FaqDir()
378378

379379
def go(self):
380-
print 'Content-type: text/html'
380+
print('Content-type: text/html')
381381
req = self.ui.req or 'home'
382382
mname = 'do_%s' % req
383383
try:
@@ -493,7 +493,7 @@ def last_changed(self, files):
493493
mtime = mtime = entry.getmtime()
494494
if mtime > latest:
495495
latest = mtime
496-
print time.strftime(LAST_CHANGED, time.localtime(latest))
496+
print(time.strftime(LAST_CHANGED, time.localtime(latest)))
497497
emit(EXPLAIN_MARKS)
498498

499499
def format_all(self, files, edit=1, headers=1):
@@ -637,7 +637,7 @@ def rlog(self, command, entry=None):
637637
rev = line[9:].split()
638638
mami = revparse(rev)
639639
if not mami:
640-
print line
640+
print(line)
641641
else:
642642
emit(REVISIONLINK, entry, rev=rev, line=line)
643643
if mami[1] > 1:
@@ -647,7 +647,7 @@ def rlog(self, command, entry=None):
647647
emit(DIFFLINK, entry, prev=rev, rev=headrev)
648648
else:
649649
headrev = rev
650-
print
650+
print()
651651
athead = 0
652652
else:
653653
athead = 0
@@ -656,8 +656,8 @@ def rlog(self, command, entry=None):
656656
athead = 1
657657
sys.stdout.write('<HR>')
658658
else:
659-
print line
660-
print '</PRE>'
659+
print(line)
660+
print('</PRE>')
661661

662662
def do_revision(self):
663663
entry = self.dir.open(self.ui.file)
@@ -686,8 +686,8 @@ def do_diff(self):
686686
def shell(self, command):
687687
output = os.popen(command).read()
688688
sys.stdout.write('<PRE>')
689-
print escape(output)
690-
print '</PRE>'
689+
print(escape(output))
690+
print('</PRE>')
691691

692692
def do_new(self):
693693
entry = self.dir.new(section=int(self.ui.section))
@@ -759,9 +759,9 @@ def do_review(self):
759759

760760
def cantcommit(self):
761761
self.prologue(T_CANTCOMMIT)
762-
print CANTCOMMIT_HEAD
762+
print(CANTCOMMIT_HEAD)
763763
self.errordetail()
764-
print CANTCOMMIT_TAIL
764+
print(CANTCOMMIT_TAIL)
765765

766766
def errordetail(self):
767767
if PASSWORD and self.ui.password != PASSWORD:
@@ -827,7 +827,7 @@ def commit(self, entry):
827827
else:
828828
self.error(T_COMMITFAILED)
829829
emit(COMMITFAILED, sts=sts)
830-
print '<PRE>%s</PRE>' % escape(output)
830+
print('<PRE>%s</PRE>' % escape(output))
831831

832832
try:
833833
os.unlink(tf.name)

Tools/framer/framer/bases.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseMetaclass(type):
2727

2828
def dump_methoddef(self, f, functions, vars):
2929
def p(templ, vars=vars): # helper function to generate output
30-
print >> f, templ % vars
30+
print(templ % vars, file=f)
3131

3232
if not functions:
3333
return
@@ -77,12 +77,12 @@ def initvars(self):
7777

7878
def dump(self, f):
7979
def p(templ, vars=self.__vars): # helper function to generate output
80-
print >> f, templ % vars
80+
print(templ % vars, file=f)
8181

8282
p(template.module_start)
8383
if self.__members:
8484
p(template.member_include)
85-
print >> f
85+
print(file=f)
8686

8787
if self.__doc__:
8888
p(template.module_doc)
@@ -111,10 +111,10 @@ def dump(self, f):
111111

112112
# defined after initvars() so that __vars is defined
113113
def p(templ, vars=self.__vars):
114-
print >> f, templ % vars
114+
print(templ % vars, file=f)
115115

116116
if self.struct is not None:
117-
print >> f, unindent(self.struct, False)
117+
print(unindent(self.struct, False), file=f)
118118

119119
if self.__doc__:
120120
p(template.docstring)
@@ -185,7 +185,7 @@ def initvars(self):
185185

186186
def dump_memberdef(self, f):
187187
def p(templ, vars=self.__vars):
188-
print >> f, templ % vars
188+
print(templ % vars, file=f)
189189

190190
if not self.__members:
191191
return
@@ -196,7 +196,7 @@ def p(templ, vars=self.__vars):
196196

197197
def dump_slots(self, f):
198198
def p(templ, vars=self.__vars):
199-
print >> f, templ % vars
199+
print(templ % vars, file=f)
200200

201201
if self.struct:
202202
p(template.dealloc_func, {"name" : self.__slots[TP_DEALLOC]})
@@ -206,12 +206,12 @@ def p(templ, vars=self.__vars):
206206
val = self.__slots.get(s, s.default)
207207
ntabs = 4 - (4 + len(val)) / 8
208208
line = " %s,%s/* %s */" % (val, "\t" * ntabs, s.name)
209-
print >> f, line
209+
print(line, file=f)
210210
p(template.type_struct_end)
211211

212212
def dump_init(self, f):
213213
def p(templ):
214-
print >> f, templ % self.__vars
214+
print(templ % self.__vars, file=f)
215215

216216
p(template.type_init_type)
217217
p(template.module_add_type)

0 commit comments

Comments
 (0)