| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Generic presubmit checks that can be reused by other presubmit checks.""" | 5 """Generic presubmit checks that can be reused by other presubmit checks.""" |
| 6 | 6 |
| 7 import os as _os | 7 import os as _os |
| 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) | 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) |
| 9 | 9 |
| 10 | 10 |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 for arg in extra_args: | 668 for arg in extra_args: |
| 669 child.stdin.write(arg + '\n') | 669 child.stdin.write(arg + '\n') |
| 670 child.stdin.close() | 670 child.stdin.close() |
| 671 | 671 |
| 672 child.communicate() | 672 child.communicate() |
| 673 return child.returncode | 673 return child.returncode |
| 674 except OSError: | 674 except OSError: |
| 675 return 'Pylint failed!' | 675 return 'Pylint failed!' |
| 676 | 676 |
| 677 result = None | 677 result = None |
| 678 if not input_api.verbose: | 678 # Always run pylint and pass it all the py files at once. |
| 679 # Passing py files one at time is slower and can produce |
| 680 # different results. input_api.verbose used to be used |
| 681 # to enable this behaviour but differing behaviour in |
| 682 # verbose mode is not desirable. |
| 683 if True: |
| 679 result = run_lint(sorted(files)) | 684 result = run_lint(sorted(files)) |
| 680 else: | 685 else: |
| 681 for filename in sorted(files): | 686 for filename in sorted(files): |
| 682 print('Running pylint on %s' % filename) | 687 print('Running pylint on %s' % filename) |
| 683 result = run_lint([filename]) or result | 688 result = run_lint([filename]) or result |
| 684 if isinstance(result, basestring): | 689 if isinstance(result, basestring): |
| 685 return [error_type(result)] | 690 return [error_type(result)] |
| 686 elif result: | 691 elif result: |
| 687 return [error_type('Fix pylint errors first.')] | 692 return [error_type('Fix pylint errors first.')] |
| 688 return [] | 693 return [] |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 959 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
| 955 input_api, output_api)) | 960 input_api, output_api)) |
| 956 snapshot("checking license") | 961 snapshot("checking license") |
| 957 results.extend(input_api.canned_checks.CheckLicense( | 962 results.extend(input_api.canned_checks.CheckLicense( |
| 958 input_api, output_api, license_header, source_file_filter=sources)) | 963 input_api, output_api, license_header, source_file_filter=sources)) |
| 959 snapshot("checking was uploaded") | 964 snapshot("checking was uploaded") |
| 960 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 965 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
| 961 input_api, output_api)) | 966 input_api, output_api)) |
| 962 snapshot("done") | 967 snapshot("done") |
| 963 return results | 968 return results |
| OLD | NEW |