| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import lib2to3.refactor | 6 import lib2to3.refactor |
| 7 | 7 |
| 8 from webkitpy.common.system.systemhost import SystemHost | 8 from webkitpy.common.system.systemhost import SystemHost |
| 9 from webkitpy.thirdparty import autopep8 | 9 from webkitpy.thirdparty import autopep8 |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 arglist = [(host, name, autopep8_options, fixers, options.backup) for name i
n options.files] | 50 arglist = [(host, name, autopep8_options, fixers, options.backup) for name i
n options.files] |
| 51 host = host or SystemHost() | 51 host = host or SystemHost() |
| 52 | 52 |
| 53 host.executive.map(_reformat_thunk, arglist, processes=options.jobs) | 53 host.executive.map(_reformat_thunk, arglist, processes=options.jobs) |
| 54 | 54 |
| 55 | 55 |
| 56 def _autopep8_options_for_style(style): | 56 def _autopep8_options_for_style(style): |
| 57 return { | 57 return { |
| 58 None: [], | 58 None: [], |
| 59 'blink': autopep8.parse_args(['--aggressive', | 59 'blink': autopep8.parse_args([ |
| 60 '--max-line-length', '132', | 60 '--aggressive', |
| 61 '--indent-size', '4', | 61 '--max-line-length', '132', |
| 62 '']), | 62 '--ignore=E309', |
| 63 'chromium': autopep8.parse_args(['--aggressive', | 63 '--indent-size', '4', |
| 64 '--max-line-length', '80', | 64 '', |
| 65 '--indent-size', '2', | 65 ]), |
| 66 '']), | 66 'chromium': autopep8.parse_args([ |
| 67 '--aggressive', |
| 68 '--max-line-length', '80', |
| 69 '--ignore=E309', |
| 70 '--indent-size', '2', |
| 71 '', |
| 72 ]), |
| 67 }.get(style) | 73 }.get(style) |
| 68 | 74 |
| 69 | 75 |
| 70 def _fixers_for_quoting(quoting): | 76 def _fixers_for_quoting(quoting): |
| 71 return { | 77 return { |
| 72 None: [], | 78 None: [], |
| 73 'double': ['webkitpy.formatter.fix_double_quote_strings'], | 79 'double': ['webkitpy.formatter.fix_double_quote_strings'], |
| 74 'single': ['webkitpy.formatter.fix_single_quote_strings'], | 80 'single': ['webkitpy.formatter.fix_single_quote_strings'], |
| 75 }.get(quoting) | 81 }.get(quoting) |
| 76 | 82 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 | 100 |
| 95 if autopep8_options: | 101 if autopep8_options: |
| 96 tmp_str = autopep8.fix_code(tmp_str, autopep8_options) | 102 tmp_str = autopep8.fix_code(tmp_str, autopep8_options) |
| 97 | 103 |
| 98 if fixers: | 104 if fixers: |
| 99 tool = lib2to3.refactor.RefactoringTool(fixer_names=fixers, | 105 tool = lib2to3.refactor.RefactoringTool(fixer_names=fixers, |
| 100 explicit=fixers) | 106 explicit=fixers) |
| 101 tmp_str = unicode(tool.refactor_string(tmp_str, name=name)) | 107 tmp_str = unicode(tool.refactor_string(tmp_str, name=name)) |
| 102 | 108 |
| 103 return tmp_str | 109 return tmp_str |
| OLD | NEW |