| 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 """Add all generated lint_result.xml files to suppressions.xml""" | 7 """Add all generated lint_result.xml files to suppressions.xml""" | 
| 8 | 8 | 
| 9 # pylint: disable=no-member | 9 # pylint: disable=no-member | 
| 10 | 10 | 
| 11 | 11 | 
| 12 import collections | 12 import collections | 
| 13 import optparse | 13 import optparse | 
| 14 import os | 14 import os | 
| 15 import sys | 15 import sys | 
| 16 from xml.dom import minidom | 16 from xml.dom import minidom | 
| 17 | 17 | 
| 18 _BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | 18 _BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | 
| 19 sys.path.append(_BUILD_ANDROID_DIR) | 19 sys.path.append(_BUILD_ANDROID_DIR) | 
| 20 | 20 | 
| 21 from pylib import constants | 21 from pylib.constants import host_paths | 
| 22 | 22 | 
| 23 | 23 | 
| 24 _THIS_FILE = os.path.abspath(__file__) | 24 _THIS_FILE = os.path.abspath(__file__) | 
| 25 _CONFIG_PATH = os.path.join(os.path.dirname(_THIS_FILE), 'suppressions.xml') | 25 _CONFIG_PATH = os.path.join(os.path.dirname(_THIS_FILE), 'suppressions.xml') | 
| 26 _DOC = ( | 26 _DOC = ( | 
| 27     '\nSTOP! It looks like you want to suppress some lint errors:\n' | 27     '\nSTOP! It looks like you want to suppress some lint errors:\n' | 
| 28     '- Have you tried identifing the offending patch?\n' | 28     '- Have you tried identifing the offending patch?\n' | 
| 29     '  Ask the author for a fix and/or revert the patch.\n' | 29     '  Ask the author for a fix and/or revert the patch.\n' | 
| 30     '- It is preferred to add suppressions in the code instead of\n' | 30     '- It is preferred to add suppressions in the code instead of\n' | 
| 31     '  sweeping it under the rug here. See:\n\n' | 31     '  sweeping it under the rug here. See:\n\n' | 
| 32     '    http://developer.android.com/tools/debugging/improving-w-lint.html\n' | 32     '    http://developer.android.com/tools/debugging/improving-w-lint.html\n' | 
| 33     '\n' | 33     '\n' | 
| 34     'Still reading?\n' | 34     'Still reading?\n' | 
| 35     '- You can edit this file manually to suppress an issue\n' | 35     '- You can edit this file manually to suppress an issue\n' | 
| 36     '  globally if it is not applicable to the project.\n' | 36     '  globally if it is not applicable to the project.\n' | 
| 37     '- You can also automatically add issues found so for in the\n' | 37     '- You can also automatically add issues found so for in the\n' | 
| 38     '  build process by running:\n\n' | 38     '  build process by running:\n\n' | 
| 39     '    ' + os.path.relpath(_THIS_FILE, constants.DIR_SOURCE_ROOT) + '\n\n' | 39     '    ' + os.path.relpath(_THIS_FILE, host_paths.DIR_SOURCE_ROOT) + '\n\n' | 
| 40     '  which will generate this file (Comments are not preserved).\n' | 40     '  which will generate this file (Comments are not preserved).\n' | 
| 41     '  Note: PRODUCT_DIR will be substituted at run-time with actual\n' | 41     '  Note: PRODUCT_DIR will be substituted at run-time with actual\n' | 
| 42     '  directory path (e.g. out/Debug)\n' | 42     '  directory path (e.g. out/Debug)\n' | 
| 43 ) | 43 ) | 
| 44 | 44 | 
| 45 | 45 | 
| 46 _Issue = collections.namedtuple('Issue', ['severity', 'paths']) | 46 _Issue = collections.namedtuple('Issue', ['severity', 'paths']) | 
| 47 | 47 | 
| 48 | 48 | 
| 49 def _ParseConfigFile(config_path): | 49 def _ParseConfigFile(config_path): | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 108   _, args = parser.parse_args() | 108   _, args = parser.parse_args() | 
| 109 | 109 | 
| 110   if len(args) != 1 or not os.path.exists(args[0]): | 110   if len(args) != 1 or not os.path.exists(args[0]): | 
| 111     parser.error('Must provide RESULT-FILE') | 111     parser.error('Must provide RESULT-FILE') | 
| 112 | 112 | 
| 113   _Suppress(_CONFIG_PATH, args[0]) | 113   _Suppress(_CONFIG_PATH, args[0]) | 
| 114 | 114 | 
| 115 | 115 | 
| 116 if __name__ == '__main__': | 116 if __name__ == '__main__': | 
| 117   main() | 117   main() | 
| OLD | NEW | 
|---|