| 1 |
#!/usr/bin/python |
|---|
| 2 |
# coding: utf-8 |
|---|
| 3 |
|
|---|
| 4 |
""" This file needs to be maintained by hand. |
|---|
| 5 |
|
|---|
| 6 |
see: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
|---|
| 7 |
see: http://www.iso.org/iso/iso3166_en_code_lists.txt |
|---|
| 8 |
""" |
|---|
| 9 |
|
|---|
| 10 |
country_code = {'AD': 'Andorra', |
|---|
| 11 |
'AE': 'United Arab Emirates', |
|---|
| 12 |
'AF': 'Afghanistan', |
|---|
| 13 |
'AG': 'Antigua and Barbuda', |
|---|
| 14 |
'AI': 'Anguilla', |
|---|
| 15 |
'AL': 'Albania', |
|---|
| 16 |
'AM': 'Armenia', |
|---|
| 17 |
'AN': 'Netherlands Antilles', |
|---|
| 18 |
'AO': 'Angola', |
|---|
| 19 |
'AQ': 'Antarctica', |
|---|
| 20 |
'AR': 'Argentina', |
|---|
| 21 |
'AS': 'American Samoa', |
|---|
| 22 |
'AT': 'Austria', |
|---|
| 23 |
'AU': 'Australia', |
|---|
| 24 |
'AW': 'Aruba', |
|---|
| 25 |
'AX': 'Aland Islands', # Ã |
|---|
| 26 |
land Islands |
|---|
| 27 |
'AZ': 'Azerbaijan', |
|---|
| 28 |
'BA': 'Bosnia and Herzegovina', |
|---|
| 29 |
'BB': 'Barbados', |
|---|
| 30 |
'BD': 'Bangladesh', |
|---|
| 31 |
'BE': 'Belgium', |
|---|
| 32 |
'BF': 'Burkina Faso', |
|---|
| 33 |
'BG': 'Bulgaria', |
|---|
| 34 |
'BH': 'Bahrain', |
|---|
| 35 |
'BI': 'Burundi', |
|---|
| 36 |
'BJ': 'Benin', |
|---|
| 37 |
'BM': 'Bermuda', |
|---|
| 38 |
'BN': 'Brunei Darussalam', |
|---|
| 39 |
'BO': 'Bolivia', |
|---|
| 40 |
'BR': 'Brazil', |
|---|
| 41 |
'BS': 'Bahamas', |
|---|
| 42 |
'BT': 'Bhutan', |
|---|
| 43 |
'BV': 'Bouvet Island', |
|---|
| 44 |
'BW': 'Botswana', |
|---|
| 45 |
'BY': 'Belarus', |
|---|
| 46 |
'BZ': 'Belize', |
|---|
| 47 |
'CA': 'Canada', |
|---|
| 48 |
'CC': 'Cocos (Keeling) Islands', |
|---|
| 49 |
'CD': 'Congo, the Democratic Republic of the', |
|---|
| 50 |
'CF': 'Central African Republic', |
|---|
| 51 |
'CG': 'Congo', |
|---|
| 52 |
'CH': 'Switzerland', |
|---|
| 53 |
'CI': 'Cote d\'Ivoire', # CÃŽte d'Ivoire |
|---|
| 54 |
'CK': 'Cook Islands', |
|---|
| 55 |
'CL': 'Chile', |
|---|
| 56 |
'CM': 'Cameroon', |
|---|
| 57 |
'CN': 'China', |
|---|
| 58 |
'CO': 'Colombia', |
|---|
| 59 |
'CR': 'Costa Rica', |
|---|
| 60 |
'CU': 'Cuba', |
|---|
| 61 |
'CV': 'Cape Verde', |
|---|
| 62 |
'CX': 'Christmas Island', |
|---|
| 63 |
'CY': 'Cyprus', |
|---|
| 64 |
'CZ': 'Czech Republic', |
|---|
| 65 |
'DE': 'Germany', |
|---|
| 66 |
'DJ': 'Djibouti', |
|---|
| 67 |
'DK': 'Denmark', |
|---|
| 68 |
'DM': 'Dominica', |
|---|
| 69 |
'DO': 'Dominican Republic', |
|---|
| 70 |
'DZ': 'Algeria', |
|---|
| 71 |
'EC': 'Ecuador', |
|---|
| 72 |
'EE': 'Estonia', |
|---|
| 73 |
'EG': 'Egypt', |
|---|
| 74 |
'EH': 'Western Sahara', |
|---|
| 75 |
'ER': 'Eritrea', |
|---|
| 76 |
'ES': 'Spain', |
|---|
| 77 |
'ET': 'Ethiopia', |
|---|
| 78 |
'FI': 'Finland', |
|---|
| 79 |
'FJ': 'Fiji', |
|---|
| 80 |
'FK': 'Falkland Islands (Malvinas)', |
|---|
| 81 |
'FM': 'Micronesia, Federated States of', |
|---|
| 82 |
'FO': 'Faroe Islands', |
|---|
| 83 |
'FR': 'France', |
|---|
| 84 |
'FX': 'France, Metropolitan', |
|---|
| 85 |
'GA': 'Gabon', |
|---|
| 86 |
'GB': 'United Kingdom', |
|---|
| 87 |
'GD': 'Grenada', |
|---|
| 88 |
'GE': 'Georgia', |
|---|
| 89 |
'GF': 'French Guiana', |
|---|
| 90 |
'GG': 'Guernsey', |
|---|
| 91 |
'GH': 'Ghana', |
|---|
| 92 |
'GI': 'Gibraltar', |
|---|
| 93 |
'GL': 'Greenland', |
|---|
| 94 |
'GM': 'Gambia', |
|---|
| 95 |
'GN': 'Guinea', |
|---|
| 96 |
'GP': 'Guadeloupe', |
|---|
| 97 |
'GQ': 'Equatorial Guinea', |
|---|
| 98 |
'GR': 'Greece', |
|---|
| 99 |
'GS': 'South Georgia and the South Sandwich Islands', |
|---|
| 100 |
'GT': 'Guatemala', |
|---|
| 101 |
'GU': 'Guam', |
|---|
| 102 |
'GW': 'Guinea-Bissau', |
|---|
| 103 |
'GY': 'Guyana', |
|---|
| 104 |
'HK': 'Hong Kong', |
|---|
| 105 |
'HM': 'Heard Island and McDonald Islands', |
|---|
| 106 |
'HN': 'Honduras', |
|---|
| 107 |
'HR': 'Croatia', |
|---|
| 108 |
'HT': 'Haiti', |
|---|
| 109 |
'HU': 'Hungary', |
|---|
| 110 |
'ID': 'Indonesia', |
|---|
| 111 |
'IE': 'Ireland', |
|---|
| 112 |
'IL': 'Israel', |
|---|
| 113 |
'IM': 'Isle of Man', |
|---|
| 114 |
'IN': 'India', |
|---|
| 115 |
'IO': 'British Indian Ocean Territory', |
|---|
| 116 |
'IQ': 'Iraq', |
|---|
| 117 |
'IR': 'Iran, Islamic Republic of', |
|---|
| 118 |
'IS': 'Iceland', |
|---|
| 119 |
'IT': 'Italy', |
|---|
| 120 |
'JE': 'Jersey', |
|---|
| 121 |
'JM': 'Jamaica', |
|---|
| 122 |
'JO': 'Jordan', |
|---|
| 123 |
'JP': 'Japan', |
|---|
| 124 |
'KE': 'Kenya', |
|---|
| 125 |
'KG': 'Kyrgyzstan', |
|---|
| 126 |
'KH': 'Cambodia', |
|---|
| 127 |
'KI': 'Kiribati', |
|---|
| 128 |
'KM': 'Comoros', |
|---|
| 129 |
'KN': 'Saint Kitts and Nevis', |
|---|
| 130 |
'KP': 'Korea, Democratic People\'s Republic of', |
|---|
| 131 |
'KR': 'Korea, Republic of', |
|---|
| 132 |
'KW': 'Kuwait', |
|---|
| 133 |
'KY': 'Cayman Islands', |
|---|
| 134 |
'KZ': 'Kazakhstan', |
|---|
| 135 |
'LA': 'Lao People\'s Democratic Republic', |
|---|
| 136 |
'LB': 'Lebanon', |
|---|
| 137 |
'LC': 'Saint Lucia', |
|---|
| 138 |
'LI': 'Liechtenstein', |
|---|
| 139 |
'LK': 'Sri Lanka', |
|---|
| 140 |
'LR': 'Liberia', |
|---|
| 141 |
'LS': 'Lesotho', |
|---|
| 142 |
'LT': 'Lithuania', |
|---|
| 143 |
'LU': 'Luxembourg', |
|---|
| 144 |
'LV': 'Latvia', |
|---|
| 145 |
'LY': 'Libyan Arab Jamahiriya', |
|---|
| 146 |
'MA': 'Morocco', |
|---|
| 147 |
'MC': 'Monaco', |
|---|
| 148 |
'MD': 'Moldova, Republic of', |
|---|
| 149 |
'ME': 'Montenegro', |
|---|
| 150 |
'MG': 'Madagascar', |
|---|
| 151 |
'MH': 'Marshall Islands', |
|---|
| 152 |
'MK': 'Macedonia, the former Yugoslav Republic of', |
|---|
| 153 |
'ML': 'Mali', |
|---|
| 154 |
'MM': 'Myanmar', |
|---|
| 155 |
'MN': 'Mongolia', |
|---|
| 156 |
'MO': 'Macao', |
|---|
| 157 |
'MP': 'Northern Mariana Islands', |
|---|
| 158 |
'MQ': 'Martinique', |
|---|
| 159 |
'MR': 'Mauritania', |
|---|
| 160 |
'MS': 'Montserrat', |
|---|
| 161 |
'MT': 'Malta', |
|---|
| 162 |
'MU': 'Mauritius', |
|---|
| 163 |
'MV': 'Maldives', |
|---|
| 164 |
'MW': 'Malawi', |
|---|
| 165 |
'MX': 'Mexico', |
|---|
| 166 |
'MY': 'Malaysia', |
|---|
| 167 |
'MZ': 'Mozambique', |
|---|
| 168 |
'NA': 'Namibia', |
|---|
| 169 |
'NC': 'New Caledonia', |
|---|
| 170 |
'NE': 'Niger', |
|---|
| 171 |
'NF': 'Norfolk Island', |
|---|
| 172 |
'NG': 'Nigeria', |
|---|
| 173 |
'NI': 'Nicaragua', |
|---|
| 174 |
'NL': 'Netherlands', |
|---|
| 175 |
'NO': 'Norway', |
|---|
| 176 |
'NP': 'Nepal', |
|---|
| 177 |
'NR': 'Nauru', |
|---|
| 178 |
'NU': 'Niue', |
|---|
| 179 |
'NZ': 'New Zealand', |
|---|
| 180 |
'OM': 'Oman', |
|---|
| 181 |
'PA': 'Panama', |
|---|
| 182 |
'PE': 'Peru', |
|---|
| 183 |
'PF': 'French Polynesia', |
|---|
| 184 |
'PG': 'Papua New Guinea', |
|---|
| 185 |
'PH': 'Philippines', |
|---|
| 186 |
'PK': 'Pakistan', |
|---|
| 187 |
'PL': 'Poland', |
|---|
| 188 |
'PM': 'Saint Pierre and Miquelon', |
|---|
| 189 |
'PN': 'Pitcairn', |
|---|
| 190 |
'PR': 'Puerto Rico', |
|---|
| 191 |
'PS': 'Palestinian Territory, Occupied', |
|---|
| 192 |
'PT': 'Portugal', |
|---|
| 193 |
'PW': 'Palau', |
|---|
| 194 |
'PY': 'Paraguay', |
|---|
| 195 |
'QA': 'Qatar', |
|---|
| 196 |
'RE': 'Reunion', # Réunion |
|---|
| 197 |
'RO': 'Romania', |
|---|
| 198 |
'RS': 'Serbia', |
|---|
| 199 |
'RU': 'Russian Federation', |
|---|
| 200 |
'RW': 'Rwanda', |
|---|
| 201 |
'SA': 'Saudi Arabia', |
|---|
| 202 |
'SB': 'Solomon Islands', |
|---|
| 203 |
'SC': 'Seychelles', |
|---|
| 204 |
'SD': 'Sudan', |
|---|
| 205 |
'SE': 'Sweden', |
|---|
| 206 |
'SG': 'Singapore', |
|---|
| 207 |
'SH': 'Saint Helena', |
|---|
| 208 |
'SI': 'Slovenia', |
|---|
| 209 |
'SJ': 'Svalbard and Jan Mayen', |
|---|
| 210 |
'SK': 'Slovakia', |
|---|
| 211 |
'SL': 'Sierra Leone', |
|---|
| 212 |
'SM': 'San Marino', |
|---|
| 213 |
'SN': 'Senegal', |
|---|
| 214 |
'SO': 'Somalia', |
|---|
| 215 |
'SR': 'Suriname', |
|---|
| 216 |
'ST': 'Sao Tome and Principe', |
|---|
| 217 |
'SV': 'El Salvador', |
|---|
| 218 |
'SY': 'Syrian Arab Republic', |
|---|
| 219 |
'SZ': 'Swaziland', |
|---|
| 220 |
'TC': 'Turks and Caicos Islands', |
|---|
| 221 |
'TD': 'Chad', |
|---|
| 222 |
'TF': 'French Southern Territories', |
|---|
| 223 |
'TG': 'Togo', |
|---|
| 224 |
'TH': 'Thailand', |
|---|
| 225 |
'TJ': 'Tajikistan', |
|---|
| 226 |
'TK': 'Tokelau', |
|---|
| 227 |
'TL': 'Timor-Leste', |
|---|
| 228 |
'TM': 'Turkmenistan', |
|---|
| 229 |
'TN': 'Tunisia', |
|---|
| 230 |
'TO': 'Tonga', |
|---|
| 231 |
'TR': 'Turkey', |
|---|
| 232 |
'TT': 'Trinidad and Tobago', |
|---|
| 233 |
'TV': 'Tuvalu', |
|---|
| 234 |
'TW': 'Taiwan, Province of China', |
|---|
| 235 |
'TZ': 'Tanzania, United Republic of', |
|---|
| 236 |
'UA': 'Ukraine', |
|---|
| 237 |
'UG': 'Uganda', |
|---|
| 238 |
#'UK': 'United Kingdom', |
|---|
| 239 |
'UM': 'United States Minor Outlying Islands', |
|---|
| 240 |
'US': 'United States', |
|---|
| 241 |
'UY': 'Uruguay', |
|---|
| 242 |
'UZ': 'Uzbekistan', |
|---|
| 243 |
'VA': 'Holy See (Vatican City State)', |
|---|
| 244 |
'VC': 'Saint Vincent and the Grenadines', |
|---|
| 245 |
'VE': 'Venezuela', |
|---|
| 246 |
'VG': 'Virgin Islands, British', |
|---|
| 247 |
'VI': 'Virgin Islands, U.S.', |
|---|
| 248 |
'VN': 'Viet Nam', |
|---|
| 249 |
'VU': 'Vanuatu', |
|---|
| 250 |
'WF': 'Wallis and Futuna', |
|---|
| 251 |
'WS': 'Samoa', |
|---|
| 252 |
'YE': 'Yemen', |
|---|
| 253 |
'YT': 'Mayotte', |
|---|
| 254 |
'YU': 'Yugoslavia', |
|---|
| 255 |
'ZA': 'South Africa', |
|---|
| 256 |
'ZM': 'Zambia', |
|---|
| 257 |
'ZW': 'Zimbabwe'} |
|---|
| 258 |
|
|---|
| 259 |
country_list = list(country_code.iteritems()) |
|---|
| 260 |
country_list.sort(key=lambda x: x[1]) |
|---|
| 261 |
# country_list.insert(1, country_list.pop(-1)) # fix à |
|---|
| 262 |
land Islands' position |
|---|
| 263 |
|
|---|
| 264 |
output = open('countries.py', 'w') |
|---|
| 265 |
|
|---|
| 266 |
output.write('from django.utils.translation import ugettext as _\n\n') |
|---|
| 267 |
output.write('COUNTRIES = (\n') |
|---|
| 268 |
for cc, name in country_list: |
|---|
| 269 |
output.write(" ('%s', _('%s')),\n" % (cc, name.encode('string-escape'))) |
|---|
| 270 |
|
|---|
| 271 |
output.write(" ('ZZ', _('Unknown or unspecified country')),\n") |
|---|
| 272 |
output.write(')\n') |
|---|
| 273 |
output.close() |
|---|