Skip to content

Commit cdbb042

Browse files
committed
Use print() function in both Python 2 and Python 3
1 parent 444218e commit cdbb042

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

modules/ts/misc/chart.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
34
import testlog_parser, sys, os, xml, re
45
from table_formatter import *
56
from optparse import OptionParser
@@ -116,7 +117,7 @@ def getTest(stests, x, y, row, col):
116117
(options, args) = parser.parse_args()
117118

118119
if len(args) != 1:
119-
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml"
120+
print("Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml", file=sys.stderr)
120121
exit(1)
121122

122123
options.generateHtml = detectHtmlOutputType(options.format)
@@ -136,7 +137,7 @@ def getTest(stests, x, y, row, col):
136137
args[0] = os.path.basename(args[0])
137138

138139
if not tests:
139-
print >> sys.stderr, "Error - no tests matched"
140+
print("Error - no tests matched", file=sys.stderr)
140141
exit(1)
141142

142143
argsnum = len(tests[0][1])
@@ -156,26 +157,26 @@ def getTest(stests, x, y, row, col):
156157
names1.add(sn)
157158
if sn == sname:
158159
if len(pair[1]) != argsnum:
159-
print >> sys.stderr, "Error - unable to create chart tables for functions having different argument numbers"
160+
print("Error - unable to create chart tables for functions having different argument numbers", file=sys.stderr)
160161
sys.exit(1)
161162
for i in range(argsnum):
162163
arglists[i][pair[1][i]] = 1
163164

164165
if names1 or len(names) != 1:
165-
print >> sys.stderr, "Error - unable to create tables for functions from different test suits:"
166+
print("Error - unable to create tables for functions from different test suits:", file=sys.stderr)
166167
i = 1
167168
for name in sorted(names):
168-
print >> sys.stderr, "%4s: %s" % (i, name)
169+
print("%4s: %s" % (i, name), file=sys.stderr)
169170
i += 1
170171
if names1:
171-
print >> sys.stderr, "Other suits in this log (can not be chosen):"
172+
print("Other suits in this log (can not be chosen):", file=sys.stderr)
172173
for name in sorted(names1):
173-
print >> sys.stderr, "%4s: %s" % (i, name)
174+
print("%4s: %s" % (i, name), file=sys.stderr)
174175
i += 1
175176
sys.exit(1)
176177

177178
if argsnum < 2:
178-
print >> sys.stderr, "Error - tests from %s have less than 2 parameters" % sname
179+
print("Error - tests from %s have less than 2 parameters" % sname, file=sys.stderr)
179180
exit(1)
180181

181182
for i in range(argsnum):

modules/ts/misc/report.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
34
import testlog_parser, sys, os, xml, re, glob
45
from table_formatter import *
56
from optparse import OptionParser
@@ -14,7 +15,7 @@
1415
(options, args) = parser.parse_args()
1516

1617
if len(args) < 1:
17-
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml"
18+
print("Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml", file=sys.stderr)
1819
exit(0)
1920

2021
options.generateHtml = detectHtmlOutputType(options.format)

modules/ts/misc/summary.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
34
import testlog_parser, sys, os, xml, glob, re
45
from table_formatter import *
56
from optparse import OptionParser
@@ -26,7 +27,7 @@ def getSetName(tset, idx, columns, short = True):
2627

2728
if __name__ == "__main__":
2829
if len(sys.argv) < 2:
29-
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml [<log_name2>.xml ...]"
30+
print("Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml [<log_name2>.xml ...]", file=sys.stderr)
3031
exit(0)
3132

3233
parser = OptionParser()

0 commit comments

Comments
 (0)