Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | |
|
Nico
2017/03/30 15:31:47
nit: add shebang line, make file executable
slan
2017/03/30 15:49:02
Done.
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Ensures that Chromecast developers are notified of locale changes.""" | |
| 6 | |
| 7 import argparse | |
| 8 import sys | |
| 9 | |
| 10 CAST_LOCALES = [ | |
| 11 'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'en-US', | |
| 12 'es-419', 'es', 'et', 'fa', 'fake-bidi', 'fi', 'fil', 'fr', 'gu', 'he', | |
| 13 'hi', 'hr', 'hu', 'id', 'it', 'ja', 'kn', 'ko', 'lt', 'lv', 'ml', 'mr', | |
| 14 'ms', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sl', 'sr', | |
| 15 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk', 'vi', 'zh-CN', 'zh-TW' | |
| 16 ] | |
| 17 | |
| 18 | |
| 19 # Chromecast OWNERS need to know if the list of locales used in | |
| 20 # //build/config/locales.gni changes, so that the Chromecast build process | |
| 21 # can be updated accordingly when it does. | |
| 22 # | |
| 23 # This script runs a check to verify that the list of locales maintained in GN | |
| 24 # matches CAST_LOCALES above. If a CL changes that list, it must also change | |
| 25 # CAST_LOCALES in this file to make the Cast trybot pass. This change will | |
| 26 # require adding a //chromecast OWNER to the change, keeping the team aware of | |
| 27 # any locale changes. | |
| 28 def main(): | |
| 29 parser = argparse.ArgumentParser() | |
| 30 parser.add_argument('locales', type=str, nargs='+', | |
| 31 help='Locales from the GN locale list') | |
| 32 parser.add_argument('--touch-file', '-t', type=str, required=True, | |
| 33 help='The script will touch this file if successful.') | |
| 34 args = parser.parse_args() | |
| 35 | |
| 36 if set(CAST_LOCALES) == set(args.locales): | |
| 37 open(args.touch_file, 'w') | |
| 38 return 0 | |
| 39 | |
| 40 # The lists do not match. Compute the difference and log it to the developer. | |
| 41 removed_locales = set(CAST_LOCALES) - set(args.locales) | |
| 42 added_locales = set(args.locales) - set(CAST_LOCALES) | |
| 43 | |
| 44 print 'CAST_LOCALES no longer matches the locales list from GN!' | |
| 45 if removed_locales: | |
| 46 print 'These locales have been removed: {}'.format(list(removed_locales)) | |
| 47 if added_locales: | |
| 48 print 'These locales have been added: {}'.format(list(added_locales)) | |
| 49 print ('Please update CAST_LOCALES in {file} and add a reviewer from ' | |
| 50 '//chromecast/OWNERS to your CL. ').format(file=__file__) | |
| 51 return -1 | |
|
Nico
2017/03/30 15:31:47
nit: 1 is a more common "failed" exit code
slan
2017/03/30 15:49:01
Done.
| |
| 52 | |
|
Nico
2017/03/30 15:31:47
nit: two blank lines between toplevel things
slan
2017/03/30 15:49:02
Done.
| |
| 53 if __name__ == '__main__': | |
| 54 sys.exit(main()) | |
| OLD | NEW |