hdx-python-country 3.9.3__tar.gz → 3.9.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/PKG-INFO +2 -2
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/documentation/index.md +6 -5
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/pyproject.toml +1 -1
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/requirements.txt +10 -12
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +7 -7
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/country.py +49 -15
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/Countries_UZB_Deleted.csv +7 -7
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/test_country.py +157 -19
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/.coveragerc +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/.gitignore +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/.pre-commit-config.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/LICENSE +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/README.md +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/documentation/mkdocs.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/hatch.toml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/pytest.ini +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/ruff.toml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/adminlevel.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/currency.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/int_timestamp.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/wfp_api.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_List_1.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_List_2.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/conftest.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/test_adminlevel.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/test_currency.py +0 -0
- {hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-country
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.5
|
|
4
4
|
Summary: HDX Python country code and exchange rate (fx) utilities
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-country
|
|
6
6
|
Author: Michael Rans
|
|
@@ -25,7 +25,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Requires-Python: >=3.8
|
|
28
|
-
Requires-Dist: hdx-python-utilities>=3.8.
|
|
28
|
+
Requires-Dist: hdx-python-utilities>=3.8.7
|
|
29
29
|
Requires-Dist: libhxl>=5.2.2
|
|
30
30
|
Requires-Dist: tenacity
|
|
31
31
|
Provides-Extra: dev
|
|
@@ -70,9 +70,10 @@ The usage of the country mappings functionality is best illustrated by some exam
|
|
|
70
70
|
|
|
71
71
|
from hdx.location.country import Country
|
|
72
72
|
|
|
73
|
-
Country.countriesdata(use_live=False, country_name_overrides={"PSE": "oPt"})
|
|
74
|
-
# Set up
|
|
75
|
-
#
|
|
73
|
+
Country.countriesdata(include_unofficial=True, use_live=False, country_name_overrides={"PSE": "oPt"})
|
|
74
|
+
# Set up including unofficial alpha2 (eg. AN) and alpha3 codes (eg. XKX)
|
|
75
|
+
# Use non live data from repo and override default country name
|
|
76
|
+
# (Leaving out this step will exclude unofficial alpha codes, use live data and no overrides)
|
|
76
77
|
Country.get_country_name_from_iso3("jpn", use_live=False) # returns "Japan"
|
|
77
78
|
Country.get_country_name_from_iso3("vEn", formal=True) # returns "the Bolivarian Republic of Venezuela"
|
|
78
79
|
# uselive=False forces the use of internal files instead of accessing the live feeds.
|
|
@@ -95,9 +96,9 @@ The usage of the country mappings functionality is best illustrated by some exam
|
|
|
95
96
|
# "#country+alt+i_fr+name+v_m49": "Japon", "#country+alt+i_fr+name+v_unterm": "Japon",
|
|
96
97
|
# "#country+alt+i_ru+name+v_m49": "Япония", "#country+alt+i_ru+name+v_unterm": "Япония",
|
|
97
98
|
# "#country+alt+i_zh+name+v_m49": "日本", "#country+alt+i_zh+name+v_unterm": "日本",
|
|
98
|
-
# "#country+alt+name+v_dgacm": "", "#country+alt+name+
|
|
99
|
+
# "#country+alt+name+v_dgacm": "", "#country+alt+name+v_hpctools": "",
|
|
99
100
|
# "#country+alt+name+v_iso": "", "#country+alt+name+v_reliefweb": "",
|
|
100
|
-
# "#country+code+num+v_m49": "392", "#country+code+
|
|
101
|
+
# "#country+code+num+v_m49": "392", "#country+code+v_hpctools": "112",
|
|
101
102
|
# "#country+code+v_iso2": "JP", "#country+code+v_iso3": "JPN",
|
|
102
103
|
# "#country+code+v_reliefweb": "128", "#country+formal+i_en+name+v_unterm": "Japan",
|
|
103
104
|
# "#country+name+preferred": "Japan", "#country+name+short+v_reliefweb": "",
|
|
@@ -30,8 +30,6 @@ colorama==0.4.6
|
|
|
30
30
|
# via mkdocs-material
|
|
31
31
|
coverage==7.8.0
|
|
32
32
|
# via pytest-cov
|
|
33
|
-
cydifflib==1.2.0
|
|
34
|
-
# via hdx-python-utilities
|
|
35
33
|
distlib==0.3.9
|
|
36
34
|
# via virtualenv
|
|
37
35
|
et-xmlfile==2.0.0
|
|
@@ -42,7 +40,7 @@ frictionless==5.18.1
|
|
|
42
40
|
# via hdx-python-utilities
|
|
43
41
|
ghp-import==2.1.0
|
|
44
42
|
# via mkdocs
|
|
45
|
-
hdx-python-utilities==3.8.
|
|
43
|
+
hdx-python-utilities==3.8.7
|
|
46
44
|
# via hdx-python-country (pyproject.toml)
|
|
47
45
|
humanize==4.12.3
|
|
48
46
|
# via frictionless
|
|
@@ -50,7 +48,7 @@ identify==2.6.10
|
|
|
50
48
|
# via pre-commit
|
|
51
49
|
idna==3.10
|
|
52
50
|
# via requests
|
|
53
|
-
ijson==3.
|
|
51
|
+
ijson==3.4.0
|
|
54
52
|
# via hdx-python-utilities
|
|
55
53
|
iniconfig==2.1.0
|
|
56
54
|
# via pytest
|
|
@@ -95,7 +93,7 @@ mergedeep==1.3.4
|
|
|
95
93
|
# via
|
|
96
94
|
# mkdocs
|
|
97
95
|
# mkdocs-get-deps
|
|
98
|
-
mkapi==4.
|
|
96
|
+
mkapi==4.4.0
|
|
99
97
|
# via hdx-python-country (pyproject.toml)
|
|
100
98
|
mkdocs==1.6.1
|
|
101
99
|
# via
|
|
@@ -103,7 +101,7 @@ mkdocs==1.6.1
|
|
|
103
101
|
# mkdocs-material
|
|
104
102
|
mkdocs-get-deps==0.2.0
|
|
105
103
|
# via mkdocs
|
|
106
|
-
mkdocs-material==9.6.
|
|
104
|
+
mkdocs-material==9.6.14
|
|
107
105
|
# via mkapi
|
|
108
106
|
mkdocs-material-extensions==1.3.1
|
|
109
107
|
# via mkdocs-material
|
|
@@ -121,11 +119,11 @@ pathspec==0.12.1
|
|
|
121
119
|
# via mkdocs
|
|
122
120
|
petl==1.7.16
|
|
123
121
|
# via frictionless
|
|
124
|
-
platformdirs==4.3.
|
|
122
|
+
platformdirs==4.3.8
|
|
125
123
|
# via
|
|
126
124
|
# mkdocs-get-deps
|
|
127
125
|
# virtualenv
|
|
128
|
-
pluggy==1.
|
|
126
|
+
pluggy==1.6.0
|
|
129
127
|
# via pytest
|
|
130
128
|
ply==3.11
|
|
131
129
|
# via
|
|
@@ -170,7 +168,7 @@ pyyaml==6.0.2
|
|
|
170
168
|
# pymdown-extensions
|
|
171
169
|
# pyyaml-env-tag
|
|
172
170
|
# tableschema-to-template
|
|
173
|
-
pyyaml-env-tag==
|
|
171
|
+
pyyaml-env-tag==1.1
|
|
174
172
|
# via mkdocs
|
|
175
173
|
ratelimit==2.2.1
|
|
176
174
|
# via hdx-python-utilities
|
|
@@ -190,7 +188,7 @@ rfc3986==2.0.0
|
|
|
190
188
|
# via frictionless
|
|
191
189
|
rich==14.0.0
|
|
192
190
|
# via typer
|
|
193
|
-
rpds-py==0.
|
|
191
|
+
rpds-py==0.25.0
|
|
194
192
|
# via
|
|
195
193
|
# jsonschema
|
|
196
194
|
# referencing
|
|
@@ -214,7 +212,7 @@ tenacity==9.1.2
|
|
|
214
212
|
# via hdx-python-country (pyproject.toml)
|
|
215
213
|
text-unidecode==1.3
|
|
216
214
|
# via python-slugify
|
|
217
|
-
typer==0.15.
|
|
215
|
+
typer==0.15.4
|
|
218
216
|
# via frictionless
|
|
219
217
|
typing-extensions==4.13.2
|
|
220
218
|
# via
|
|
@@ -236,7 +234,7 @@ urllib3==2.4.0
|
|
|
236
234
|
# requests
|
|
237
235
|
validators==0.35.0
|
|
238
236
|
# via frictionless
|
|
239
|
-
virtualenv==20.31.
|
|
237
|
+
virtualenv==20.31.2
|
|
240
238
|
# via pre-commit
|
|
241
239
|
watchdog==6.0.0
|
|
242
240
|
# via mkdocs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
ID,RW ID,m49 numerical code,
|
|
2
|
-
#meta +id,#country +code +v_reliefweb,#country +code +num +v_m49,#country +code +
|
|
1
|
+
ID,RW ID,m49 numerical code,HPC Tools API ID,Appears in UNTERM list,Appears in DGACM list,Independent,Deprecated,Has HRP,In GHO,ISO 3166-1 Alpha 2-Codes,ISO 3166-1 Alpha 3-Codes,x Alpha2 codes,x Alpha3 codes,Preferred Term,ISO Alt Term,DGACM Alt Term,HPC Tools Alt Term,RW Short Name,RW API Alt Term,English Short,French Short,Spanish Short,Russian Short,Chinese Short,Arabic Short,English Formal,M49 English,M49 French,M49 Spanish,M49 Russian,M49 Chinese,M49 Arabic,Admin Level,Latitude,Longitude,Region Code,Region Name,Sub-region Code,Sub-region Name,Intermediate Region Code,Intermediate Region Name,Regex,World Bank Income Level,Currency,Reference Period Start,Concatenation
|
|
2
|
+
#meta +id,#country +code +v_reliefweb,#country +code +num +v_m49,#country +code +v_hpctools,,,#meta+independent+bool,#meta+deprecated+bool,#indicator+hrp+bool,#indicator+gho+bool,#country +code +v_iso2,#country +code +v_iso3,#country +code +alpha2,#country +code +alpha3,#country +name +preferred,#country +name +alt +v_iso,#country +name +alt +v_dgacm,#country +name +alt +v_hpctools,#country +name +short +v_reliefweb,#country +name +alt +v_reliefweb,#country +name +i_en +alt +v_unterm,#country +name +i_fr +alt +v_unterm,#country +name +i_es +alt +v_unterm,#country +name +i_ru +alt +v_unterm,#country +name +i_zh +alt +v_unterm,#country +name +i_ar +alt +v_unterm,#country +name +i_en +formal +v_unterm,#country +name +i_en +alt +v_m49,#country +name +i_fr +alt +v_m49,#country +name +i_es +alt +v_m49,#country +name +i_ru +alt +v_m49,#country +name +i_zh +alt +v_m49,#country +name +i_ar +alt +v_m49,#geo +admin_level,#geo +lat,#geo +lon,#region +main +code,#region +main +name +preferred,#region +sub +code,#region +sub +name +preferred,#region +intermediate +code,#region +intermediate +name +preferred,#country +regex,#indicator+incomelevel,#currency +code,#date+start,
|
|
3
3
|
1,13,4,1,Y,Y,Y,N,Y,Y,AF,AFG,,,Afghanistan,,,,,,Afghanistan,Afghanistan,Afganistán,Афганистан,阿富汗,أفغانستان,the Islamic Republic of Afghanistan,Afghanistan,Afghanistan,Afganistán,Афганистан,阿富汗,أفغانستان,0,33.83147477,66.02621828,142,Asia,34,Southern Asia,,,afghan,Low,AFN,2004-01-26,1 - Afghanistan
|
|
4
4
|
2,14,248,2,,,N,N,,,AX,ALA,,,Åland Islands,,,,,Aland Islands (Finland),Åland Islands,,,,,,,Åland Islands,Îles d’Åland,Islas Åland,Аландских островов,奥兰群岛,جزر ألاند,0,60.18121338,19.89649072,150,Europe,154,Northern Europe,,,^[å|a]land,,EUR,2004-02-13,2 - Åland Islands
|
|
5
5
|
3,15,8,3,Y,Y,Y,N,,,AL,ALB,,,Albania,,,,,,Albania,Albanie,Albania,Албания,阿尔巴尼亚,ألبانيا,the Republic of Albania,Albania,Albanie,Albania,Албания,阿尔巴尼亚,ألبانيا,0,41.13180899,20.06882519,150,Europe,39,Southern Europe,,,albania,Upper middle,ALL,1974-01-01,3 - Albania
|
|
@@ -105,7 +105,7 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
105
105
|
103,119,356,103,Y,Y,Y,N,,,IN,IND,,,India,,,,,,India,Inde,India,Индия,印度,الهند,the Republic of India,India,Inde,India,Индия,印度,الهند,0,22.37137039,79.32792202,142,Asia,34,Southern Asia,,,^(?!\D*(?:bassas))\D*india(?!.*ocea)(?!na),Lower middle,INR,1975-01-01,103 - India
|
|
106
106
|
104,120,360,104,Y,Y,Y,N,,,ID,IDN,,,Indonesia,,,,,,Indonesia,Indonésie,Indonesia,Индонезия,印度尼西亚,إندونيسيا,the Republic of Indonesia,Indonesia,Indonésie,Indonesia,Индонезия,印度尼西亚,إندونيسيا,0,-2.21433486,117.2844335,142,Asia,35,South-eastern Asia,,,indonesia,Upper middle,IDR,1974-01-01,104 - Indonesia
|
|
107
107
|
105,121,364,105,Y,Y,Y,N,,Y,IR,IRN,,,Iran (Islamic Republic of),,,"Iran, Islamic Republic of",Iran,,Iran (Islamic Republic of),Iran (République islamique d'),Irán (República Islámica del),Иран (Исламская Республика),伊朗伊斯兰共和国,إيران (جمهورية - الإسلامية),the Islamic Republic of Iran,Iran (Islamic Republic of),Iran (République islamique d’),Irán (República Islámica del),Иран (Исламская Республика),伊朗伊斯兰共和国,إيران (جمهورية - الإسلامية),0,32.57533772,54.2973284,142,Asia,34,Southern Asia,,,\biran|persia,Lower middle,IRR,1974-01-01,105 - Iran (Islamic Republic of)
|
|
108
|
-
106,122,368,106,Y,Y,Y,N
|
|
108
|
+
106,122,368,106,Y,Y,Y,N,,,IQ,IRQ,,,Iraq,,,,,,Iraq,Iraq,Iraq,Ирак,伊拉克,العراق,the Republic of Iraq,Iraq,Iraq,Iraq,Ирак,伊拉克,العراق,0,33.04497404,43.77207391,142,Asia,145,Western Asia,,,\biraq|mesopotamia,Upper middle,IQD,1974-01-01,106 - Iraq
|
|
109
109
|
107,123,372,107,Y,Y,Y,N,,,IE,IRL,,,Ireland,,,,,,Ireland,Irlande,Irlanda,Ирландия,爱尔兰,أيرلندا,Ireland,Ireland,Irlande,Irlanda,Ирландия,爱尔兰,آيرلندا,0,53.16969376,-8.154213185,150,Europe,154,Northern Europe,,,^(?!.*north).*\bireland,High,EUR,1974-01-01,107 - Ireland
|
|
110
110
|
108,124,833,108,,,N,N,,,IM,IMN,,,Isle of Man,,,,,Isle of Man (The United Kingdom of Great Britain and Northern Ireland),Isle of Man,,,,,,,Isle of Man,Île de Man,Isla de Man,Остров Мэн,马恩岛,جزيرة مان,0,54.23948288,-4.51817639,150,Europe,154,Northern Europe,,,^(?=.*isle).*\bman,High,GBP,2006-03-29,108 - Isle of Man
|
|
111
111
|
109,125,376,109,Y,Y,Y,N,,,IL,ISR,,,Israel,,,,,,Israel,Israël,Israel,Израиль,以色列,إسرائيل,the State of Israel,Israel,Israël,Israel,Израиль,以色列,إسرائيل,0,31.33857325,34.96023155,142,Asia,145,Western Asia,,,israel,High,ILS,1974-01-01,109 - Israel
|
|
@@ -132,8 +132,8 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
132
132
|
130,143,442,130,Y,Y,Y,N,,,LU,LUX,,,Luxembourg,,,,,,Luxembourg,Luxembourg,Luxemburgo,Люксембург,卢森堡,لكسمبرغ,the Grand Duchy of Luxembourg,Luxembourg,Luxembourg,Luxemburgo,Люксембург,卢森堡,لكسمبرغ,0,49.77027091,6.08637699,150,Europe,155,Western Europe,,,^(?!.*belg).*luxem,High,EUR,1974-01-01,130 - Luxembourg
|
|
133
133
|
131,60,446,131,,,N,N,,,MO,MAC,,,"China, Macao Special Administrative Region",Macao,,Macao,,China - Macau (Special Administrative Region),Macao,,,,,,,"China, Macao Special Administrative Region","Chine, région administrative spéciale de Macao","China, región administrativa especial de Macao","Китай, Специальный административный район Макао",中国澳门特别行政区,الصين، منطقة ماكاو الإدارية الخاصة,0,22.1985265,113.5450075,142,Asia,30,Eastern Asia,,,maca(o|u),High,MOP,1974-01-01,"131 - China, Macao Special Administrative Region"
|
|
134
134
|
132,229,807,132,Y,Y,Y,N,,,MK,MKD,,,North Macedonia,,,"North Macedonia, Republic of",,the Republic of North Macedonia,North Macedonia,Macédoine du Nord,Macedonia del Norte,Северная Македония,北马其顿,مقدونيا الشمالية,the Republic of North Macedonia,North Macedonia,Macédoine du Nord,Macedonia del Norte,Северная Македония,北马其顿,مقدونيا الشمالية,0,41.59654823,21.69480535,150,Europe,39,Southern Europe,,,macedonia|^f\.?y\.?r\.?o\.?m\.?$,Upper middle,MKD,2019-02-14,132 - North Macedonia
|
|
135
|
-
133,144,450,133,Y,Y,Y,N
|
|
136
|
-
134,146,454,134,Y,Y,Y,N
|
|
135
|
+
133,144,450,133,Y,Y,Y,N,,,MG,MDG,,,Madagascar,,,,,,Madagascar,Madagascar,Madagascar,Мадагаскар,马达加斯加,مدغشقر,the Republic of Madagascar,Madagascar,Madagascar,Madagascar,Мадагаскар,马达加斯加,مدغشقر,0,-19.37969027,46.70406219,2,Africa,202,Sub-Saharan Africa,14,Eastern Africa,madagascar|malagasy,Low,MGA,1993-07-12,133 - Madagascar
|
|
136
|
+
134,146,454,134,Y,Y,Y,N,,Y,MW,MWI,,,Malawi,,,,,,Malawi,Malawi,Malawi,Малави,马拉维,ملاوي,the Republic of Malawi,Malawi,Malawi,Malawi,Малави,马拉维,ملاوي,0,-13.21991287,34.31171876,2,Africa,202,Sub-Saharan Africa,14,Eastern Africa,malawi|nyasa,Low,MWK,1974-01-01,134 - Malawi
|
|
137
137
|
135,147,458,135,Y,Y,Y,N,,,MY,MYS,,,Malaysia,,,,,,Malaysia,Malaisie,Malasia,Малайзия,马来西亚,ماليزيا,Malaysia,Malaysia,Malaisie,Malasia,Малайзия,马来西亚,ماليزيا,0,2.745185714,140.4915783,142,Asia,35,South-eastern Asia,,,malaysia,Upper middle,MYR,1974-01-01,135 - Malaysia
|
|
138
138
|
136,148,462,136,Y,Y,Y,N,,,MV,MDV,,,Maldives,,,,,,Maldives,Maldives,Maldivas,Мальдивские Острова,马尔代夫,ملديف,the Republic of Maldives,Maldives,Maldives,Maldivas,Мальдивские Острова,马尔代夫,ملديف,0,5.068606213,73.32614511,142,Asia,34,Southern Asia,,,maldive,Upper middle,MVR,1974-01-01,136 - Maldives
|
|
139
139
|
137,149,466,137,Y,Y,Y,N,Y,Y,ML,MLI,,,Mali,,,,,,Mali,Mali,Malí,Мали,马里,مالي,the Republic of Mali,Mali,Mali,Malí,Мали,马里,مالي,0,17.34640627,-3.525051581,2,Africa,202,Sub-Saharan Africa,11,Western Africa,\bmali\b,Low,XOF,1974-01-01,137 - Mali
|
|
@@ -174,7 +174,7 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
174
174
|
172,185,598,173,Y,Y,Y,N,,,PG,PNG,,,Papua New Guinea,,,,PNG,,Papua New Guinea,Papouasie-Nouvelle-Guinée,Papua Nueva Guinea,Папуа — Новая Гвинея,巴布亚新几内亚,بابوا غينيا الجديدة,the Independent State of Papua New Guinea,Papua New Guinea,Papouasie-Nouvelle-Guinée,Papua Nueva Guinea,Папуа-Новая Гвинея,巴布亚新几内亚,بابوا غينيا الجديدة,0,-6.834760878,143.0464597,9,Oceania,54,Melanesia,,,papua|new.?guinea,Lower middle,PGK,1974-01-01,172 - Papua New Guinea
|
|
175
175
|
173,186,600,174,Y,Y,Y,N,,Y,PY,PRY,,,Paraguay,,,,,,Paraguay,Paraguay,Paraguay,Парагвай,巴拉圭,باراغواي,the Republic of Paraguay,Paraguay,Paraguay,Paraguay,Парагвай,巴拉圭,باراغواي,0,-23.23840821,-58.39126243,19,Americas,419,Latin America and the Caribbean,5,South America,paraguay,Upper middle,PYG,1974-01-01,173 - Paraguay
|
|
176
176
|
174,187,604,175,Y,Y,Y,N,,Y,PE,PER,,,Peru,,,,,,Peru,Pérou,Perú,Перу,秘鲁,بيرو,the Republic of Peru,Peru,Pérou,Perú,Перу,秘鲁,بيرو,0,-9.167216491,-74.37537796,19,Americas,419,Latin America and the Caribbean,5,South America,peru,Upper middle,PEN,1974-01-01,174 - Peru
|
|
177
|
-
175,188,608,176,Y,Y,Y,N
|
|
177
|
+
175,188,608,176,Y,Y,Y,N,,Y,PH,PHL,,,Philippines,Philippines (the),,,,,Philippines,Philippines,Filipinas,Филиппины,菲律宾,الفلبين,the Republic of the Philippines,Philippines,Philippines,Filipinas,Филиппины,菲律宾,الفلبين,0,-0.736653675,127.2358509,142,Asia,35,South-eastern Asia,,,philippines,Lower middle,PHP,1976-01-01,175 - Philippines
|
|
178
178
|
176,189,612,177,,,N,N,,,PN,PCN,,,Pitcairn,,,,,Pitcairn Islands,Pitcairn,,,,,,,Pitcairn,Pitcairn,Pitcairn,Питкэрн,皮特凯恩,بيتكرن,0,-24.2051566,-127.9093208,9,Oceania,61,Polynesia,,,pitcairn,,NZD,1974-01-01,176 - Pitcairn
|
|
179
179
|
177,190,616,178,Y,Y,Y,N,,Y,PL,POL,,,Poland,,,,,,Poland,Pologne,Polonia,Польша,波兰,بولندا,the Republic of Poland,Poland,Pologne,Polonia,Польша,波兰,بولندا,0,52.12847492,19.40086,150,Europe,151,Eastern Europe,,,poland,High,PLN,1974-01-01,177 - Poland
|
|
180
180
|
178,191,620,179,Y,Y,Y,N,,,PT,PRT,,,Portugal,,,,,,Portugal,Portugal,Portugal,Португалия,葡萄牙,البرتغال,the Portuguese Republic,Portugal,Portugal,Portugal,Португалия,葡萄牙,البرتغال,0,39.23901506,-30.21832194,150,Europe,39,Southern Europe,,,portugal,High,EUR,1974-01-01,178 - Portugal
|
|
@@ -241,7 +241,7 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
241
241
|
239,248,860,240,Y,Y,Y,N,,,UZ,UZB,,,Uzbekistan,,,,,,Uzbekistan,Ouzbékistan,Uzbekistán,Узбекистан,乌兹别克斯坦,أوزبكستان,the Republic of Uzbekistan,Uzbekistan,Ouzbékistan,Uzbekistán,Узбекистан,乌兹别克斯坦,أوزبكستان,0,41.74950759,63.17455249,142,Asia,143,Central Asia,,,uzbek,Lower middle,UZS,1992-06-15,239 - Uzbekistan
|
|
242
242
|
240,249,548,241,Y,Y,Y,N,,,VU,VUT,,,Vanuatu,,,,,,Vanuatu,Vanuatu,Vanuatu,Вануату,瓦努阿图,فانواتو,the Republic of Vanuatu,Vanuatu,Vanuatu,Vanuatu,Вануату,瓦努阿图,فانواتو,0,-21.04390394,171.2797047,9,Oceania,54,Melanesia,,,vanuatu|new.?hebrides,Lower middle,VUV,1980-01-01,240 - Vanuatu
|
|
243
243
|
241,250,862,242,Y,Y,Y,N,Y,Y,VE,VEN,,,Venezuela (Bolivarian Republic of),,,"Venezuela, Bolivarian Republic of",Venezuela,,Venezuela (Bolivarian Republic of),Venezuela (République bolivarienne du),Venezuela (República Bolivariana de),Венесуэла (Боливарианская Республика),委内瑞拉玻利瓦尔共和国,فنزويلا (جمهورية - البوليفارية),the Bolivarian Republic of Venezuela,Venezuela (Bolivarian Republic of),Venezuela (République bolivarienne du),Venezuela (República Bolivariana de),Венесуэла (Боливарианская Республика),委内瑞拉玻利瓦尔共和国,فنزويلا (جمهورية - البوليفارية),0,7.115201972,-66.18367077,19,Americas,419,Latin America and the Caribbean,5,South America,venezuela,,VEF,2009-03-03,241 - Venezuela (Bolivarian Republic of)
|
|
244
|
-
242,251,704,243,Y,Y,Y,N
|
|
244
|
+
242,251,704,243,Y,Y,Y,N,,Y,VN,VNM,,,Viet Nam,,,,,,Viet Nam,Viet Nam,Viet Nam,Вьетнам,越南,فييت نام,the Socialist Republic of Viet Nam,Viet Nam,Viet Nam,Viet Nam,Вьетнам,越南,فييت نام,0,16.64893259,106.3103686,142,Asia,35,South-eastern Asia,,,^(?!south)(?!republic).*viet.?nam(?!.*south)|democratic.republic.of.vietnam|socialist.republic.of.viet.?nam|north.viet.?nam|viet.?nam.north,Lower middle,VND,1977-01-01,242 - Viet Nam
|
|
245
245
|
243,43,92,244,,,N,N,,,VG,VGB,,,British Virgin Islands,Virgin Islands (British),,"Virgin Islands, British",,,British Virgin Islands,,,,,,,British Virgin Islands,Îles Vierges britanniques,Islas Vírgenes Británicas,Британские Виргинские острова,英属维尔京群岛,جزر فرجن البريطانية,0,18.30332154,-65.11493198,19,Americas,419,Latin America and the Caribbean,29,Caribbean,^(?=.*\bu\.?\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin,High,USD,1974-01-01,243 - British Virgin Islands
|
|
246
246
|
244,252,876,246,,,N,N,,,WF,WLF,,,Wallis and Futuna Islands,Wallis and Futuna,,Wallis and Futuna,,Wallis and Futuna (France),Wallis and Futuna Islands,,,,,,,Wallis and Futuna Islands,Îles Wallis-et-Futuna,Islas Wallis y Futuna,Острова Уоллис и Футуна,瓦利斯群岛和富图纳群岛,جزر واليس وفوتونا,0,-14.36099529,-178.0421057,9,Oceania,61,Polynesia,,,futuna|wallis,,XPF,1974-01-01,244 - Wallis and Futuna Islands
|
|
247
247
|
245,253,732,247,,,N,N,,,EH,ESH,,,Western Sahara,,,"Western Sahara, non-self-governing territory",,,Western Sahara,,,,,,,Western Sahara,Sahara occidental,Sáhara Occidental,Западная Сахара,西撒哈拉,الصحراء الغربية,0,24.66295331,-13.13425705,2,Africa,15,Northern Africa,,,western.sahara,,MAD,1985-01-01,245 - Western Sahara
|
|
@@ -8,7 +8,7 @@ from string import punctuation
|
|
|
8
8
|
from typing import Dict, List, Optional, Tuple, Union
|
|
9
9
|
|
|
10
10
|
import hxl
|
|
11
|
-
from hxl import InputOptions
|
|
11
|
+
from hxl import Dataset, InputOptions
|
|
12
12
|
|
|
13
13
|
from hdx.utilities.path import script_dir_plus_file
|
|
14
14
|
from hdx.utilities.text import get_words_in_sentence
|
|
@@ -69,6 +69,8 @@ class Country:
|
|
|
69
69
|
"KINGDOM",
|
|
70
70
|
"PROTECTORATE",
|
|
71
71
|
]
|
|
72
|
+
_include_unofficial_default = False
|
|
73
|
+
_include_unofficial = _include_unofficial_default
|
|
72
74
|
_use_live_default = True
|
|
73
75
|
_use_live = _use_live_default
|
|
74
76
|
_countriesdata = None
|
|
@@ -102,6 +104,8 @@ class Country:
|
|
|
102
104
|
if countryname is not None:
|
|
103
105
|
country["#country+name+override"] = countryname
|
|
104
106
|
iso2 = hxlcountry.get("#country+code+v_iso2")
|
|
107
|
+
if not iso2 and cls._include_unofficial:
|
|
108
|
+
iso2 = hxlcountry.get("#country+code+alpha2")
|
|
105
109
|
if iso2:
|
|
106
110
|
cls._countriesdata["iso2iso3"][iso2] = iso3
|
|
107
111
|
# different types so keys won't clash
|
|
@@ -159,12 +163,12 @@ class Country:
|
|
|
159
163
|
return country
|
|
160
164
|
|
|
161
165
|
@classmethod
|
|
162
|
-
def set_countriesdata(cls, countries:
|
|
166
|
+
def set_countriesdata(cls, countries: Dataset) -> None:
|
|
163
167
|
"""
|
|
164
|
-
Set up countries data from
|
|
168
|
+
Set up countries data from OCHA countries and territories dataset
|
|
165
169
|
|
|
166
170
|
Args:
|
|
167
|
-
countries (
|
|
171
|
+
countries (Dataset): Countries data from countries and territories dataset
|
|
168
172
|
|
|
169
173
|
Returns:
|
|
170
174
|
None
|
|
@@ -186,7 +190,12 @@ class Country:
|
|
|
186
190
|
for country in countries:
|
|
187
191
|
iso3 = country.get("#country+code+v_iso3")
|
|
188
192
|
if not iso3:
|
|
189
|
-
|
|
193
|
+
if cls._include_unofficial:
|
|
194
|
+
iso3 = country.get("#country+code+alpha3")
|
|
195
|
+
if not iso3:
|
|
196
|
+
continue
|
|
197
|
+
else:
|
|
198
|
+
continue
|
|
190
199
|
iso3 = iso3.upper()
|
|
191
200
|
countrydict = cls._add_countriesdata(iso3, country)
|
|
192
201
|
cls._countriesdata["countries"][iso3] = countrydict
|
|
@@ -202,30 +211,37 @@ class Country:
|
|
|
202
211
|
@classmethod
|
|
203
212
|
def countriesdata(
|
|
204
213
|
cls,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
214
|
+
include_unofficial: Optional[bool] = None,
|
|
215
|
+
use_live: Optional[bool] = None,
|
|
216
|
+
country_name_overrides: Optional[Dict] = None,
|
|
217
|
+
country_name_mappings: Optional[Dict] = None,
|
|
208
218
|
) -> List[Dict[str, Dict]]:
|
|
209
219
|
"""
|
|
210
|
-
Read countries data from OCHA countries feed (falling back to file)
|
|
220
|
+
Read countries data from OCHA countries feed (falling back to file).
|
|
221
|
+
include_unofficial, use_live, country_name_overrides and country_name_mappings
|
|
222
|
+
are taken from internal defaults if they are None, otherwise the internal
|
|
223
|
+
defaults are overridden.
|
|
211
224
|
|
|
212
225
|
Args:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
include_unofficial (Optional[bool]): Include unofficial country alpha codes. Defaults to False.
|
|
227
|
+
use_live (Optional[bool]): Try to get latest data from web rather than file in package. Defaults to True.
|
|
228
|
+
country_name_overrides (Optional[Dict]): Dictionary of mappings from iso3 to country name
|
|
229
|
+
country_name_mappings (Optional[Dict]): Dictionary of mappings from country name to iso3
|
|
216
230
|
|
|
217
231
|
Returns:
|
|
218
232
|
List[Dict[str,Dict]]: Countries dictionaries
|
|
219
233
|
"""
|
|
220
|
-
if
|
|
221
|
-
|
|
234
|
+
if include_unofficial is not None:
|
|
235
|
+
cls._include_unofficial = include_unofficial
|
|
236
|
+
if use_live is not None:
|
|
237
|
+
cls._use_live = use_live
|
|
222
238
|
if cls._countriesdata is None:
|
|
223
239
|
countries = None
|
|
224
240
|
if country_name_overrides is not None:
|
|
225
241
|
cls.set_country_name_overrides(country_name_overrides)
|
|
226
242
|
if country_name_mappings is not None:
|
|
227
243
|
cls.set_country_name_mappings(country_name_mappings)
|
|
228
|
-
if
|
|
244
|
+
if cls._use_live:
|
|
229
245
|
try:
|
|
230
246
|
countries = hxl.data(cls._ochaurl, InputOptions(encoding="utf-8"))
|
|
231
247
|
except OSError:
|
|
@@ -240,6 +256,24 @@ class Country:
|
|
|
240
256
|
cls.set_countriesdata(countries)
|
|
241
257
|
return cls._countriesdata
|
|
242
258
|
|
|
259
|
+
@classmethod
|
|
260
|
+
def set_include_unofficial_default(
|
|
261
|
+
cls, include_unofficial: Optional[bool] = None
|
|
262
|
+
) -> None:
|
|
263
|
+
"""
|
|
264
|
+
Set the default for include_unofficial which defines if unofficial alpha2 and
|
|
265
|
+
alpha3 codes such as AN and XKX will be included.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
include_unofficial (bool): Default value to use for include_unofficial. Defaults to internal value (False).
|
|
269
|
+
|
|
270
|
+
Returns:
|
|
271
|
+
None
|
|
272
|
+
"""
|
|
273
|
+
if include_unofficial is None:
|
|
274
|
+
include_unofficial = cls._include_unofficial
|
|
275
|
+
cls._include_unofficial = include_unofficial
|
|
276
|
+
|
|
243
277
|
@classmethod
|
|
244
278
|
def set_use_live_default(cls, use_live: Optional[bool] = None) -> None:
|
|
245
279
|
"""
|
{hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
ID,RW ID,m49 numerical code,
|
|
2
|
-
#meta +id,#country +code +v_reliefweb,#country +code +num +v_m49,#country +code +
|
|
1
|
+
ID,RW ID,m49 numerical code,HPC Tools API ID,Appears in UNTERM list,Appears in DGACM list,Independent,Deprecated,Has HRP,In GHO,ISO 3166-1 Alpha 2-Codes,ISO 3166-1 Alpha 3-Codes,x Alpha2 codes,x Alpha3 codes,Preferred Term,ISO Alt Term,DGACM Alt Term,HPC Tools Alt Term,RW Short Name,RW API Alt Term,English Short,French Short,Spanish Short,Russian Short,Chinese Short,Arabic Short,English Formal,M49 English,M49 French,M49 Spanish,M49 Russian,M49 Chinese,M49 Arabic,Admin Level,Latitude,Longitude,Region Code,Region Name,Sub-region Code,Sub-region Name,Intermediate Region Code,Intermediate Region Name,Regex,World Bank Income Level,Currency,Reference Period Start,Concatenation
|
|
2
|
+
#meta +id,#country +code +v_reliefweb,#country +code +num +v_m49,#country +code +v_hpctools,,,#meta+independent+bool,#meta+deprecated+bool,#indicator+hrp+bool,#indicator+gho+bool,#country +code +v_iso2,#country +code +v_iso3,#country +code +alpha2,#country +code +alpha3,#country +name +preferred,#country +name +alt +v_iso,#country +name +alt +v_dgacm,#country +name +alt +v_hpctools,#country +name +short +v_reliefweb,#country +name +alt +v_reliefweb,#country +name +i_en +alt +v_unterm,#country +name +i_fr +alt +v_unterm,#country +name +i_es +alt +v_unterm,#country +name +i_ru +alt +v_unterm,#country +name +i_zh +alt +v_unterm,#country +name +i_ar +alt +v_unterm,#country +name +i_en +formal +v_unterm,#country +name +i_en +alt +v_m49,#country +name +i_fr +alt +v_m49,#country +name +i_es +alt +v_m49,#country +name +i_ru +alt +v_m49,#country +name +i_zh +alt +v_m49,#country +name +i_ar +alt +v_m49,#geo +admin_level,#geo +lat,#geo +lon,#region +main +code,#region +main +name +preferred,#region +sub +code,#region +sub +name +preferred,#region +intermediate +code,#region +intermediate +name +preferred,#country +regex,#indicator+incomelevel,#currency +code,#date+start,
|
|
3
3
|
1,13,4,1,Y,Y,Y,N,Y,Y,AF,AFG,,,Afghanistan,,,,,,Afghanistan,Afghanistan,Afganistán,Афганистан,阿富汗,أفغانستان,the Islamic Republic of Afghanistan,Afghanistan,Afghanistan,Afganistán,Афганистан,阿富汗,أفغانستان,0,33.83147477,66.02621828,142,Asia,34,Southern Asia,,,afghan,Low,AFN,2004-01-26,1 - Afghanistan
|
|
4
4
|
2,14,248,2,,,N,N,,,AX,ALA,,,Åland Islands,,,,,Aland Islands (Finland),Åland Islands,,,,,,,Åland Islands,Îles d’Åland,Islas Åland,Аландских островов,奥兰群岛,جزر ألاند,0,60.18121338,19.89649072,150,Europe,154,Northern Europe,,,^[å|a]land,,EUR,2004-02-13,2 - Åland Islands
|
|
5
5
|
3,15,8,3,Y,Y,Y,N,,,AL,ALB,,,Albania,,,,,,Albania,Albanie,Albania,Албания,阿尔巴尼亚,ألبانيا,the Republic of Albania,Albania,Albanie,Albania,Албания,阿尔巴尼亚,ألبانيا,0,41.13180899,20.06882519,150,Europe,39,Southern Europe,,,albania,Upper middle,ALL,1974-01-01,3 - Albania
|
|
@@ -105,7 +105,7 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
105
105
|
103,119,356,103,Y,Y,Y,N,,,IN,IND,,,India,,,,,,India,Inde,India,Индия,印度,الهند,the Republic of India,India,Inde,India,Индия,印度,الهند,0,22.37137039,79.32792202,142,Asia,34,Southern Asia,,,^(?!\D*(?:bassas))\D*india(?!.*ocea)(?!na),Lower middle,INR,1975-01-01,103 - India
|
|
106
106
|
104,120,360,104,Y,Y,Y,N,,,ID,IDN,,,Indonesia,,,,,,Indonesia,Indonésie,Indonesia,Индонезия,印度尼西亚,إندونيسيا,the Republic of Indonesia,Indonesia,Indonésie,Indonesia,Индонезия,印度尼西亚,إندونيسيا,0,-2.21433486,117.2844335,142,Asia,35,South-eastern Asia,,,indonesia,Upper middle,IDR,1974-01-01,104 - Indonesia
|
|
107
107
|
105,121,364,105,Y,Y,Y,N,,Y,IR,IRN,,,Iran (Islamic Republic of),,,"Iran, Islamic Republic of",Iran,,Iran (Islamic Republic of),Iran (République islamique d'),Irán (República Islámica del),Иран (Исламская Республика),伊朗伊斯兰共和国,إيران (جمهورية - الإسلامية),the Islamic Republic of Iran,Iran (Islamic Republic of),Iran (République islamique d’),Irán (República Islámica del),Иран (Исламская Республика),伊朗伊斯兰共和国,إيران (جمهورية - الإسلامية),0,32.57533772,54.2973284,142,Asia,34,Southern Asia,,,\biran|persia,Lower middle,IRR,1974-01-01,105 - Iran (Islamic Republic of)
|
|
108
|
-
106,122,368,106,Y,Y,Y,N
|
|
108
|
+
106,122,368,106,Y,Y,Y,N,,,IQ,IRQ,,,Iraq,,,,,,Iraq,Iraq,Iraq,Ирак,伊拉克,العراق,the Republic of Iraq,Iraq,Iraq,Iraq,Ирак,伊拉克,العراق,0,33.04497404,43.77207391,142,Asia,145,Western Asia,,,\biraq|mesopotamia,Upper middle,IQD,1974-01-01,106 - Iraq
|
|
109
109
|
107,123,372,107,Y,Y,Y,N,,,IE,IRL,,,Ireland,,,,,,Ireland,Irlande,Irlanda,Ирландия,爱尔兰,أيرلندا,Ireland,Ireland,Irlande,Irlanda,Ирландия,爱尔兰,آيرلندا,0,53.16969376,-8.154213185,150,Europe,154,Northern Europe,,,^(?!.*north).*\bireland,High,EUR,1974-01-01,107 - Ireland
|
|
110
110
|
108,124,833,108,,,N,N,,,IM,IMN,,,Isle of Man,,,,,Isle of Man (The United Kingdom of Great Britain and Northern Ireland),Isle of Man,,,,,,,Isle of Man,Île de Man,Isla de Man,Остров Мэн,马恩岛,جزيرة مان,0,54.23948288,-4.51817639,150,Europe,154,Northern Europe,,,^(?=.*isle).*\bman,High,GBP,2006-03-29,108 - Isle of Man
|
|
111
111
|
109,125,376,109,Y,Y,Y,N,,,IL,ISR,,,Israel,,,,,,Israel,Israël,Israel,Израиль,以色列,إسرائيل,the State of Israel,Israel,Israël,Israel,Израиль,以色列,إسرائيل,0,31.33857325,34.96023155,142,Asia,145,Western Asia,,,israel,High,ILS,1974-01-01,109 - Israel
|
|
@@ -132,8 +132,8 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
132
132
|
130,143,442,130,Y,Y,Y,N,,,LU,LUX,,,Luxembourg,,,,,,Luxembourg,Luxembourg,Luxemburgo,Люксембург,卢森堡,لكسمبرغ,the Grand Duchy of Luxembourg,Luxembourg,Luxembourg,Luxemburgo,Люксембург,卢森堡,لكسمبرغ,0,49.77027091,6.08637699,150,Europe,155,Western Europe,,,^(?!.*belg).*luxem,High,EUR,1974-01-01,130 - Luxembourg
|
|
133
133
|
131,60,446,131,,,N,N,,,MO,MAC,,,"China, Macao Special Administrative Region",Macao,,Macao,,China - Macau (Special Administrative Region),Macao,,,,,,,"China, Macao Special Administrative Region","Chine, région administrative spéciale de Macao","China, región administrativa especial de Macao","Китай, Специальный административный район Макао",中国澳门特别行政区,الصين، منطقة ماكاو الإدارية الخاصة,0,22.1985265,113.5450075,142,Asia,30,Eastern Asia,,,maca(o|u),High,MOP,1974-01-01,"131 - China, Macao Special Administrative Region"
|
|
134
134
|
132,229,807,132,Y,Y,Y,N,,,MK,MKD,,,North Macedonia,,,"North Macedonia, Republic of",,the Republic of North Macedonia,North Macedonia,Macédoine du Nord,Macedonia del Norte,Северная Македония,北马其顿,مقدونيا الشمالية,the Republic of North Macedonia,North Macedonia,Macédoine du Nord,Macedonia del Norte,Северная Македония,北马其顿,مقدونيا الشمالية,0,41.59654823,21.69480535,150,Europe,39,Southern Europe,,,macedonia|^f\.?y\.?r\.?o\.?m\.?$,Upper middle,MKD,2019-02-14,132 - North Macedonia
|
|
135
|
-
133,144,450,133,Y,Y,Y,N
|
|
136
|
-
134,146,454,134,Y,Y,Y,N
|
|
135
|
+
133,144,450,133,Y,Y,Y,N,,,MG,MDG,,,Madagascar,,,,,,Madagascar,Madagascar,Madagascar,Мадагаскар,马达加斯加,مدغشقر,the Republic of Madagascar,Madagascar,Madagascar,Madagascar,Мадагаскар,马达加斯加,مدغشقر,0,-19.37969027,46.70406219,2,Africa,202,Sub-Saharan Africa,14,Eastern Africa,madagascar|malagasy,Low,MGA,1993-07-12,133 - Madagascar
|
|
136
|
+
134,146,454,134,Y,Y,Y,N,,Y,MW,MWI,,,Malawi,,,,,,Malawi,Malawi,Malawi,Малави,马拉维,ملاوي,the Republic of Malawi,Malawi,Malawi,Malawi,Малави,马拉维,ملاوي,0,-13.21991287,34.31171876,2,Africa,202,Sub-Saharan Africa,14,Eastern Africa,malawi|nyasa,Low,MWK,1974-01-01,134 - Malawi
|
|
137
137
|
135,147,458,135,Y,Y,Y,N,,,MY,MYS,,,Malaysia,,,,,,Malaysia,Malaisie,Malasia,Малайзия,马来西亚,ماليزيا,Malaysia,Malaysia,Malaisie,Malasia,Малайзия,马来西亚,ماليزيا,0,2.745185714,140.4915783,142,Asia,35,South-eastern Asia,,,malaysia,Upper middle,MYR,1974-01-01,135 - Malaysia
|
|
138
138
|
136,148,462,136,Y,Y,Y,N,,,MV,MDV,,,Maldives,,,,,,Maldives,Maldives,Maldivas,Мальдивские Острова,马尔代夫,ملديف,the Republic of Maldives,Maldives,Maldives,Maldivas,Мальдивские Острова,马尔代夫,ملديف,0,5.068606213,73.32614511,142,Asia,34,Southern Asia,,,maldive,Upper middle,MVR,1974-01-01,136 - Maldives
|
|
139
139
|
137,149,466,137,Y,Y,Y,N,Y,Y,ML,MLI,,,Mali,,,,,,Mali,Mali,Malí,Мали,马里,مالي,the Republic of Mali,Mali,Mali,Malí,Мали,马里,مالي,0,17.34640627,-3.525051581,2,Africa,202,Sub-Saharan Africa,11,Western Africa,\bmali\b,Low,XOF,1974-01-01,137 - Mali
|
|
@@ -174,7 +174,7 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
174
174
|
172,185,598,173,Y,Y,Y,N,,,PG,PNG,,,Papua New Guinea,,,,PNG,,Papua New Guinea,Papouasie-Nouvelle-Guinée,Papua Nueva Guinea,Папуа — Новая Гвинея,巴布亚新几内亚,بابوا غينيا الجديدة,the Independent State of Papua New Guinea,Papua New Guinea,Papouasie-Nouvelle-Guinée,Papua Nueva Guinea,Папуа-Новая Гвинея,巴布亚新几内亚,بابوا غينيا الجديدة,0,-6.834760878,143.0464597,9,Oceania,54,Melanesia,,,papua|new.?guinea,Lower middle,PGK,1974-01-01,172 - Papua New Guinea
|
|
175
175
|
173,186,600,174,Y,Y,Y,N,,Y,PY,PRY,,,Paraguay,,,,,,Paraguay,Paraguay,Paraguay,Парагвай,巴拉圭,باراغواي,the Republic of Paraguay,Paraguay,Paraguay,Paraguay,Парагвай,巴拉圭,باراغواي,0,-23.23840821,-58.39126243,19,Americas,419,Latin America and the Caribbean,5,South America,paraguay,Upper middle,PYG,1974-01-01,173 - Paraguay
|
|
176
176
|
174,187,604,175,Y,Y,Y,N,,Y,PE,PER,,,Peru,,,,,,Peru,Pérou,Perú,Перу,秘鲁,بيرو,the Republic of Peru,Peru,Pérou,Perú,Перу,秘鲁,بيرو,0,-9.167216491,-74.37537796,19,Americas,419,Latin America and the Caribbean,5,South America,peru,Upper middle,PEN,1974-01-01,174 - Peru
|
|
177
|
-
175,188,608,176,Y,Y,Y,N
|
|
177
|
+
175,188,608,176,Y,Y,Y,N,,Y,PH,PHL,,,Philippines,Philippines (the),,,,,Philippines,Philippines,Filipinas,Филиппины,菲律宾,الفلبين,the Republic of the Philippines,Philippines,Philippines,Filipinas,Филиппины,菲律宾,الفلبين,0,-0.736653675,127.2358509,142,Asia,35,South-eastern Asia,,,philippines,Lower middle,PHP,1976-01-01,175 - Philippines
|
|
178
178
|
176,189,612,177,,,N,N,,,PN,PCN,,,Pitcairn,,,,,Pitcairn Islands,Pitcairn,,,,,,,Pitcairn,Pitcairn,Pitcairn,Питкэрн,皮特凯恩,بيتكرن,0,-24.2051566,-127.9093208,9,Oceania,61,Polynesia,,,pitcairn,,NZD,1974-01-01,176 - Pitcairn
|
|
179
179
|
177,190,616,178,Y,Y,Y,N,,Y,PL,POL,,,Poland,,,,,,Poland,Pologne,Polonia,Польша,波兰,بولندا,the Republic of Poland,Poland,Pologne,Polonia,Польша,波兰,بولندا,0,52.12847492,19.40086,150,Europe,151,Eastern Europe,,,poland,High,PLN,1974-01-01,177 - Poland
|
|
180
180
|
178,191,620,179,Y,Y,Y,N,,,PT,PRT,,,Portugal,,,,,,Portugal,Portugal,Portugal,Португалия,葡萄牙,البرتغال,the Portuguese Republic,Portugal,Portugal,Portugal,Португалия,葡萄牙,البرتغال,0,39.23901506,-30.21832194,150,Europe,39,Southern Europe,,,portugal,High,EUR,1974-01-01,178 - Portugal
|
|
@@ -240,7 +240,7 @@ ID,RW ID,m49 numerical code,FTS API ID,Appears in UNTERM list,Appears in DGACM l
|
|
|
240
240
|
238,247,858,239,Y,Y,Y,N,,Y,UY,URY,,,Uruguay,,,,,,Uruguay,Uruguay,Uruguay,Уругвай,乌拉圭,أوروغواي,the Eastern Republic of Uruguay,Uruguay,Uruguay,Uruguay,Уругвай,乌拉圭,أوروغواي,0,-32.80198719,-56.01417232,19,Americas,419,Latin America and the Caribbean,5,South America,uruguay,High,UYU,1974-01-01,238 - Uruguay
|
|
241
241
|
240,249,548,241,Y,Y,Y,N,,,VU,VUT,,,Vanuatu,,,,,,Vanuatu,Vanuatu,Vanuatu,Вануату,瓦努阿图,فانواتو,the Republic of Vanuatu,Vanuatu,Vanuatu,Vanuatu,Вануату,瓦努阿图,فانواتو,0,-21.04390394,171.2797047,9,Oceania,54,Melanesia,,,vanuatu|new.?hebrides,Lower middle,VUV,1980-01-01,240 - Vanuatu
|
|
242
242
|
241,250,862,242,Y,Y,Y,N,Y,Y,VE,VEN,,,Venezuela (Bolivarian Republic of),,,"Venezuela, Bolivarian Republic of",Venezuela,,Venezuela (Bolivarian Republic of),Venezuela (République bolivarienne du),Venezuela (República Bolivariana de),Венесуэла (Боливарианская Республика),委内瑞拉玻利瓦尔共和国,فنزويلا (جمهورية - البوليفارية),the Bolivarian Republic of Venezuela,Venezuela (Bolivarian Republic of),Venezuela (République bolivarienne du),Venezuela (República Bolivariana de),Венесуэла (Боливарианская Республика),委内瑞拉玻利瓦尔共和国,فنزويلا (جمهورية - البوليفارية),0,7.115201972,-66.18367077,19,Americas,419,Latin America and the Caribbean,5,South America,venezuela,,VEF,2009-03-03,241 - Venezuela (Bolivarian Republic of)
|
|
243
|
-
242,251,704,243,Y,Y,Y,N
|
|
243
|
+
242,251,704,243,Y,Y,Y,N,,Y,VN,VNM,,,Viet Nam,,,,,,Viet Nam,Viet Nam,Viet Nam,Вьетнам,越南,فييت نام,the Socialist Republic of Viet Nam,Viet Nam,Viet Nam,Viet Nam,Вьетнам,越南,فييت نام,0,16.64893259,106.3103686,142,Asia,35,South-eastern Asia,,,^(?!south)(?!republic).*viet.?nam(?!.*south)|democratic.republic.of.vietnam|socialist.republic.of.viet.?nam|north.viet.?nam|viet.?nam.north,Lower middle,VND,1977-01-01,242 - Viet Nam
|
|
244
244
|
243,43,92,244,,,N,N,,,VG,VGB,,,British Virgin Islands,Virgin Islands (British),,"Virgin Islands, British",,,British Virgin Islands,,,,,,,British Virgin Islands,Îles Vierges britanniques,Islas Vírgenes Británicas,Британские Виргинские острова,英属维尔京群岛,جزر فرجن البريطانية,0,18.30332154,-65.11493198,19,Americas,419,Latin America and the Caribbean,29,Caribbean,^(?=.*\bu\.?\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin,High,USD,1974-01-01,243 - British Virgin Islands
|
|
245
245
|
244,252,876,246,,,N,N,,,WF,WLF,,,Wallis and Futuna Islands,Wallis and Futuna,,Wallis and Futuna,,Wallis and Futuna (France),Wallis and Futuna Islands,,,,,,,Wallis and Futuna Islands,Îles Wallis-et-Futuna,Islas Wallis y Futuna,Острова Уоллис и Футуна,瓦利斯群岛和富图纳群岛,جزر واليس وفوتونا,0,-14.36099529,-178.0421057,9,Oceania,61,Polynesia,,,futuna|wallis,,XPF,1974-01-01,244 - Wallis and Futuna Islands
|
|
246
246
|
245,253,732,247,,,N,N,,,EH,ESH,,,Western Sahara,,,"Western Sahara, non-self-governing territory",,,Western Sahara,,,,,,,Western Sahara,Sahara occidental,Sáhara Occidental,Западная Сахара,西撒哈拉,الصحراء الغربية,0,24.66295331,-13.13425705,2,Africa,15,Northern Africa,,,western.sahara,,MAD,1985-01-01,245 - Western Sahara
|
|
@@ -13,13 +13,22 @@ class LocationError(Exception):
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class TestCountry:
|
|
16
|
-
|
|
17
|
-
def setup(self):
|
|
18
|
-
# Clean up Country class before each test
|
|
16
|
+
def clear_data(self):
|
|
19
17
|
Country._countriesdata = None
|
|
20
18
|
Country.set_use_live_default(False)
|
|
21
19
|
Country.set_ocha_url()
|
|
22
20
|
Country.set_ocha_path()
|
|
21
|
+
|
|
22
|
+
def setup_unofficial_date(self):
|
|
23
|
+
self.clear_data()
|
|
24
|
+
Country.set_include_unofficial_default(True)
|
|
25
|
+
Country.countriesdata()
|
|
26
|
+
|
|
27
|
+
@pytest.fixture(scope="function", autouse=True)
|
|
28
|
+
def setup(self):
|
|
29
|
+
# Clean up Country class before each test
|
|
30
|
+
self.clear_data()
|
|
31
|
+
Country.set_include_unofficial_default(False)
|
|
23
32
|
Country.countriesdata(
|
|
24
33
|
country_name_overrides={"PSE": "oPt"},
|
|
25
34
|
country_name_mappings={"Congo DR": "COD"},
|
|
@@ -52,6 +61,10 @@ class TestCountry:
|
|
|
52
61
|
== "Taiwan (Province of China)"
|
|
53
62
|
)
|
|
54
63
|
assert Country.get_country_name_from_iso3("PSE") == "oPt"
|
|
64
|
+
with pytest.raises(LocationError):
|
|
65
|
+
Country.get_iso2_from_iso3("CHI", exception=LocationError)
|
|
66
|
+
self.setup_unofficial_date()
|
|
67
|
+
assert Country.get_country_name_from_iso3("CHI") == "Channel Islands"
|
|
55
68
|
|
|
56
69
|
def test_get_iso2_from_iso3(self):
|
|
57
70
|
assert Country.get_iso2_from_iso3("jpn") == "JP"
|
|
@@ -67,6 +80,8 @@ class TestCountry:
|
|
|
67
80
|
|
|
68
81
|
def test_get_country_info_from_iso3(self):
|
|
69
82
|
assert Country.get_country_info_from_iso3("bih") == {
|
|
83
|
+
"#country+alpha2+code": "",
|
|
84
|
+
"#country+alpha3+code": "",
|
|
70
85
|
"#country+alt+i_ar+name+v_m49": "البوسنة والهرسك",
|
|
71
86
|
"#country+alt+i_ar+name+v_unterm": "البوسنة والهرسك",
|
|
72
87
|
"#country+alt+i_en+name+v_m49": "Bosnia and Herzegovina",
|
|
@@ -80,11 +95,11 @@ class TestCountry:
|
|
|
80
95
|
"#country+alt+i_zh+name+v_m49": "波斯尼亚和黑塞哥维那",
|
|
81
96
|
"#country+alt+i_zh+name+v_unterm": "波斯尼亚和黑塞哥维那",
|
|
82
97
|
"#country+alt+name+v_dgacm": "",
|
|
83
|
-
"#country+alt+name+
|
|
98
|
+
"#country+alt+name+v_hpctools": "",
|
|
84
99
|
"#country+alt+name+v_iso": "",
|
|
85
100
|
"#country+alt+name+v_reliefweb": "",
|
|
86
101
|
"#country+code+num+v_m49": "70",
|
|
87
|
-
"#country+code+
|
|
102
|
+
"#country+code+v_hpctools": "28",
|
|
88
103
|
"#country+code+v_iso2": "BA",
|
|
89
104
|
"#country+code+v_iso3": "BIH",
|
|
90
105
|
"#country+code+v_reliefweb": "40",
|
|
@@ -111,6 +126,8 @@ class TestCountry:
|
|
|
111
126
|
"#region+name+preferred+sub": "Southern Europe",
|
|
112
127
|
}
|
|
113
128
|
assert Country.get_country_info_from_iso3("PSE") == {
|
|
129
|
+
"#country+alpha2+code": "",
|
|
130
|
+
"#country+alpha3+code": "",
|
|
114
131
|
"#country+alt+i_ar+name+v_m49": "دولة فلسطين",
|
|
115
132
|
"#country+alt+i_ar+name+v_unterm": "دولة فلسطين",
|
|
116
133
|
"#country+alt+i_en+name+v_m49": "State of Palestine",
|
|
@@ -124,11 +141,11 @@ class TestCountry:
|
|
|
124
141
|
"#country+alt+i_zh+name+v_m49": "巴勒斯坦国",
|
|
125
142
|
"#country+alt+i_zh+name+v_unterm": "巴勒斯坦国",
|
|
126
143
|
"#country+alt+name+v_dgacm": "",
|
|
127
|
-
"#country+alt+name+
|
|
144
|
+
"#country+alt+name+v_hpctools": "occupied Palestinian territory",
|
|
128
145
|
"#country+alt+name+v_iso": "Palestine, State of",
|
|
129
146
|
"#country+alt+name+v_reliefweb": "occupied Palestinian territory",
|
|
130
147
|
"#country+code+num+v_m49": "275",
|
|
131
|
-
"#country+code+
|
|
148
|
+
"#country+code+v_hpctools": "171",
|
|
132
149
|
"#country+code+v_iso2": "PS",
|
|
133
150
|
"#country+code+v_iso3": "PSE",
|
|
134
151
|
"#country+code+v_reliefweb": "180",
|
|
@@ -155,6 +172,55 @@ class TestCountry:
|
|
|
155
172
|
"#region+main+name+preferred": "Asia",
|
|
156
173
|
"#region+name+preferred+sub": "Western Asia",
|
|
157
174
|
}
|
|
175
|
+
with pytest.raises(LocationError):
|
|
176
|
+
Country.get_country_name_from_iso2("AZO", exception=LocationError)
|
|
177
|
+
self.setup_unofficial_date()
|
|
178
|
+
assert Country.get_country_info_from_iso3("AZO") == {
|
|
179
|
+
"#country+alpha2+code": "",
|
|
180
|
+
"#country+alpha3+code": "AZO",
|
|
181
|
+
"#country+alt+i_ar+name+v_m49": "",
|
|
182
|
+
"#country+alt+i_ar+name+v_unterm": "",
|
|
183
|
+
"#country+alt+i_en+name+v_m49": "",
|
|
184
|
+
"#country+alt+i_en+name+v_unterm": "Azores Islands",
|
|
185
|
+
"#country+alt+i_es+name+v_m49": "",
|
|
186
|
+
"#country+alt+i_es+name+v_unterm": "",
|
|
187
|
+
"#country+alt+i_fr+name+v_m49": "",
|
|
188
|
+
"#country+alt+i_fr+name+v_unterm": "",
|
|
189
|
+
"#country+alt+i_ru+name+v_m49": "",
|
|
190
|
+
"#country+alt+i_ru+name+v_unterm": "",
|
|
191
|
+
"#country+alt+i_zh+name+v_m49": "",
|
|
192
|
+
"#country+alt+i_zh+name+v_unterm": "",
|
|
193
|
+
"#country+alt+name+v_dgacm": "",
|
|
194
|
+
"#country+alt+name+v_hpctools": "",
|
|
195
|
+
"#country+alt+name+v_iso": "",
|
|
196
|
+
"#country+alt+name+v_reliefweb": "",
|
|
197
|
+
"#country+code+num+v_m49": "",
|
|
198
|
+
"#country+code+v_hpctools": "",
|
|
199
|
+
"#country+code+v_iso2": "",
|
|
200
|
+
"#country+code+v_iso3": "",
|
|
201
|
+
"#country+code+v_reliefweb": "28",
|
|
202
|
+
"#country+formal+i_en+name+v_unterm": "",
|
|
203
|
+
"#country+name+preferred": "Azores Islands (Portugal)",
|
|
204
|
+
"#country+name+short+v_reliefweb": "",
|
|
205
|
+
"#country+regex": "azores",
|
|
206
|
+
"#currency+code": "EUR",
|
|
207
|
+
"#date+start": "1974-01-01",
|
|
208
|
+
"#geo+admin_level": "",
|
|
209
|
+
"#geo+lat": "38.72708329",
|
|
210
|
+
"#geo+lon": "-27.26017212",
|
|
211
|
+
"#indicator+bool+gho": "",
|
|
212
|
+
"#indicator+bool+hrp": "",
|
|
213
|
+
"#indicator+incomelevel": "",
|
|
214
|
+
"#meta+bool+deprecated": "N",
|
|
215
|
+
"#meta+bool+independent": "N",
|
|
216
|
+
"#meta+id": "249",
|
|
217
|
+
"#region+code+intermediate": "",
|
|
218
|
+
"#region+code+main": "150",
|
|
219
|
+
"#region+code+sub": "39",
|
|
220
|
+
"#region+intermediate+name+preferred": "",
|
|
221
|
+
"#region+main+name+preferred": "Europe",
|
|
222
|
+
"#region+name+preferred+sub": "Southern Europe",
|
|
223
|
+
}
|
|
158
224
|
|
|
159
225
|
def test_get_currency_from_iso3(self):
|
|
160
226
|
assert Country.get_currency_from_iso3("jpn") == "JPY"
|
|
@@ -164,6 +230,8 @@ class TestCountry:
|
|
|
164
230
|
|
|
165
231
|
def test_get_country_info_from_iso2(self):
|
|
166
232
|
assert Country.get_country_info_from_iso2("jp") == {
|
|
233
|
+
"#country+alpha2+code": "",
|
|
234
|
+
"#country+alpha3+code": "",
|
|
167
235
|
"#country+alt+i_ar+name+v_m49": "اليابان",
|
|
168
236
|
"#country+alt+i_ar+name+v_unterm": "اليابان",
|
|
169
237
|
"#country+alt+i_en+name+v_m49": "Japan",
|
|
@@ -177,11 +245,11 @@ class TestCountry:
|
|
|
177
245
|
"#country+alt+i_zh+name+v_m49": "日本",
|
|
178
246
|
"#country+alt+i_zh+name+v_unterm": "日本",
|
|
179
247
|
"#country+alt+name+v_dgacm": "",
|
|
180
|
-
"#country+alt+name+
|
|
248
|
+
"#country+alt+name+v_hpctools": "",
|
|
181
249
|
"#country+alt+name+v_iso": "",
|
|
182
250
|
"#country+alt+name+v_reliefweb": "",
|
|
183
251
|
"#country+code+num+v_m49": "392",
|
|
184
|
-
"#country+code+
|
|
252
|
+
"#country+code+v_hpctools": "112",
|
|
185
253
|
"#country+code+v_iso2": "JP",
|
|
186
254
|
"#country+code+v_iso3": "JPN",
|
|
187
255
|
"#country+code+v_reliefweb": "128",
|
|
@@ -209,6 +277,8 @@ class TestCountry:
|
|
|
209
277
|
}
|
|
210
278
|
assert Country.get_country_info_from_iso2("ab") is None
|
|
211
279
|
assert Country.get_country_info_from_iso2("TW") == {
|
|
280
|
+
"#country+alpha2+code": "",
|
|
281
|
+
"#country+alpha3+code": "",
|
|
212
282
|
"#country+alt+i_ar+name+v_m49": "",
|
|
213
283
|
"#country+alt+i_ar+name+v_unterm": "",
|
|
214
284
|
"#country+alt+i_en+name+v_m49": "",
|
|
@@ -222,11 +292,11 @@ class TestCountry:
|
|
|
222
292
|
"#country+alt+i_zh+name+v_m49": "",
|
|
223
293
|
"#country+alt+i_zh+name+v_unterm": "",
|
|
224
294
|
"#country+alt+name+v_dgacm": "",
|
|
225
|
-
"#country+alt+name+
|
|
295
|
+
"#country+alt+name+v_hpctools": "Taiwan, Province of China",
|
|
226
296
|
"#country+alt+name+v_iso": "",
|
|
227
297
|
"#country+alt+name+v_reliefweb": "China - Taiwan Province",
|
|
228
298
|
"#country+code+num+v_m49": "158",
|
|
229
|
-
"#country+code+
|
|
299
|
+
"#country+code+v_hpctools": "219",
|
|
230
300
|
"#country+code+v_iso2": "TW",
|
|
231
301
|
"#country+code+v_iso3": "TWN",
|
|
232
302
|
"#country+code+v_reliefweb": "61",
|
|
@@ -254,6 +324,8 @@ class TestCountry:
|
|
|
254
324
|
}
|
|
255
325
|
|
|
256
326
|
assert Country.get_country_info_from_iso2("PS") == {
|
|
327
|
+
"#country+alpha2+code": "",
|
|
328
|
+
"#country+alpha3+code": "",
|
|
257
329
|
"#country+alt+i_ar+name+v_m49": "دولة فلسطين",
|
|
258
330
|
"#country+alt+i_ar+name+v_unterm": "دولة فلسطين",
|
|
259
331
|
"#country+alt+i_en+name+v_m49": "State of Palestine",
|
|
@@ -267,11 +339,11 @@ class TestCountry:
|
|
|
267
339
|
"#country+alt+i_zh+name+v_m49": "巴勒斯坦国",
|
|
268
340
|
"#country+alt+i_zh+name+v_unterm": "巴勒斯坦国",
|
|
269
341
|
"#country+alt+name+v_dgacm": "",
|
|
270
|
-
"#country+alt+name+
|
|
342
|
+
"#country+alt+name+v_hpctools": "occupied Palestinian territory",
|
|
271
343
|
"#country+alt+name+v_iso": "Palestine, State of",
|
|
272
344
|
"#country+alt+name+v_reliefweb": "occupied Palestinian territory",
|
|
273
345
|
"#country+code+num+v_m49": "275",
|
|
274
|
-
"#country+code+
|
|
346
|
+
"#country+code+v_hpctools": "171",
|
|
275
347
|
"#country+code+v_iso2": "PS",
|
|
276
348
|
"#country+code+v_iso3": "PSE",
|
|
277
349
|
"#country+code+v_reliefweb": "180",
|
|
@@ -298,6 +370,56 @@ class TestCountry:
|
|
|
298
370
|
"#region+main+name+preferred": "Asia",
|
|
299
371
|
"#region+name+preferred+sub": "Western Asia",
|
|
300
372
|
}
|
|
373
|
+
with pytest.raises(LocationError):
|
|
374
|
+
Country.get_country_info_from_iso2("XK", exception=LocationError)
|
|
375
|
+
self.setup_unofficial_date()
|
|
376
|
+
assert Country.get_country_info_from_iso2("XK") == {
|
|
377
|
+
"#country+alpha2+code": "XK",
|
|
378
|
+
"#country+alpha3+code": "XKX",
|
|
379
|
+
"#country+alt+i_ar+name+v_m49": "",
|
|
380
|
+
"#country+alt+i_ar+name+v_unterm": "",
|
|
381
|
+
"#country+alt+i_en+name+v_m49": "",
|
|
382
|
+
"#country+alt+i_en+name+v_unterm": "Kosovo",
|
|
383
|
+
"#country+alt+i_es+name+v_m49": "",
|
|
384
|
+
"#country+alt+i_es+name+v_unterm": "",
|
|
385
|
+
"#country+alt+i_fr+name+v_m49": "",
|
|
386
|
+
"#country+alt+i_fr+name+v_unterm": "",
|
|
387
|
+
"#country+alt+i_ru+name+v_m49": "",
|
|
388
|
+
"#country+alt+i_ru+name+v_unterm": "",
|
|
389
|
+
"#country+alt+i_zh+name+v_m49": "",
|
|
390
|
+
"#country+alt+i_zh+name+v_unterm": "",
|
|
391
|
+
"#country+alt+name+v_dgacm": "",
|
|
392
|
+
"#country+alt+name+v_hpctools": "",
|
|
393
|
+
"#country+alt+name+v_iso": "",
|
|
394
|
+
"#country+alt+name+v_reliefweb": "",
|
|
395
|
+
"#country+code+num+v_m49": "",
|
|
396
|
+
"#country+code+v_hpctools": "",
|
|
397
|
+
"#country+code+v_iso2": "",
|
|
398
|
+
"#country+code+v_iso3": "",
|
|
399
|
+
"#country+code+v_reliefweb": "",
|
|
400
|
+
"#country+formal+i_en+name+v_unterm": "",
|
|
401
|
+
"#country+name+preferred": "Kosovo",
|
|
402
|
+
"#country+name+short+v_reliefweb": "",
|
|
403
|
+
"#country+regex": "kosovo",
|
|
404
|
+
"#currency+code": "EUR",
|
|
405
|
+
"#date+start": "1974-01-01",
|
|
406
|
+
"#geo+admin_level": "",
|
|
407
|
+
"#geo+lat": "42.61901705",
|
|
408
|
+
"#geo+lon": "20.90987836",
|
|
409
|
+
"#indicator+bool+gho": "",
|
|
410
|
+
"#indicator+bool+hrp": "",
|
|
411
|
+
"#indicator+incomelevel": "",
|
|
412
|
+
"#meta+bool+deprecated": "N",
|
|
413
|
+
"#meta+bool+independent": "N",
|
|
414
|
+
"#meta+id": "266",
|
|
415
|
+
"#region+code+intermediate": "",
|
|
416
|
+
"#region+code+main": "150",
|
|
417
|
+
"#region+code+sub": "39",
|
|
418
|
+
"#region+intermediate+name+preferred": "",
|
|
419
|
+
"#region+main+name+preferred": "Europe",
|
|
420
|
+
"#region+name+preferred+sub": "Southern Europe",
|
|
421
|
+
}
|
|
422
|
+
|
|
301
423
|
with pytest.raises(LocationError):
|
|
302
424
|
Country.get_country_info_from_iso2("ab", exception=LocationError)
|
|
303
425
|
|
|
@@ -319,6 +441,13 @@ class TestCountry:
|
|
|
319
441
|
)
|
|
320
442
|
assert Country.get_country_name_from_iso2("TW") == "Taiwan (Province of China)"
|
|
321
443
|
assert Country.get_country_name_from_iso2("PS") == "oPt"
|
|
444
|
+
with pytest.raises(LocationError):
|
|
445
|
+
Country.get_country_name_from_iso2("AN", exception=LocationError)
|
|
446
|
+
self.setup_unofficial_date()
|
|
447
|
+
assert (
|
|
448
|
+
Country.get_country_name_from_iso2("AN")
|
|
449
|
+
== "Netherlands Antilles (The Netherlands)"
|
|
450
|
+
)
|
|
322
451
|
|
|
323
452
|
def test_get_currency_from_iso2(self):
|
|
324
453
|
assert Country.get_currency_from_iso2("jp") == "JPY"
|
|
@@ -343,6 +472,8 @@ class TestCountry:
|
|
|
343
472
|
|
|
344
473
|
def test_get_country_info_from_m49(self):
|
|
345
474
|
assert Country.get_country_info_from_m49(4) == {
|
|
475
|
+
"#country+alpha2+code": "",
|
|
476
|
+
"#country+alpha3+code": "",
|
|
346
477
|
"#country+alt+i_ar+name+v_m49": "أفغانستان",
|
|
347
478
|
"#country+alt+i_ar+name+v_unterm": "أفغانستان",
|
|
348
479
|
"#country+alt+i_en+name+v_m49": "Afghanistan",
|
|
@@ -356,11 +487,11 @@ class TestCountry:
|
|
|
356
487
|
"#country+alt+i_zh+name+v_m49": "阿富汗",
|
|
357
488
|
"#country+alt+i_zh+name+v_unterm": "阿富汗",
|
|
358
489
|
"#country+alt+name+v_dgacm": "",
|
|
359
|
-
"#country+alt+name+
|
|
490
|
+
"#country+alt+name+v_hpctools": "",
|
|
360
491
|
"#country+alt+name+v_iso": "",
|
|
361
492
|
"#country+alt+name+v_reliefweb": "",
|
|
362
493
|
"#country+code+num+v_m49": "4",
|
|
363
|
-
"#country+code+
|
|
494
|
+
"#country+code+v_hpctools": "1",
|
|
364
495
|
"#country+code+v_iso2": "AF",
|
|
365
496
|
"#country+code+v_iso3": "AFG",
|
|
366
497
|
"#country+code+v_reliefweb": "13",
|
|
@@ -387,6 +518,8 @@ class TestCountry:
|
|
|
387
518
|
"#region+name+preferred+sub": "Southern Asia",
|
|
388
519
|
}
|
|
389
520
|
assert Country.get_country_info_from_m49(882) == {
|
|
521
|
+
"#country+alpha2+code": "",
|
|
522
|
+
"#country+alpha3+code": "",
|
|
390
523
|
"#country+alt+i_ar+name+v_m49": "ساموا",
|
|
391
524
|
"#country+alt+i_ar+name+v_unterm": "ساموا",
|
|
392
525
|
"#country+alt+i_en+name+v_m49": "Samoa",
|
|
@@ -400,11 +533,11 @@ class TestCountry:
|
|
|
400
533
|
"#country+alt+i_zh+name+v_m49": "萨摩亚",
|
|
401
534
|
"#country+alt+i_zh+name+v_unterm": "萨摩亚",
|
|
402
535
|
"#country+alt+name+v_dgacm": "",
|
|
403
|
-
"#country+alt+name+
|
|
536
|
+
"#country+alt+name+v_hpctools": "",
|
|
404
537
|
"#country+alt+name+v_iso": "",
|
|
405
538
|
"#country+alt+name+v_reliefweb": "",
|
|
406
539
|
"#country+code+num+v_m49": "882",
|
|
407
|
-
"#country+code+
|
|
540
|
+
"#country+code+v_hpctools": "193",
|
|
408
541
|
"#country+code+v_iso2": "WS",
|
|
409
542
|
"#country+code+v_iso3": "WSM",
|
|
410
543
|
"#country+code+v_reliefweb": "204",
|
|
@@ -431,6 +564,8 @@ class TestCountry:
|
|
|
431
564
|
"#region+name+preferred+sub": "Polynesia",
|
|
432
565
|
}
|
|
433
566
|
assert Country.get_country_info_from_m49(275) == {
|
|
567
|
+
"#country+alpha2+code": "",
|
|
568
|
+
"#country+alpha3+code": "",
|
|
434
569
|
"#country+alt+i_ar+name+v_m49": "دولة فلسطين",
|
|
435
570
|
"#country+alt+i_ar+name+v_unterm": "دولة فلسطين",
|
|
436
571
|
"#country+alt+i_en+name+v_m49": "State of Palestine",
|
|
@@ -444,11 +579,11 @@ class TestCountry:
|
|
|
444
579
|
"#country+alt+i_zh+name+v_m49": "巴勒斯坦国",
|
|
445
580
|
"#country+alt+i_zh+name+v_unterm": "巴勒斯坦国",
|
|
446
581
|
"#country+alt+name+v_dgacm": "",
|
|
447
|
-
"#country+alt+name+
|
|
582
|
+
"#country+alt+name+v_hpctools": "occupied Palestinian territory",
|
|
448
583
|
"#country+alt+name+v_iso": "Palestine, State of",
|
|
449
584
|
"#country+alt+name+v_reliefweb": "occupied Palestinian territory",
|
|
450
585
|
"#country+code+num+v_m49": "275",
|
|
451
|
-
"#country+code+
|
|
586
|
+
"#country+code+v_hpctools": "171",
|
|
452
587
|
"#country+code+v_iso2": "PS",
|
|
453
588
|
"#country+code+v_iso3": "PSE",
|
|
454
589
|
"#country+code+v_reliefweb": "180",
|
|
@@ -688,6 +823,9 @@ class TestCountry:
|
|
|
688
823
|
Country.get_iso3_country_code("abc", exception=ValueError)
|
|
689
824
|
with pytest.raises(ValueError):
|
|
690
825
|
Country.get_iso3_country_code_fuzzy("abcde", exception=ValueError)
|
|
826
|
+
self.setup_unofficial_date()
|
|
827
|
+
assert Country.get_iso3_country_code_fuzzy("Kosovo") == ("XKX", True)
|
|
828
|
+
assert Country.get_iso3_country_code_fuzzy("Kosovo*") == ("XKX", False)
|
|
691
829
|
|
|
692
830
|
def test_get_countries_in_region(self):
|
|
693
831
|
assert Country.get_countries_in_region("Eastern Asia") == [
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/.github/workflows/run-python-tests.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_List_1.json
RENAMED
|
File without changes
|
{hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/fixtures/wfp/Currency_List_2.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.3 → hdx_python_country-3.9.5}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
File without changes
|