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