File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff 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
2738if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments