15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#!/usr/bin/env python 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Copyright 2014 The Chromium Authors. All rights reserved. 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# found in the LICENSE file. 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)import json 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)import urllib 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)from sys import exit as sys_exit 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Derived from region_data_constants.cc. 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)_COUNTRIES = [ 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ', 'AR', 'AS', 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'CO', 'CR', 'CS', 'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IS', 'IT', 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MN', 'MO', 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW' 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)] 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)_I18N_URL = 'https://i18napis.appspot.com/address/data/%s' 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)def main(): 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for country in _COUNTRIES: 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) url = _I18N_URL % country 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) try: 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) data = json.load(urllib.urlopen(url)) 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) except Exception as e: 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) print 'Error: could not load %s' % url 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return 1 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if 'require' in data: 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) print '%s: %s' % (country, data['require']) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return 0 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)if __name__ == '__main__': 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) sys_exit(main()) 52