Skip to content

Commit 93a02d3

Browse files
committed
etc: py3 compat for featureck
Also rewrite most of the string formatting to be a bit more idiomatic
1 parent 9ecc5a9 commit 93a02d3

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/etc/featureck.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import sys, os, re
2222

2323
if len(sys.argv) < 2:
24-
print "usage: featurkck.py <src-dir>"
24+
print("usage: featureck.py <src-dir>")
2525
sys.exit(1)
2626

2727
src_dir = sys.argv[1]
@@ -47,7 +47,7 @@
4747
line = line.replace("(", "").replace("),", "").replace(")", "")
4848
parts = line.split(",")
4949
if len(parts) != 3:
50-
print "error: unexpected number of components in line: " + original_line
50+
print("error: unexpected number of components in line: " + original_line)
5151
sys.exit(1)
5252
feature_name = parts[0].strip().replace('"', "")
5353
since = parts[1].strip().replace('"', "")
@@ -107,9 +107,9 @@
107107
if not mm is None:
108108
since = mm.group(1)
109109
else:
110-
print "error: misformed stability attribute"
111-
print "line " + str(line_num) + " of " + path + ":"
112-
print line
110+
print("error: misformed stability attribute")
111+
print("line %d of %:" % (line_num, path))
112+
print(line)
113113
errors = True
114114

115115
lib_features[feature_name] = feature_name
@@ -123,24 +123,24 @@
123123
(expected_since, source_path, source_line_num, source_line) = \
124124
lib_features_and_level.get((feature_name, level))
125125
if since != expected_since:
126-
print "error: mismatch in " + level + " feature '" + feature_name + "'"
127-
print "line " + str(source_line_num) + " of " + source_path + ":"
128-
print source_line
129-
print "line " + str(line_num) + " of " + path + ":"
130-
print line
126+
print("error: mismatch in %s feature '%s'" % (level, feature_name))
127+
print("line %d of %s:" % (source_line_num, source_path))
128+
print(source_line)
129+
print("line %d of %s:" % (line_num, path))
130+
print(line)
131131
errors = True
132132

133133
# Verify that this lib feature doesn't duplicate a lang feature
134134
if feature_name in language_feature_names:
135-
print "error: lib feature '" + feature_name + "' duplicates a lang feature"
136-
print "line " + str(line_num) + " of " + path + ":"
137-
print line
135+
print("error: lib feature '%s' duplicates a lang feature" % (feature_name))
136+
print("line %d of %s:" % (line_num, path))
137+
print(line)
138138
errors = True
139139

140140
else:
141-
print "error: misformed stability attribute"
142-
print "line " + str(line_num) + " of " + path + ":"
143-
print line
141+
print("error: misformed stability attribute")
142+
print("line %d of %s:" % (line_num, path))
143+
print(line)
144144
errors = True
145145

146146
# Merge data about both lists
@@ -175,7 +175,7 @@
175175
is_unstable = lib_features_and_level.get((name, "unstable")) is not None
176176

177177
if is_stable and is_unstable:
178-
print "error: feature '" + name + "' is both stable and unstable"
178+
print("error: feature '%s' is both stable and unstable" % (name))
179179
errors = True
180180

181181
if is_stable:
@@ -192,21 +192,21 @@
192192
for name in lib_feature_stats:
193193
if language_feature_stats.get(name) is not None:
194194
if not name in joint_features:
195-
print "error: feature '" + name + "' is both a lang and lib feature but not whitelisted"
195+
print("error: feature '%s' is both a lang and lib feature but not whitelisted" % (name))
196196
errors = True
197197
lang_status = language_feature_stats[name][3]
198198
lib_status = lib_feature_stats[name][3]
199199
lang_stable_since = language_feature_stats[name][4]
200200
lib_stable_since = lib_feature_stats[name][4]
201201

202202
if lang_status != lib_status and lib_status != "deprecated":
203-
print "error: feature '" + name + "' has lang status " + lang_status + \
204-
" but lib status " + lib_status
203+
print("error: feature '%s' has lang status %s " +
204+
"but lib status %s" % (name, lang_status, lib_status))
205205
errors = True
206206

207207
if lang_stable_since != lib_stable_since:
208-
print "error: feature '" + name + "' has lang stable since " + lang_stable_since + \
209-
" but lib stable since " + lib_stable_since
208+
print("error: feature '%s' has lang stable since %s " +
209+
"but lib stable since %s" % (name, lang_stable_since, lib_stable_since))
210210
errors = True
211211

212212
merged_stats[name] = (name, True, True, lang_status, lang_stable_since)
@@ -240,5 +240,5 @@
240240

241241
print
242242
for line in lines:
243-
print "* " + line
243+
print("* " + line)
244244
print

0 commit comments

Comments
 (0)