hdx-python-country 3.9.2__tar.gz → 3.9.4__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.
Files changed (51) hide show
  1. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/.github/workflows/publish.yaml +1 -1
  2. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/PKG-INFO +90 -2
  3. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/README.md +88 -0
  4. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/documentation/index.md +4 -3
  5. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/pyproject.toml +1 -1
  6. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/requirements.txt +38 -40
  7. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +6 -6
  8. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/_version.py +2 -2
  9. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/country.py +50 -16
  10. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/Countries_UZB_Deleted.csv +6 -6
  11. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/test_country.py +149 -3
  12. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/test_currency.py +9 -1
  13. hdx_python_country-3.9.2/CONTRIBUTING.md +0 -53
  14. /hdx_python_country-3.9.2/coveragerc → /hdx_python_country-3.9.4/.coveragerc +0 -0
  15. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/.github/workflows/run-python-tests.yaml +0 -0
  16. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/.gitignore +0 -0
  17. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/.pre-commit-config.yaml +0 -0
  18. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/LICENSE +0 -0
  19. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/documentation/.readthedocs.yaml +0 -0
  20. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/documentation/mkdocs.yaml +0 -0
  21. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/hatch.toml +0 -0
  22. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/pytest.ini +0 -0
  23. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/ruff.toml +0 -0
  24. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/__init__.py +0 -0
  25. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/adminlevel.py +0 -0
  26. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/currency.py +0 -0
  27. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/int_timestamp.py +0 -0
  28. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/wfp_api.py +0 -0
  29. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/src/hdx/location/wfp_exchangerates.py +0 -0
  30. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/adminlevel.yaml +0 -0
  31. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/adminlevelparent.yaml +0 -0
  32. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
  33. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
  34. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/secondary_historic_rates.csv +0 -0
  35. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/secondary_rates.json +0 -0
  36. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_List_1.json +0 -0
  37. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_List_2.json +0 -0
  38. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
  39. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
  40. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
  41. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
  42. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
  43. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
  44. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
  45. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
  46. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
  47. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
  48. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/__init__.py +0 -0
  49. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/conftest.py +0 -0
  50. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/test_adminlevel.py +0 -0
  51. {hdx_python_country-3.9.2 → hdx_python_country-3.9.4}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
@@ -10,7 +10,7 @@ jobs:
10
10
 
11
11
  environment:
12
12
  name: pypi
13
- url: https://pypi.org/p/hdx-python-utilities
13
+ url: https://pypi.org/p/hdx-python-country
14
14
 
15
15
  permissions:
16
16
  id-token: write # IMPORTANT: mandatory for trusted publishing
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hdx-python-country
3
- Version: 3.9.2
3
+ Version: 3.9.4
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.5
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
@@ -69,3 +69,91 @@ For more information, please read the [documentation](https://hdx-python-country
69
69
  This library is part of the [Humanitarian Data Exchange](https://data.humdata.org/)
70
70
  (HDX) project. If you have humanitarian related data, please upload your datasets to
71
71
  HDX.
72
+
73
+ ## Development
74
+
75
+ ### Environment
76
+
77
+ Development is currently done using Python 3.12. We recommend using a virtual
78
+ environment such as ``venv``:
79
+
80
+ ```shell
81
+ python -m venv venv
82
+ source venv/bin/activate
83
+ ```
84
+
85
+ In your virtual environment, install all packages for development by running:
86
+
87
+ ```shell
88
+ pip install -r requirements.txt
89
+ ```
90
+
91
+ ### Pre-commit
92
+
93
+ Be sure to install `pre-commit`, which is run every time you make a git commit:
94
+
95
+ ```shell
96
+ pip install pre-commit
97
+ pre-commit install
98
+ ```
99
+
100
+ With pre-commit, all code is formatted according to
101
+ [ruff](https://docs.astral.sh/ruff/) guidelines.
102
+
103
+ To check if your changes pass pre-commit without committing, run:
104
+
105
+ ```shell
106
+ pre-commit run --all-files
107
+ ```
108
+
109
+ ### Testing
110
+
111
+ Ensure you have the required packages to run the tests:
112
+
113
+ ```shell
114
+ pip install -r requirements.txt
115
+ ```
116
+
117
+ To run the tests and view coverage, execute:
118
+
119
+ ```shell
120
+ pytest -c --cov hdx
121
+ ```
122
+
123
+ ## Packages
124
+
125
+ [uv](https://github.com/astral-sh/uv) is used for package management. If
126
+ you’ve introduced a new package to the source code (i.e. anywhere in `src/`),
127
+ please add it to the `project.dependencies` section of `pyproject.toml` with
128
+ any known version constraints.
129
+
130
+ To add packages required only for testing, add them to the `test` section under
131
+ `[project.optional-dependencies]`.
132
+
133
+ Any changes to the dependencies will be automatically reflected in
134
+ `requirements.txt` with `pre-commit`, but you can re-generate the file without
135
+ committing by executing:
136
+
137
+ ```shell
138
+ pre-commit run pip-compile --all-files
139
+ ```
140
+
141
+ ## Project
142
+
143
+ [Hatch](https://hatch.pypa.io/) is used for project management. The project can be built using:
144
+
145
+ ```shell
146
+ hatch build
147
+ ```
148
+
149
+ Linting and syntax checking can be run with:
150
+
151
+ ```shell
152
+ hatch fmt --check
153
+ ```
154
+
155
+ Tests can be executed using:
156
+
157
+ ```shell
158
+ hatch test
159
+ ```
@@ -30,3 +30,91 @@ For more information, please read the [documentation](https://hdx-python-country
30
30
  This library is part of the [Humanitarian Data Exchange](https://data.humdata.org/)
31
31
  (HDX) project. If you have humanitarian related data, please upload your datasets to
32
32
  HDX.
33
+
34
+ ## Development
35
+
36
+ ### Environment
37
+
38
+ Development is currently done using Python 3.12. We recommend using a virtual
39
+ environment such as ``venv``:
40
+
41
+ ```shell
42
+ python -m venv venv
43
+ source venv/bin/activate
44
+ ```
45
+
46
+ In your virtual environment, install all packages for development by running:
47
+
48
+ ```shell
49
+ pip install -r requirements.txt
50
+ ```
51
+
52
+ ### Pre-commit
53
+
54
+ Be sure to install `pre-commit`, which is run every time you make a git commit:
55
+
56
+ ```shell
57
+ pip install pre-commit
58
+ pre-commit install
59
+ ```
60
+
61
+ With pre-commit, all code is formatted according to
62
+ [ruff](https://docs.astral.sh/ruff/) guidelines.
63
+
64
+ To check if your changes pass pre-commit without committing, run:
65
+
66
+ ```shell
67
+ pre-commit run --all-files
68
+ ```
69
+
70
+ ### Testing
71
+
72
+ Ensure you have the required packages to run the tests:
73
+
74
+ ```shell
75
+ pip install -r requirements.txt
76
+ ```
77
+
78
+ To run the tests and view coverage, execute:
79
+
80
+ ```shell
81
+ pytest -c --cov hdx
82
+ ```
83
+
84
+ ## Packages
85
+
86
+ [uv](https://github.com/astral-sh/uv) is used for package management. If
87
+ you’ve introduced a new package to the source code (i.e. anywhere in `src/`),
88
+ please add it to the `project.dependencies` section of `pyproject.toml` with
89
+ any known version constraints.
90
+
91
+ To add packages required only for testing, add them to the `test` section under
92
+ `[project.optional-dependencies]`.
93
+
94
+ Any changes to the dependencies will be automatically reflected in
95
+ `requirements.txt` with `pre-commit`, but you can re-generate the file without
96
+ committing by executing:
97
+
98
+ ```shell
99
+ pre-commit run pip-compile --all-files
100
+ ```
101
+
102
+ ## Project
103
+
104
+ [Hatch](https://hatch.pypa.io/) is used for project management. The project can be built using:
105
+
106
+ ```shell
107
+ hatch build
108
+ ```
109
+
110
+ Linting and syntax checking can be run with:
111
+
112
+ ```shell
113
+ hatch fmt --check
114
+ ```
115
+
116
+ Tests can be executed using:
117
+
118
+ ```shell
119
+ hatch test
120
+ ```
@@ -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 using non live data from repo rather and override default country name
75
- # (Leaving out this step will use live data and no overrides)
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.
@@ -34,7 +34,7 @@ classifiers = [
34
34
  requires-python = ">=3.8"
35
35
 
36
36
  dependencies = [
37
- "hdx-python-utilities>=3.8.5",
37
+ "hdx-python-utilities>=3.8.7",
38
38
  "libhxl>=5.2.2",
39
39
  "tenacity",
40
40
  ]
@@ -2,7 +2,7 @@
2
2
  # uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
3
3
  annotated-types==0.7.0
4
4
  # via pydantic
5
- astdoc==1.1.5
5
+ astdoc==1.2.1
6
6
  # via mkapi
7
7
  attrs==25.3.0
8
8
  # via
@@ -14,13 +14,13 @@ babel==2.17.0
14
14
  # via mkdocs-material
15
15
  backrefs==5.8
16
16
  # via mkdocs-material
17
- certifi==2025.1.31
17
+ certifi==2025.4.26
18
18
  # via requests
19
19
  cfgv==3.4.0
20
20
  # via pre-commit
21
21
  chardet==5.2.0
22
22
  # via frictionless
23
- charset-normalizer==3.4.1
23
+ charset-normalizer==3.4.2
24
24
  # via requests
25
25
  click==8.1.8
26
26
  # via
@@ -28,7 +28,7 @@ click==8.1.8
28
28
  # typer
29
29
  colorama==0.4.6
30
30
  # via mkdocs-material
31
- coverage==7.7.1
31
+ coverage==7.8.0
32
32
  # via pytest-cov
33
33
  distlib==0.3.9
34
34
  # via virtualenv
@@ -36,19 +36,19 @@ et-xmlfile==2.0.0
36
36
  # via openpyxl
37
37
  filelock==3.18.0
38
38
  # via virtualenv
39
- frictionless==5.18.0
39
+ frictionless==5.18.1
40
40
  # via hdx-python-utilities
41
41
  ghp-import==2.1.0
42
42
  # via mkdocs
43
- hdx-python-utilities==3.8.5
43
+ hdx-python-utilities==3.8.7
44
44
  # via hdx-python-country (pyproject.toml)
45
- humanize==4.12.2
45
+ humanize==4.12.3
46
46
  # via frictionless
47
- identify==2.6.9
47
+ identify==2.6.10
48
48
  # via pre-commit
49
49
  idna==3.10
50
50
  # via requests
51
- ijson==3.3.0
51
+ ijson==3.4.0
52
52
  # via hdx-python-utilities
53
53
  iniconfig==2.1.0
54
54
  # via pytest
@@ -68,21 +68,20 @@ jsonschema==4.23.0
68
68
  # via
69
69
  # frictionless
70
70
  # tableschema-to-template
71
- jsonschema-specifications==2024.10.1
71
+ jsonschema-specifications==2025.4.1
72
72
  # via jsonschema
73
73
  libhxl==5.2.2
74
74
  # via hdx-python-country (pyproject.toml)
75
75
  loguru==0.7.3
76
76
  # via hdx-python-utilities
77
- markdown==3.7
77
+ markdown==3.8
78
78
  # via
79
- # astdoc
80
79
  # mkdocs
81
80
  # mkdocs-material
82
81
  # pymdown-extensions
83
82
  markdown-it-py==3.0.0
84
83
  # via rich
85
- marko==2.1.2
84
+ marko==2.1.3
86
85
  # via frictionless
87
86
  markupsafe==3.0.2
88
87
  # via
@@ -94,7 +93,7 @@ mergedeep==1.3.4
94
93
  # via
95
94
  # mkdocs
96
95
  # mkdocs-get-deps
97
- mkapi==4.1.3
96
+ mkapi==4.4.0
98
97
  # via hdx-python-country (pyproject.toml)
99
98
  mkdocs==1.6.1
100
99
  # via
@@ -102,7 +101,7 @@ mkdocs==1.6.1
102
101
  # mkdocs-material
103
102
  mkdocs-get-deps==0.2.0
104
103
  # via mkdocs
105
- mkdocs-material==9.6.9
104
+ mkdocs-material==9.6.14
106
105
  # via mkapi
107
106
  mkdocs-material-extensions==1.3.1
108
107
  # via mkdocs-material
@@ -110,7 +109,7 @@ nodeenv==1.9.1
110
109
  # via pre-commit
111
110
  openpyxl==3.1.5
112
111
  # via hdx-python-utilities
113
- packaging==24.2
112
+ packaging==25.0
114
113
  # via
115
114
  # mkdocs
116
115
  # pytest
@@ -118,13 +117,13 @@ paginate==0.5.7
118
117
  # via mkdocs-material
119
118
  pathspec==0.12.1
120
119
  # via mkdocs
121
- petl==1.7.15
120
+ petl==1.7.16
122
121
  # via frictionless
123
- platformdirs==4.3.7
122
+ platformdirs==4.3.8
124
123
  # via
125
124
  # mkdocs-get-deps
126
125
  # virtualenv
127
- pluggy==1.5.0
126
+ pluggy==1.6.0
128
127
  # via pytest
129
128
  ply==3.11
130
129
  # via
@@ -132,15 +131,15 @@ ply==3.11
132
131
  # libhxl
133
132
  pre-commit==4.2.0
134
133
  # via hdx-python-country (pyproject.toml)
135
- pydantic==2.10.6
134
+ pydantic==2.11.4
136
135
  # via frictionless
137
- pydantic-core==2.27.2
136
+ pydantic-core==2.33.2
138
137
  # via pydantic
139
138
  pygments==2.19.1
140
139
  # via
141
140
  # mkdocs-material
142
141
  # rich
143
- pymdown-extensions==10.14.3
142
+ pymdown-extensions==10.15
144
143
  # via mkdocs-material
145
144
  pyphonetics==0.5.3
146
145
  # via hdx-python-utilities
@@ -148,7 +147,7 @@ pytest==8.3.5
148
147
  # via
149
148
  # hdx-python-country (pyproject.toml)
150
149
  # pytest-cov
151
- pytest-cov==6.0.0
150
+ pytest-cov==6.1.1
152
151
  # via hdx-python-country (pyproject.toml)
153
152
  python-dateutil==2.9.0.post0
154
153
  # via
@@ -169,7 +168,7 @@ pyyaml==6.0.2
169
168
  # pymdown-extensions
170
169
  # pyyaml-env-tag
171
170
  # tableschema-to-template
172
- pyyaml-env-tag==0.1
171
+ pyyaml-env-tag==1.1
173
172
  # via mkdocs
174
173
  ratelimit==2.2.1
175
174
  # via hdx-python-utilities
@@ -187,11 +186,9 @@ requests-file==2.1.0
187
186
  # via hdx-python-utilities
188
187
  rfc3986==2.0.0
189
188
  # via frictionless
190
- rich==13.9.4
191
- # via
192
- # mkapi
193
- # typer
194
- rpds-py==0.23.1
189
+ rich==14.0.0
190
+ # via typer
191
+ rpds-py==0.25.0
195
192
  # via
196
193
  # jsonschema
197
194
  # referencing
@@ -205,38 +202,39 @@ simpleeval==1.0.3
205
202
  # via frictionless
206
203
  six==1.17.0
207
204
  # via python-dateutil
208
- stringcase==1.2.0
209
- # via frictionless
210
- structlog==25.2.0
205
+ structlog==25.3.0
211
206
  # via libhxl
212
207
  tableschema-to-template==0.0.13
213
208
  # via hdx-python-utilities
214
209
  tabulate==0.9.0
215
210
  # via frictionless
216
- tenacity==9.0.0
211
+ tenacity==9.1.2
217
212
  # via hdx-python-country (pyproject.toml)
218
213
  text-unidecode==1.3
219
214
  # via python-slugify
220
- typer==0.15.2
215
+ typer==0.15.4
221
216
  # via frictionless
222
- typing-extensions==4.12.2
217
+ typing-extensions==4.13.2
223
218
  # via
224
219
  # frictionless
225
220
  # pydantic
226
221
  # pydantic-core
227
222
  # referencing
228
223
  # typer
229
- unidecode==1.3.8
224
+ # typing-inspection
225
+ typing-inspection==0.4.0
226
+ # via pydantic
227
+ unidecode==1.4.0
230
228
  # via
231
229
  # libhxl
232
230
  # pyphonetics
233
- urllib3==2.3.0
231
+ urllib3==2.4.0
234
232
  # via
235
233
  # libhxl
236
234
  # requests
237
- validators==0.34.0
235
+ validators==0.35.0
238
236
  # via frictionless
239
- virtualenv==20.29.3
237
+ virtualenv==20.31.2
240
238
  # via pre-commit
241
239
  watchdog==6.0.0
242
240
  # via mkdocs
@@ -248,7 +246,7 @@ xlrd3==1.1.0
248
246
  # via libhxl
249
247
  xlsx2csv==0.8.4
250
248
  # via hdx-python-utilities
251
- xlsxwriter==3.2.2
249
+ xlsxwriter==3.2.3
252
250
  # via tableschema-to-template
253
251
  xlwt==1.3.0
254
252
  # via hdx-python-utilities
@@ -1,5 +1,5 @@
1
1
  ID,RW ID,m49 numerical code,FTS 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,FTS 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_fts,,,#meta+independent+bool,#meta+deprecated+bool,#indicator+hrp+bool,#indicator+gho+bool,#country +code +v_iso2,#country +code +v_iso3,,,#country +name +preferred,#country +name +alt +v_iso,#country +name +alt +v_dgacm,#country +name +alt +v_fts,#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,
2
+ #meta +id,#country +code +v_reliefweb,#country +code +num +v_m49,#country +code +v_fts,,,#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_fts,#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,,Y,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
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,,Y,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,,,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
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,,,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
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,,,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
+ 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
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '3.9.2'
21
- __version_tuple__ = version_tuple = (3, 9, 2)
20
+ __version__ = version = '3.9.4'
21
+ __version_tuple__ = version_tuple = (3, 9, 4)
@@ -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: str) -> None:
166
+ def set_countriesdata(cls, countries: Dataset) -> None:
163
167
  """
164
- Set up countries data from data in form provided by UNStats and World Bank
168
+ Set up countries data from OCHA countries and territories dataset
165
169
 
166
170
  Args:
167
- countries (str): Countries data in HTML format provided by UNStats
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
- continue
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
- use_live: bool = None,
206
- country_name_overrides: Dict = None,
207
- country_name_mappings: Dict = None,
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
- use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
214
- country_name_overrides (Dict): Dictionary of mappings from iso3 to country name
215
- country_name_mappings (Dict): Dictionary of mappings from country name to iso3
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 use_live is None:
221
- use_live = cls._use_live
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 use_live:
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
  """
@@ -709,7 +743,7 @@ class Country:
709
743
  for simplification2 in simplifications:
710
744
  remove.append(simplification2)
711
745
  remove = "|".join(remove)
712
- regex = re.compile(r"\b(" + remove + r")\b", flags=re.IGNORECASE)
746
+ regex = re.compile(r"[^\w\s]|\b(" + remove + r")\b", flags=re.IGNORECASE)
713
747
  countryupper = regex.sub("", countryupper)
714
748
  countryupper = countryupper.strip()
715
749
  countryupper_words = get_words_in_sentence(countryupper)
@@ -1,5 +1,5 @@
1
1
  ID,RW ID,m49 numerical code,FTS 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,FTS 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_fts,,,#meta+independent+bool,#meta+deprecated+bool,#indicator+hrp+bool,#indicator+gho+bool,#country +code +v_iso2,#country +code +v_iso3,,,#country +name +preferred,#country +name +alt +v_iso,#country +name +alt +v_dgacm,#country +name +alt +v_fts,#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,
2
+ #meta +id,#country +code +v_reliefweb,#country +code +num +v_m49,#country +code +v_fts,,,#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_fts,#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,,Y,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
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,,Y,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,,,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
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,,,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
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,,,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
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
- @pytest.fixture(scope="function", autouse=True)
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",
@@ -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",
@@ -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_fts": "",
195
+ "#country+alt+name+v_iso": "",
196
+ "#country+alt+name+v_reliefweb": "",
197
+ "#country+code+num+v_m49": "",
198
+ "#country+code+v_fts": "",
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",
@@ -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": "",
@@ -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",
@@ -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_fts": "",
393
+ "#country+alt+name+v_iso": "",
394
+ "#country+alt+name+v_reliefweb": "",
395
+ "#country+code+num+v_m49": "",
396
+ "#country+code+v_fts": "",
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",
@@ -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",
@@ -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",
@@ -528,6 +663,14 @@ class TestCountry:
528
663
  assert Country.simplify_countryname(
529
664
  "Democratic People's Republic of Korea"
530
665
  ) == ("KOREA", ["DEMOCRATIC", "PEOPLE'S", "REPUBLIC", "OF"])
666
+ assert Country.simplify_countryname("Korea (the Republic of))") == (
667
+ "KOREA",
668
+ ["THE", "REPUBLIC", "OF"],
669
+ )
670
+ assert Country.simplify_countryname("Korea (the Republic of") == (
671
+ "KOREA",
672
+ ["THE", "REPUBLIC", "OF"],
673
+ )
531
674
  assert Country.simplify_countryname(
532
675
  "The former Yugoslav Republic of Macedonia"
533
676
  ) == ("MACEDONIA", ["THE", "FORMER", "YUGOSLAV", "REPUBLIC", "OF"])
@@ -680,6 +823,9 @@ class TestCountry:
680
823
  Country.get_iso3_country_code("abc", exception=ValueError)
681
824
  with pytest.raises(ValueError):
682
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)
683
829
 
684
830
  def test_get_countries_in_region(self):
685
831
  assert Country.get_countries_in_region("Eastern Asia") == [
@@ -106,8 +106,16 @@ class TestCurrency:
106
106
  Currency._rates_api = None
107
107
  with pytest.raises(CurrencyError):
108
108
  Currency.get_current_rate("gbp")
109
- Currency._rates_api = Currency._primary_rates_url
110
109
  assert Currency.get_current_rate("usd") == 1
110
+
111
+ Currency._cached_current_rates = {}
112
+ Currency._cached_historic_rates = {}
113
+ Currency._rates_api = ""
114
+ Currency._secondary_rates = {}
115
+ Currency._secondary_historic_rates = {}
116
+ Currency._fallback_to_current = False
117
+ Currency._no_historic = False
118
+ Currency.setup(no_historic=True)
111
119
  rate1gbp = Currency.get_current_rate("gbp")
112
120
  assert rate1gbp != 1
113
121
  rate1xdr = Currency.get_current_rate("xdr")
@@ -1,53 +0,0 @@
1
- # Development
2
-
3
- ## Environment
4
-
5
- Development is currently done using Python 3.12. We recommend using a virtual
6
- environment such as ``venv``:
7
-
8
- python3.12 -m venv venv
9
- source venv/bin/activate
10
-
11
- In your virtual environment, please install all packages for
12
- development by running:
13
-
14
- pip install -r requirements.txt
15
-
16
- ## Pre-Commit
17
-
18
- Also be sure to install `pre-commit`, which is run every time
19
- you make a git commit:
20
-
21
- pre-commit install
22
-
23
- With pre-commit, all code is formatted according to
24
- [ruff](https://github.com/astral-sh/ruff) guidelines.
25
-
26
- To check if your changes pass pre-commit without committing, run:
27
-
28
- pre-commit run --all-files
29
-
30
- ## Testing
31
-
32
- To run the tests and view coverage, execute:
33
-
34
- pytest --cov hdx
35
-
36
- Follow the example set out already in ``documentation/main.md`` as you write the documentation.
37
-
38
- ## Packages
39
-
40
- [pip-tools](https://github.com/jazzband/pip-tools) is used for
41
- package management. If you’ve introduced a new package to the
42
- source code (i.e.anywhere in `src/`), please add it to the
43
- `project.dependencies` section of
44
- `pyproject.toml` with any known version constraints.
45
-
46
- For adding packages for testing or development, add them to
47
- the `test` or `dev` sections under `[project.optional-dependencies]`.
48
-
49
- Any changes to the dependencies will be automatically reflected in
50
- `requirements.txt` with `pre-commit`, but you can re-generate
51
- the file without committing by executing:
52
-
53
- pre-commit run pip-compile --all-files