Skip to content

Commit a0d6cae

Browse files
committed
Add python/fix_error_messages.py
1 parent 464fa3f commit a0d6cae

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

python/fix_error_messages.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import fileinput
2+
import re
3+
4+
MESSAGE_RE = re.compile(r'( (?:\w+/)+ \w+ \.py :\d+)(?::\d+)?(.*)', re.VERBOSE)
5+
6+
7+
def pr(*a):
8+
if False:
9+
print(*a)
10+
11+
12+
def fix_error_messages():
13+
for line in fileinput.input():
14+
if m := MESSAGE_RE.search(line):
15+
file, message = m.groups()
16+
print(f"{file}: {message.strip()}")
17+
else:
18+
print(line.rstrip())
19+
20+
21+
if __name__ == '__main__':
22+
fix_error_messages()

0 commit comments

Comments
 (0)