Skip to content

Commit 68b64f5

Browse files
committed
scripts: Fix gha helper script
1 parent e50d665 commit 68b64f5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

scripts/typos_json_to_gha.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,25 @@ def main():
1414
# Grab the JSON data coming from typos from stdin
1515
data = json.loads(line.rstrip())
1616

17-
# Calculate the end column and format the correction
18-
end_col = data['byte_offset'] + len(data['typo'])
19-
suggestions = ', '.join(data['corrections'])
20-
21-
# Print the templated message to stdout
22-
print(message_template.safe_substitute(
23-
data, end_col=end_col, suggestions=suggestions
24-
))
17+
if data['type'] == 'binary_file':
18+
continue
19+
20+
try:
21+
# Calculate the end column and format the correction
22+
suggestions = ', '.join(data['corrections'])
23+
end_col = data['byte_offset'] + len(data['typo'])
24+
25+
# Print the templated message to stdout
26+
print(message_template.safe_substitute(
27+
data, end_col=end_col, suggestions=suggestions
28+
))
29+
except KeyError:
30+
print('KeyError')
31+
print(f'{data}')
32+
except Exception as e:
33+
print('Caught unhandled exception')
34+
print(f'{data}')
35+
print(f'{e}')
2536

2637

2738
if __name__ == '__main__':

0 commit comments

Comments
 (0)