| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import cStringIO | 6 import cStringIO |
| 7 import imp | 7 import imp |
| 8 import inspect | 8 import inspect |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 import_group.append(list(import_match.groups())) | 100 import_group.append(list(import_match.groups())) |
| 101 continue | 101 continue |
| 102 | 102 |
| 103 if not import_group: | 103 if not import_group: |
| 104 updated_file.write(line) | 104 updated_file.write(line) |
| 105 continue | 105 continue |
| 106 | 106 |
| 107 _WriteImports(updated_file, import_group) | 107 _WriteImports(updated_file, import_group) |
| 108 import_group = [] | 108 import_group = [] |
| 109 | 109 |
| 110 Updated_file.write(line) | 110 updated_file.write(line) |
| 111 | 111 |
| 112 if import_group: | 112 if import_group: |
| 113 _WriteImports(updated_file, import_group) | 113 _WriteImports(updated_file, import_group) |
| 114 import_group = [] | 114 import_group = [] |
| 115 | 115 |
| 116 if original_file == updated_file.getvalue(): | 116 if original_file == updated_file.getvalue(): |
| 117 return False | 117 return False |
| 118 | 118 |
| 119 with open(module_path, 'w') as module_file: | 119 with open(module_path, 'w') as module_file: |
| 120 module_file.write(updated_file.getvalue()) | 120 module_file.write(updated_file.getvalue()) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 _, ext = os.path.splitext(file_name) | 280 _, ext = os.path.splitext(file_name) |
| 281 return ext == '.py' | 281 return ext == '.py' |
| 282 | 282 |
| 283 | 283 |
| 284 class RefactorCommand(command_line.SubcommandCommand): | 284 class RefactorCommand(command_line.SubcommandCommand): |
| 285 commands = (Count, Mv,) | 285 commands = (Count, Mv,) |
| 286 | 286 |
| 287 | 287 |
| 288 if __name__ == '__main__': | 288 if __name__ == '__main__': |
| 289 sys.exit(RefactorCommand.main()) | 289 sys.exit(RefactorCommand.main()) |
| OLD | NEW |