|
18 | 18 | # since the same version
|
19 | 19 | # * Prints information about features
|
20 | 20 |
|
21 |
| -import sys, os, re |
| 21 | +import sys |
| 22 | +import os |
| 23 | +import re |
| 24 | +import codecs |
22 | 25 |
|
23 | 26 | if len(sys.argv) < 2:
|
24 |
| - print "usage: featurkck.py <src-dir>" |
| 27 | + print("usage: featureck.py <src-dir>") |
25 | 28 | sys.exit(1)
|
26 | 29 |
|
27 | 30 | src_dir = sys.argv[1]
|
|
47 | 50 | line = line.replace("(", "").replace("),", "").replace(")", "")
|
48 | 51 | parts = line.split(",")
|
49 | 52 | if len(parts) != 3:
|
50 |
| - print "error: unexpected number of components in line: " + original_line |
| 53 | + print("error: unexpected number of components in line: " + original_line) |
51 | 54 | sys.exit(1)
|
52 | 55 | feature_name = parts[0].strip().replace('"', "")
|
53 | 56 | since = parts[1].strip().replace('"', "")
|
|
79 | 82 | continue
|
80 | 83 |
|
81 | 84 | path = os.path.join(dirpath, filename)
|
82 |
| - with open(path, 'r') as f: |
| 85 | + with codecs.open(filename=path, mode='r', encoding="utf-8") as f: |
83 | 86 | line_num = 0
|
84 | 87 | for line in f:
|
85 | 88 | line_num += 1
|
|
107 | 110 | if not mm is None:
|
108 | 111 | since = mm.group(1)
|
109 | 112 | else:
|
110 |
| - print "error: misformed stability attribute" |
111 |
| - print "line " + str(line_num) + " of " + path + ":" |
112 |
| - print line |
| 113 | + print("error: misformed stability attribute") |
| 114 | + print("line %d of %:" % (line_num, path)) |
| 115 | + print(line) |
113 | 116 | errors = True
|
114 | 117 |
|
115 | 118 | lib_features[feature_name] = feature_name
|
|
123 | 126 | (expected_since, source_path, source_line_num, source_line) = \
|
124 | 127 | lib_features_and_level.get((feature_name, level))
|
125 | 128 | 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 |
| 129 | + print("error: mismatch in %s feature '%s'" % (level, feature_name)) |
| 130 | + print("line %d of %s:" % (source_line_num, source_path)) |
| 131 | + print(source_line) |
| 132 | + print("line %d of %s:" % (line_num, path)) |
| 133 | + print(line) |
131 | 134 | errors = True
|
132 | 135 |
|
133 | 136 | # Verify that this lib feature doesn't duplicate a lang feature
|
134 | 137 | 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 |
| 138 | + print("error: lib feature '%s' duplicates a lang feature" % (feature_name)) |
| 139 | + print("line %d of %s:" % (line_num, path)) |
| 140 | + print(line) |
138 | 141 | errors = True
|
139 | 142 |
|
140 | 143 | else:
|
141 |
| - print "error: misformed stability attribute" |
142 |
| - print "line " + str(line_num) + " of " + path + ":" |
143 |
| - print line |
| 144 | + print("error: misformed stability attribute") |
| 145 | + print("line %d of %s:" % (line_num, path)) |
| 146 | + print(line) |
144 | 147 | errors = True
|
145 | 148 |
|
146 | 149 | # Merge data about both lists
|
|
175 | 178 | is_unstable = lib_features_and_level.get((name, "unstable")) is not None
|
176 | 179 |
|
177 | 180 | if is_stable and is_unstable:
|
178 |
| - print "error: feature '" + name + "' is both stable and unstable" |
| 181 | + print("error: feature '%s' is both stable and unstable" % (name)) |
179 | 182 | errors = True
|
180 | 183 |
|
181 | 184 | if is_stable:
|
|
192 | 195 | for name in lib_feature_stats:
|
193 | 196 | if language_feature_stats.get(name) is not None:
|
194 | 197 | if not name in joint_features:
|
195 |
| - print "error: feature '" + name + "' is both a lang and lib feature but not whitelisted" |
| 198 | + print("error: feature '%s' is both a lang and lib feature but not whitelisted" % (name)) |
196 | 199 | errors = True
|
197 | 200 | lang_status = language_feature_stats[name][3]
|
198 | 201 | lib_status = lib_feature_stats[name][3]
|
199 | 202 | lang_stable_since = language_feature_stats[name][4]
|
200 | 203 | lib_stable_since = lib_feature_stats[name][4]
|
201 | 204 |
|
202 | 205 | 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 |
| 206 | + print("error: feature '%s' has lang status %s " + |
| 207 | + "but lib status %s" % (name, lang_status, lib_status)) |
205 | 208 | errors = True
|
206 | 209 |
|
207 | 210 | 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 |
| 211 | + print("error: feature '%s' has lang stable since %s " + |
| 212 | + "but lib stable since %s" % (name, lang_stable_since, lib_stable_since)) |
210 | 213 | errors = True
|
211 | 214 |
|
212 | 215 | merged_stats[name] = (name, True, True, lang_status, lang_stable_since)
|
|
240 | 243 |
|
241 | 244 | print
|
242 | 245 | for line in lines:
|
243 |
| - print "* " + line |
| 246 | + print("* " + line) |
244 | 247 | print
|
0 commit comments