Skip to content

Commit e39238a

Browse files
BPerlakiHkelson42
authored andcommitted
Make extra and unused strings an assertion error
1 parent 4966ceb commit e39238a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

localizations.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,18 @@ def __init__(self, input_file_name, comment_file_name, enum_name, search_directo
114114
if swift_var in content:
115115
counter[swift_var] += 1
116116

117-
assert len(matches.keys()) == 0, "localization strings should not be used directly in swift: {}".format(matches)
117+
assert len(matches.keys()) == 0, "localization strings cannot not be directly used in swift (use LocalString instead): {}".format(matches)
118118
unused_swift_vars = {k: v for k, v in counter.items() if v == 0 }.keys()
119-
if len(unused_swift_vars) > 0:
120-
print("unused localizations in swift: {}".format(sorted(unused_swift_vars)))
119+
assert len(unused_swift_vars) == 0, "unused localizations entries (delete them from localizations, and run: python localizations.py generate): {}".format(sorted(unused_swift_vars))
121120

122121
comment_keys = list()
123122
comment_reader = Reader(comment_file_name)
124123
for comment_key, _ in comment_reader.keys():
125-
assert comment_key in vars, "extra qqq key: {}".format(comment_key)
124+
assert comment_key in vars, "extra qqq key found: {}".format(comment_key)
126125
comment_keys.append(comment_key)
127126

128127
missing = sorted(set(vars).difference(comment_keys))
129-
if len(missing) > 0:
130-
print("missing qqq keys: {}".format(missing))
128+
assert len(missing) == 0, "undocumented keys (please add them to qqq): {}".format(missing)
131129

132130
def __get_var_name(self, key):
133131
return re.sub('[^a-z0-9]', '_', key.lower())

0 commit comments

Comments
 (0)