Skip to content

Commit 64a8468

Browse files
committed
Print all lines that match the regex pattern
1 parent b0a931b commit 64a8468

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

relint.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,22 @@ def main():
8585
_filename = filename
8686
lines = match.string.splitlines()
8787

88-
line_no = match.string[:match.start()].count('\n')
88+
start_line_no = match.string[:match.start()].count('\n')
89+
end_line_no = match.string[:match.end()].count('\n')
8990
output_format = "{filename}:{line_no} {test.name}"
9091
print(output_format.format(
91-
filename=filename, line_no=line_no + 1, test=test,
92+
filename=filename, line_no=start_line_no + 1, test=test,
9293
))
9394
if test.hint:
9495
print("Hint:", test.hint)
95-
print("> ", lines[line_no])
96+
match_lines = (
97+
"{line_no}> {code_line}".format(
98+
line_no=no + start_line_no + 1,
99+
code_line=line,
100+
)
101+
for no, line in enumerate(lines[start_line_no:end_line_no + 1])
102+
)
103+
print(*match_lines, sep="\n")
96104

97105
exit(exit_code)
98106

0 commit comments

Comments
 (0)