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 | |
59 message = issue.attributes['message'].value | 58 message = issue.attributes['message'].value |
60 location_elem = issue.getElementsByTagName('location')[0] | 59 location_elem = issue.getElementsByTagName('location')[0] |
61 path = location_elem.attributes['file'].value | 60 path = location_elem.attributes['file'].value |
62 line = location_elem.getAttribute('line') | 61 line = location_elem.getAttribute('line') |
63 if line: | 62 if line: |
64 error = '%s:%s %s: %s [%s]' % (path, line, severity, message, | 63 error = '%s:%s %s: %s [warning]' % (path, line, message, issue_id) |
65 issue_id) | |
66 else: | 64 else: |
67 # Issues in class files don't have a line number. | 65 # Issues in class files don't have a line number. |
68 error = '%s %s: %s [%s]' % (path, severity, message, issue_id) | 66 error = '%s %s: %s [warning]' % (path, message, issue_id) |
69 print >> sys.stderr, error | 67 print >> sys.stderr, error |
70 for attr in ['errorLine1', 'errorLine2']: | 68 for attr in ['errorLine1', 'errorLine2']: |
71 error_line = issue.getAttribute(attr) | 69 error_line = issue.getAttribute(attr) |
72 if error_line: | 70 if error_line: |
73 print >> sys.stderr, error_line | 71 print >> sys.stderr, error_line |
74 return len(issues) | 72 return len(issues) |
75 | 73 |
76 _ProcessConfigFile() | 74 _ProcessConfigFile() |
77 | 75 |
78 cmd = [ | 76 cmd = [ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 options.product_dir, src_dirs, options.classes_dir) | 148 options.product_dir, src_dirs, options.classes_dir) |
151 | 149 |
152 if options.stamp and not rc: | 150 if options.stamp and not rc: |
153 build_utils.Touch(options.stamp) | 151 build_utils.Touch(options.stamp) |
154 | 152 |
155 return rc | 153 return rc |
156 | 154 |
157 | 155 |
158 if __name__ == '__main__': | 156 if __name__ == '__main__': |
159 sys.exit(main(sys.argv)) | 157 sys.exit(main(sys.argv)) |
OLD | NEW |