From 4be276c1a6502b21ae2e9ccc0071a2105b144efd Mon Sep 17 00:00:00 2001 From: Morgan Courbet Date: Thu, 20 Jul 2017 18:59:38 +0200 Subject: [PATCH] Remove non relevant comments and make others more explicit --- pre_commit_hooks/mixed_line_ending.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pre_commit_hooks/mixed_line_ending.py b/pre_commit_hooks/mixed_line_ending.py index f918d4f..31e8eda 100644 --- a/pre_commit_hooks/mixed_line_ending.py +++ b/pre_commit_hooks/mixed_line_ending.py @@ -52,15 +52,9 @@ VERBOSE_OPTION_TO_LOGGING_SEVERITY = { ANY_LINE_ENDING_PATTERN = re.compile( - # match either - b'(' + - # \r\n - LineEnding.CRLF.regex.pattern + - # or \n + b'(' + LineEnding.CRLF.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): - # read the file with open(filename, 'rb+') as f: bufin = f.read() # convert line ending 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.write(bufout) f.truncate()