mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 03:56:54 +00:00
Remove non relevant comments and make others more explicit
This commit is contained in:
parent
f58b552c37
commit
4be276c1a6
1 changed files with 3 additions and 10 deletions
|
|
@ -52,15 +52,9 @@ VERBOSE_OPTION_TO_LOGGING_SEVERITY = {
|
||||||
|
|
||||||
|
|
||||||
ANY_LINE_ENDING_PATTERN = re.compile(
|
ANY_LINE_ENDING_PATTERN = re.compile(
|
||||||
# match either
|
b'(' + LineEnding.CRLF.regex.pattern +
|
||||||
b'(' +
|
|
||||||
# \r\n
|
|
||||||
LineEnding.CRLF.regex.pattern +
|
|
||||||
# or \n
|
|
||||||
b'|' + LineEnding.LF.regex.pattern +
|
b'|' + LineEnding.LF.regex.pattern +
|
||||||
# or \r
|
b'|' + LineEnding.CR.regex.pattern + b')',
|
||||||
b'|' + LineEnding.CR.regex.pattern +
|
|
||||||
b')',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -252,14 +246,13 @@ def _process_fix_force(filenames, line_ending_enum):
|
||||||
|
|
||||||
|
|
||||||
def _convert_line_ending(filename, line_ending):
|
def _convert_line_ending(filename, line_ending):
|
||||||
# read the file
|
|
||||||
with open(filename, 'rb+') as f:
|
with open(filename, 'rb+') as f:
|
||||||
bufin = f.read()
|
bufin = f.read()
|
||||||
|
|
||||||
# convert line ending
|
# convert line ending
|
||||||
bufout = ANY_LINE_ENDING_PATTERN.sub(line_ending, bufin)
|
bufout = ANY_LINE_ENDING_PATTERN.sub(line_ending, bufin)
|
||||||
|
|
||||||
# write the result in the file
|
# write the result in the file replacing the existing content
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
f.write(bufout)
|
f.write(bufout)
|
||||||
f.truncate()
|
f.truncate()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue