mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Address review comments
This commit is contained in:
parent
55c74c10d9
commit
55ef3ce960
1 changed files with 6 additions and 10 deletions
|
|
@ -34,17 +34,13 @@ def _process_filename_at_once(pattern, filename):
|
|||
match = pattern.search(contents)
|
||||
if match:
|
||||
retv = 1
|
||||
line_no = len(
|
||||
re.compile('\n'.encode()).findall(contents, 0, match.start()),
|
||||
)
|
||||
output.write(
|
||||
'{}:{}:'.format(filename, line_no + 1),
|
||||
)
|
||||
line_no = contents[:match.start()].count(b'\n')
|
||||
output.write('{}:{}:'.format(filename, line_no + 1))
|
||||
|
||||
matched_lines = match.group().split('\n')
|
||||
matched_lines[0] = contents.split('\n')[line_no]
|
||||
matched_lines = match.group().split(b'\n')
|
||||
matched_lines[0] = contents.split(b'\n')[line_no]
|
||||
|
||||
output.write_line('\n'.join(matched_lines))
|
||||
output.write_line(b'\n'.join(matched_lines))
|
||||
return retv
|
||||
|
||||
|
||||
|
|
@ -70,7 +66,7 @@ def main(argv=None):
|
|||
|
||||
flags = re.IGNORECASE if args.ignore_case else 0
|
||||
if args.multiline:
|
||||
flags = flags | re.MULTILINE | re.DOTALL
|
||||
flags |= re.MULTILINE | re.DOTALL
|
||||
|
||||
pattern = re.compile(args.pattern.encode(), flags)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue