1# -*- coding: UTF-8 -*-
2
3from collections import namedtuple
4
5# https://www.iso.org/obp/ui/#iso:pub:PUB500001:en
6
7ISO3166 = namedtuple('ISO3166', 'iso2, country')
8ISO3166_LIST = [
9    ISO3166("unknown", _("Unknown")),
10    # Specific to pyChess: ISO3166("C", _("Computer")),
11    ISO3166("ad", _("Andorra")),
12    ISO3166("ae", _("United Arab Emirates")),
13    ISO3166("af", _("Afghanistan")),
14    ISO3166("ag", _("Antigua and Barbuda")),
15    ISO3166("ai", _("Anguilla")),
16    ISO3166("al", _("Albania")),
17    ISO3166("am", _("Armenia")),
18    # Discontinued: ISO3166("an", _("Netherlands Antilles")),
19    ISO3166("ao", _("Angola")),
20    ISO3166("aq", _("Antarctica")),
21    ISO3166("ar", _("Argentina")),
22    ISO3166("as", _("American Samoa")),
23    ISO3166("at", _("Austria")),
24    ISO3166("au", _("Australia")),
25    ISO3166("aw", _("Aruba")),
26    ISO3166("ax", _("Åland Islands")),
27    ISO3166("az", _("Azerbaijan")),
28    ISO3166("ba", _("Bosnia and Herzegovina")),
29    ISO3166("bb", _("Barbados")),
30    ISO3166("bd", _("Bangladesh")),
31    ISO3166("be", _("Belgium")),
32    ISO3166("bf", _("Burkina Faso")),
33    ISO3166("bg", _("Bulgaria")),
34    ISO3166("bh", _("Bahrain")),
35    ISO3166("bi", _("Burundi")),
36    ISO3166("bj", _("Benin")),
37    ISO3166("bl", _("Saint Barthélemy")),
38    ISO3166("bm", _("Bermuda")),
39    ISO3166("bn", _("Brunei Darussalam")),
40    ISO3166("bo", _("Bolivia (Plurinational State of)")),
41    ISO3166("bq", _("Bonaire, Sint Eustatius and Saba")),
42    ISO3166("br", _("Brazil")),
43    ISO3166("bs", _("Bahamas")),
44    ISO3166("bt", _("Bhutan")),
45    ISO3166("bv", _("Bouvet Island")),
46    ISO3166("bw", _("Botswana")),
47    ISO3166("by", _("Belarus")),
48    ISO3166("bz", _("Belize")),
49    ISO3166("ca", _("Canada")),
50    ISO3166("cc", _("Cocos (Keeling) Islands")),
51    ISO3166("cd", _("Congo (the Democratic Republic of the)")),
52    ISO3166("cf", _("Central African Republic")),
53    ISO3166("cg", _("Congo")),
54    ISO3166("ch", _("Switzerland")),
55    ISO3166("ci", _("Côte d'Ivoire")),
56    ISO3166("ck", _("Cook Islands")),
57    ISO3166("cl", _("Chile")),
58    ISO3166("cm", _("Cameroon")),
59    ISO3166("cn", _("China")),
60    ISO3166("co", _("Colombia")),
61    ISO3166("cr", _("Costa Rica")),
62    ISO3166("cu", _("Cuba")),
63    ISO3166("cv", _("Cabo Verde")),
64    ISO3166("cw", _("Curaçao")),
65    ISO3166("cx", _("Christmas Island")),
66    ISO3166("cy", _("Cyprus")),
67    ISO3166("cz", _("Czechia")),
68    ISO3166("de", _("Germany")),
69    ISO3166("dj", _("Djibouti")),
70    ISO3166("dk", _("Denmark")),
71    ISO3166("dm", _("Dominica")),
72    ISO3166("do", _("Dominican Republic")),
73    ISO3166("dz", _("Algeria")),
74    ISO3166("ec", _("Ecuador")),
75    ISO3166("ee", _("Estonia")),
76    ISO3166("eg", _("Egypt")),
77    ISO3166("eh", _("Western Sahara")),
78    ISO3166("er", _("Eritrea")),
79    ISO3166("es", _("Spain")),
80    ISO3166("et", _("Ethiopia")),
81    ISO3166("fi", _("Finland")),
82    ISO3166("fj", _("Fiji")),
83    ISO3166("fk", _("Falkland Islands [Malvinas]")),
84    ISO3166("fm", _("Micronesia (Federated States of)")),
85    ISO3166("fo", _("Faroe Islands")),
86    ISO3166("fr", _("France")),
87    ISO3166("ga", _("Gabon")),
88    ISO3166("gb", _("United Kingdom of Great Britain and Northern Ireland")),
89    ISO3166("gd", _("Grenada")),
90    ISO3166("ge", _("Georgia")),
91    ISO3166("gf", _("French Guiana")),
92    ISO3166("gg", _("Guernsey")),
93    ISO3166("gh", _("Ghana")),
94    ISO3166("gi", _("Gibraltar")),
95    ISO3166("gl", _("Greenland")),
96    ISO3166("gm", _("Gambia")),
97    ISO3166("gn", _("Guinea")),
98    ISO3166("gp", _("Guadeloupe")),
99    ISO3166("gq", _("Equatorial Guinea")),
100    ISO3166("gr", _("Greece")),
101    ISO3166("gs", _("South Georgia and the South Sandwich Islands")),
102    ISO3166("gt", _("Guatemala")),
103    ISO3166("gu", _("Guam")),
104    ISO3166("gw", _("Guinea-Bissau")),
105    ISO3166("gy", _("Guyana")),
106    ISO3166("hk", _("Hong Kong")),
107    ISO3166("hm", _("Heard Island and McDonald Islands")),
108    ISO3166("hn", _("Honduras")),
109    ISO3166("hr", _("Croatia")),
110    ISO3166("ht", _("Haiti")),
111    ISO3166("hu", _("Hungary")),
112    ISO3166("id", _("Indonesia")),
113    ISO3166("ie", _("Ireland")),
114    ISO3166("il", _("Israel")),
115    ISO3166("im", _("Isle of Man")),
116    ISO3166("in", _("India")),
117    ISO3166("io", _("British Indian Ocean Territory")),
118    ISO3166("iq", _("Iraq")),
119    ISO3166("ir", _("Iran (Islamic Republic of)")),
120    ISO3166("is", _("Iceland")),
121    ISO3166("it", _("Italy")),
122    ISO3166("je", _("Jersey")),
123    ISO3166("jm", _("Jamaica")),
124    ISO3166("jo", _("Jordan")),
125    ISO3166("jp", _("Japan")),
126    ISO3166("ke", _("Kenya")),
127    ISO3166("kg", _("Kyrgyzstan")),
128    ISO3166("kh", _("Cambodia")),
129    ISO3166("ki", _("Kiribati")),
130    ISO3166("km", _("Comoros")),
131    ISO3166("kn", _("Saint Kitts and Nevis")),
132    ISO3166("kp", _("Korea (the Democratic People's Republic of)")),
133    ISO3166("kr", _("Korea (the Republic of)")),
134    ISO3166("kw", _("Kuwait")),
135    ISO3166("ky", _("Cayman Islands")),
136    ISO3166("kz", _("Kazakhstan")),
137    ISO3166("la", _("Lao People's Democratic Republic")),
138    ISO3166("lb", _("Lebanon")),
139    ISO3166("lc", _("Saint Lucia")),
140    ISO3166("li", _("Liechtenstein")),
141    ISO3166("lk", _("Sri Lanka")),
142    ISO3166("lr", _("Liberia")),
143    ISO3166("ls", _("Lesotho")),
144    ISO3166("lt", _("Lithuania")),
145    ISO3166("lu", _("Luxembourg")),
146    ISO3166("lv", _("Latvia")),
147    ISO3166("ly", _("Libya")),
148    ISO3166("ma", _("Morocco")),
149    ISO3166("mc", _("Monaco")),
150    ISO3166("md", _("Moldova (the Republic of)")),
151    ISO3166("me", _("Montenegro")),
152    ISO3166("mf", _("Saint Martin (French part)")),
153    ISO3166("mg", _("Madagascar")),
154    ISO3166("mh", _("Marshall Islands")),
155    ISO3166("mk", _("Macedonia (the former Yugoslav Republic of)")),
156    ISO3166("ml", _("Mali")),
157    ISO3166("mm", _("Myanmar")),
158    ISO3166("mn", _("Mongolia")),
159    ISO3166("mo", _("Macao")),
160    ISO3166("mp", _("Northern Mariana Islands")),
161    ISO3166("mq", _("Martinique")),
162    ISO3166("mr", _("Mauritania")),
163    ISO3166("ms", _("Montserrat")),
164    ISO3166("mt", _("Malta")),
165    ISO3166("mu", _("Mauritius")),
166    ISO3166("mv", _("Maldives")),
167    ISO3166("mw", _("Malawi")),
168    ISO3166("mx", _("Mexico")),
169    ISO3166("my", _("Malaysia")),
170    ISO3166("mz", _("Mozambique")),
171    ISO3166("na", _("Namibia")),
172    ISO3166("nc", _("New Caledonia")),
173    ISO3166("ne", _("Niger")),
174    ISO3166("nf", _("Norfolk Island")),
175    ISO3166("ng", _("Nigeria")),
176    ISO3166("ni", _("Nicaragua")),
177    ISO3166("nl", _("Netherlands")),
178    ISO3166("no", _("Norway")),
179    ISO3166("np", _("Nepal")),
180    ISO3166("nr", _("Nauru")),
181    ISO3166("nu", _("Niue")),
182    ISO3166("nz", _("New Zealand")),
183    ISO3166("om", _("Oman")),
184    ISO3166("pa", _("Panama")),
185    ISO3166("pe", _("Peru")),
186    ISO3166("pf", _("French Polynesia")),
187    ISO3166("pg", _("Papua New Guinea")),
188    ISO3166("ph", _("Philippines")),
189    ISO3166("pk", _("Pakistan")),
190    ISO3166("pl", _("Poland")),
191    ISO3166("pm", _("Saint Pierre and Miquelon")),
192    ISO3166("pn", _("Pitcairn")),
193    ISO3166("pr", _("Puerto Rico")),
194    ISO3166("ps", _("Palestine, State of")),
195    ISO3166("pt", _("Portugal")),
196    ISO3166("pw", _("Palau")),
197    ISO3166("py", _("Paraguay")),
198    ISO3166("qa", _("Qatar")),
199    ISO3166("re", _("Réunion")),
200    ISO3166("ro", _("Romania")),
201    ISO3166("rs", _("Serbia")),
202    ISO3166("ru", _("Russian Federation")),
203    ISO3166("rw", _("Rwanda")),
204    ISO3166("sa", _("Saudi Arabia")),
205    ISO3166("sb", _("Solomon Islands")),
206    ISO3166("sc", _("Seychelles")),
207    ISO3166("sd", _("Sudan")),
208    ISO3166("se", _("Sweden")),
209    ISO3166("sg", _("Singapore")),
210    ISO3166("sh", _("Saint Helena, Ascension and Tristan da Cunha")),
211    ISO3166("si", _("Slovenia")),
212    ISO3166("sj", _("Svalbard and Jan Mayen")),
213    ISO3166("sk", _("Slovakia")),
214    ISO3166("sl", _("Sierra Leone")),
215    ISO3166("sm", _("San Marino")),
216    ISO3166("sn", _("Senegal")),
217    ISO3166("so", _("Somalia")),
218    ISO3166("sr", _("Suriname")),
219    ISO3166("ss", _("South Sudan")),
220    ISO3166("st", _("Sao Tome and Principe")),
221    ISO3166("sv", _("El Salvador")),
222    ISO3166("sx", _("Sint Maarten (Dutch part)")),
223    ISO3166("sy", _("Syrian Arab Republic")),
224    ISO3166("sz", _("Eswatini")),
225    ISO3166("tc", _("Turks and Caicos Islands")),
226    ISO3166("td", _("Chad")),
227    ISO3166("tf", _("French Southern Territories")),
228    ISO3166("tg", _("Togo")),
229    ISO3166("th", _("Thailand")),
230    ISO3166("tj", _("Tajikistan")),
231    ISO3166("tk", _("Tokelau")),
232    ISO3166("tl", _("Timor-Leste")),
233    ISO3166("tm", _("Turkmenistan")),
234    ISO3166("tn", _("Tunisia")),
235    ISO3166("to", _("Tonga")),
236    # Discontinued: ISO3166("tp", _("East Timor")),
237    ISO3166("tr", _("Turkey")),
238    ISO3166("tt", _("Trinidad and Tobago")),
239    ISO3166("tv", _("Tuvalu")),
240    ISO3166("tw", _("Taiwan (Province of China)")),
241    ISO3166("tz", _("Tanzania, United Republic of")),
242    ISO3166("ua", _("Ukraine")),
243    ISO3166("ug", _("Uganda")),
244    ISO3166("um", _("United States Minor Outlying Islands")),
245    ISO3166("us", _("United States of America")),
246    ISO3166("uy", _("Uruguay")),
247    ISO3166("uz", _("Uzbekistan")),
248    ISO3166("va", _("Holy See")),
249    ISO3166("vc", _("Saint Vincent and the Grenadines")),
250    ISO3166("ve", _("Venezuela (Bolivarian Republic of)")),
251    ISO3166("vg", _("Virgin Islands (British)")),
252    ISO3166("vi", _("Virgin Islands (U.S.)")),
253    ISO3166("vn", _("Viet Nam")),
254    ISO3166("vu", _("Vanuatu")),
255    ISO3166("wf", _("Wallis and Futuna")),
256    ISO3166("ws", _("Samoa")),
257    ISO3166("ye", _("Yemen")),
258    ISO3166("yt", _("Mayotte")),
259    # Discontinued: ISO3166("yu", _("Yugoslavia")),
260    ISO3166("za", _("South Africa")),
261    ISO3166("zm", _("Zambia")),
262    ISO3166("zw", _("Zimbabwe"))
263]
264
265# Bubble sort for the translated countries
266for i in range(len(ISO3166_LIST) - 1, 1, - 1):
267    for j in range(1, i - 1):
268        if ISO3166_LIST[i].country < ISO3166_LIST[j].country:
269            tmp = ISO3166_LIST[i]
270            ISO3166_LIST[i] = ISO3166_LIST[j]
271            ISO3166_LIST[j] = tmp
272