| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 a given messages.json file defines all the strings used by the | 6 """Verifies that a given messages.json file defines all the strings used by the |
| 7 a given set of files. For file formats where it is not possible to infer which | 7 a given set of 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 |
| 11 LocalizeString(/*i18n-content*/"PRODUCT_NAME"); | 11 LocalizeString(/*i18n-content*/"PRODUCT_NAME"); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 (os.getcwd(), filename, i + 1, tag) | 71 (os.getcwd(), filename, i + 1, tag) |
| 72 if not matches: | 72 if not matches: |
| 73 print '%s/%s:0: warning: No tags found' % (os.getcwd(), filename) | 73 print '%s/%s:0: warning: No tags found' % (os.getcwd(), filename) |
| 74 f.close() | 74 f.close() |
| 75 return result | 75 return result |
| 76 | 76 |
| 77 | 77 |
| 78 def main(): | 78 def main(): |
| 79 if len(sys.argv) < 4: | 79 if len(sys.argv) < 4: |
| 80 print 'Usage: verify-webapp.py <touch> <messages> <message_users...>' | 80 print 'Usage: verify-webapp.py <touch> <messages> <message_users...>' |
| 81 sys.exit(1) | 81 return 1 |
| 82 | 82 |
| 83 touch_file = sys.argv[1] | 83 touch_file = sys.argv[1] |
| 84 messages = json.load(open(sys.argv[2], 'r')) | 84 messages = json.load(open(sys.argv[2], 'r')) |
| 85 exit_code = 0 | 85 exit_code = 0 |
| 86 for f in sys.argv[3:]: | 86 for f in sys.argv[3:]: |
| 87 if not CheckFileForUnknownTag(f, messages): | 87 if not CheckFileForUnknownTag(f, messages): |
| 88 exit_code = 1 | 88 exit_code = 1 |
| 89 | 89 |
| 90 warnings = False | 90 warnings = False |
| 91 for tag in messages: | 91 for tag in messages: |
| 92 if tag not in all_tags: | 92 if tag not in all_tags: |
| 93 print ('%s/%s:0: warning: %s is defined but not used') % \ | 93 print ('%s/%s:0: warning: %s is defined but not used') % \ |
| 94 (os.getcwd(), sys.argv[2], tag) | 94 (os.getcwd(), sys.argv[2], tag) |
| 95 warnings = True | 95 warnings = True |
| 96 if warnings: | 96 if warnings: |
| 97 print WARNING_MESSAGE | 97 print WARNING_MESSAGE |
| 98 | 98 |
| 99 if exit_code == 0: | 99 if exit_code == 0: |
| 100 f = open(touch_file, 'a') | 100 f = open(touch_file, 'a') |
| 101 f.close() | 101 f.close() |
| 102 os.utime(touch_file, None) | 102 os.utime(touch_file, None) |
| 103 | 103 |
| 104 sys.exit(exit_code) | 104 return exit_code |
| 105 | 105 |
| 106 | 106 |
| 107 if __name__ == '__main__': | 107 if __name__ == '__main__': |
| 108 main() | 108 sys.exit(main()) |
| OLD | NEW |