()
| 23 | |
| 24 | |
| 25 | def main(): |
| 26 | parser = argparse.ArgumentParser( |
| 27 | description='Normalize tabs and multiple spaces to single spaces') |
| 28 | parser.add_argument('filenames', nargs='*', help='Filenames to fix') |
| 29 | args = parser.parse_args() |
| 30 | |
| 31 | retval = 0 |
| 32 | for filename in args.filenames: |
| 33 | with open(filename, 'r', encoding='utf-8') as f: |
| 34 | original_contents = f.read() |
| 35 | |
| 36 | normalized_contents = normalize_whitespace(original_contents) |
| 37 | |
| 38 | if original_contents != normalized_contents: |
| 39 | print(f'Fixing {filename}') |
| 40 | with open(filename, 'w', encoding='utf-8') as f: |
| 41 | f.write(normalized_contents) |
| 42 | retval = 1 |
| 43 | |
| 44 | return retval |
| 45 | |
| 46 | |
| 47 | if __name__ == '__main__': |
no test coverage detected