Refactor mixed_line_ending

This commit is contained in:
Morgan Courbet 2017-07-04 21:23:03 +02:00
parent 614893f36d
commit a1e1421a99
No known key found for this signature in database
GPG key ID: 467299D324A21B24

View file

@ -79,14 +79,7 @@ def mixed_line_ending(argv=None):
return _process_fix_auto(filenames)
# when a line ending character is forced with --fix option
else:
line_ending_enum = fix_option.line_ending_enum
logging.info('Force line ending to "%s"', line_ending_enum.str_print)
for filename in options['filenames']:
_convert_line_ending(filename, line_ending_enum.string)
return 1
return _process_fix_force(filenames, fix_option.line_ending_enum)
return 0
@ -221,6 +214,15 @@ def _process_fix_auto(filenames):
return 1 if converted_found else 0
def _process_fix_force(filenames, line_ending_enum):
logging.info('Force line ending to "%s"', line_ending_enum.str_print)
for filename in filenames:
_convert_line_ending(filename, line_ending_enum.string)
return 1
def _convert_line_ending(filename, line_ending):
# read the file
fin = open(filename, 'r')