| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs Android's lint tool.""" | 7 """Runs Android's lint tool.""" |
| 8 | 8 |
| 9 | 9 |
| 10 import optparse | 10 import optparse |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 with open(result_path, 'wb') as f: | 49 with open(result_path, 'wb') as f: |
| 50 f.write(content) | 50 f.write(content) |
| 51 | 51 |
| 52 def _ParseAndShowResultFile(): | 52 def _ParseAndShowResultFile(): |
| 53 dom = minidom.parse(result_path) | 53 dom = minidom.parse(result_path) |
| 54 issues = dom.getElementsByTagName('issue') | 54 issues = dom.getElementsByTagName('issue') |
| 55 print >> sys.stderr | 55 print >> sys.stderr |
| 56 for issue in issues: | 56 for issue in issues: |
| 57 issue_id = issue.attributes['id'].value | 57 issue_id = issue.attributes['id'].value |
| 58 severity = issue.attributes['severity'].value |
| 58 message = issue.attributes['message'].value | 59 message = issue.attributes['message'].value |
| 59 location_elem = issue.getElementsByTagName('location')[0] | 60 location_elem = issue.getElementsByTagName('location')[0] |
| 60 path = location_elem.attributes['file'].value | 61 path = location_elem.attributes['file'].value |
| 61 line = location_elem.getAttribute('line') | 62 line = location_elem.getAttribute('line') |
| 62 if line: | 63 if line: |
| 63 error = '%s:%s %s: %s [warning]' % (path, line, message, issue_id) | 64 error = '%s:%s %s: %s [%s]' % (path, line, severity, message, |
| 65 issue_id) |
| 64 else: | 66 else: |
| 65 # Issues in class files don't have a line number. | 67 # Issues in class files don't have a line number. |
| 66 error = '%s %s: %s [warning]' % (path, message, issue_id) | 68 error = '%s %s: %s [%s]' % (path, severity, message, issue_id) |
| 67 print >> sys.stderr, error | 69 print >> sys.stderr, error |
| 68 for attr in ['errorLine1', 'errorLine2']: | 70 for attr in ['errorLine1', 'errorLine2']: |
| 69 error_line = issue.getAttribute(attr) | 71 error_line = issue.getAttribute(attr) |
| 70 if error_line: | 72 if error_line: |
| 71 print >> sys.stderr, error_line | 73 print >> sys.stderr, error_line |
| 72 return len(issues) | 74 return len(issues) |
| 73 | 75 |
| 74 _ProcessConfigFile() | 76 _ProcessConfigFile() |
| 75 | 77 |
| 76 cmd = [ | 78 cmd = [ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 options.product_dir, src_dirs, options.classes_dir) | 150 options.product_dir, src_dirs, options.classes_dir) |
| 149 | 151 |
| 150 if options.stamp and not rc: | 152 if options.stamp and not rc: |
| 151 build_utils.Touch(options.stamp) | 153 build_utils.Touch(options.stamp) |
| 152 | 154 |
| 153 return rc | 155 return rc |
| 154 | 156 |
| 155 | 157 |
| 156 if __name__ == '__main__': | 158 if __name__ == '__main__': |
| 157 sys.exit(main(sys.argv)) | 159 sys.exit(main(sys.argv)) |
| OLD | NEW |