| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Verifies that GRD resource files define all the strings used by a given | 6 """Verifies that GRD resource files define all the strings used by a given |
| 7 set of source files. For file formats where it is not possible to infer which | 7 set of source files. For file formats where it is not possible to infer which |
| 8 strings represent message identifiers, localized strings should be explicitly | 8 strings represent message identifiers, localized strings should be explicitly |
| 9 annotated with the string "i18n-content", for example: | 9 annotated with the string "i18n-content", for example: |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 for f in args: | 151 for f in args: |
| 152 if not VerifyFile(f, all_resources, used_tags): | 152 if not VerifyFile(f, all_resources, used_tags): |
| 153 exit_code = 1 | 153 exit_code = 1 |
| 154 | 154 |
| 155 if options.strict: | 155 if options.strict: |
| 156 warnings = False | 156 warnings = False |
| 157 # Determining if a resource is being used in the Android app is tricky | 157 # Determining if a resource is being used in the Android app is tricky |
| 158 # because it requires annotating and parsing Android XML layout files. | 158 # because it requires annotating and parsing Android XML layout files. |
| 159 # For now, exclude Android strings from this check. | 159 # For now, exclude Android strings from this check. |
| 160 for tag in non_android_resources: | 160 for tag in non_android_resources: |
| 161 if tag.endswith("_GENERATED_AT_RUNTIME"): |
| 162 continue |
| 161 if tag not in used_tags: | 163 if tag not in used_tags: |
| 162 print ('%s/%s:0: warning: %s is defined but not used') % \ | 164 print ('%s/%s:0: warning: %s is defined but not used') % \ |
| 163 (os.getcwd(), sys.argv[2], tag) | 165 (os.getcwd(), sys.argv[2], tag) |
| 164 warnings = True | 166 warnings = True |
| 165 if warnings: | 167 if warnings: |
| 166 print WARNING_MESSAGE | 168 print WARNING_MESSAGE |
| 167 | 169 |
| 168 if exit_code == 0: | 170 if exit_code == 0: |
| 169 f = open(options.touch, 'a') | 171 f = open(options.touch, 'a') |
| 170 f.close() | 172 f.close() |
| 171 os.utime(options.touch, None) | 173 os.utime(options.touch, None) |
| 172 | 174 |
| 173 return exit_code | 175 return exit_code |
| 174 | 176 |
| 175 | 177 |
| 176 if __name__ == '__main__': | 178 if __name__ == '__main__': |
| 177 sys.exit(main()) | 179 sys.exit(main()) |
| OLD | NEW |