hdx-python-country 3.8.4__tar.gz → 3.8.6__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.8.4 → hdx_python_country-3.8.6}/.config/pre-commit-config.yaml +2 -2
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/PKG-INFO +4 -4
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/pyproject.toml +5 -3
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/requirements.txt +22 -22
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/adminlevel.py +2 -2
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/country.py +19 -17
- hdx_python_country-3.8.6/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/test_adminlevel.py +1 -1
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/test_country.py +21 -1
- hdx_python_country-3.8.4/src/hdx/location/phonetics.py +0 -56
- hdx_python_country-3.8.4/tests/hdx/location/__init__.py +0 -8
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.config/coveragerc +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.config/pytest.ini +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.config/ruff.toml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.gitignore +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/CONTRIBUTING.md +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/LICENSE +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/README.md +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/documentation/main.md +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/documentation/pydoc-markdown.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/currency.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/wfp_api.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_List_1.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_List_2.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/test_currency.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
|
@@ -8,7 +8,7 @@ repos:
|
|
|
8
8
|
- id: end-of-file-fixer
|
|
9
9
|
- id: check-ast
|
|
10
10
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
-
rev: v0.
|
|
11
|
+
rev: v0.8.6
|
|
12
12
|
hooks:
|
|
13
13
|
# Run the linter.
|
|
14
14
|
- id: ruff
|
|
@@ -17,7 +17,7 @@ repos:
|
|
|
17
17
|
- id: ruff-format
|
|
18
18
|
args: [--config, .config/ruff.toml]
|
|
19
19
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
20
|
-
rev: 0.
|
|
20
|
+
rev: 0.5.15
|
|
21
21
|
hooks:
|
|
22
22
|
# Run the pip compile
|
|
23
23
|
- id: pip-compile
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-country
|
|
3
|
-
Version: 3.8.
|
|
3
|
+
Version: 3.8.6
|
|
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
|
|
7
7
|
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
8
9
|
Keywords: HDX,country,country code,currencies,currency,exchange rate,foreign exchange,fx,iso 3166,iso2,iso3,location,region
|
|
9
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -24,9 +25,8 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
24
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
25
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
27
|
Requires-Python: >=3.8
|
|
27
|
-
Requires-Dist: hdx-python-utilities>=3.
|
|
28
|
+
Requires-Dist: hdx-python-utilities>=3.8.0
|
|
28
29
|
Requires-Dist: libhxl>=5.2.2
|
|
29
|
-
Requires-Dist: pyphonetics
|
|
30
30
|
Requires-Dist: tenacity
|
|
31
31
|
Provides-Extra: dev
|
|
32
32
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
@@ -34,9 +34,8 @@ classifiers = [
|
|
|
34
34
|
requires-python = ">=3.8"
|
|
35
35
|
|
|
36
36
|
dependencies = [
|
|
37
|
-
"hdx-python-utilities>=3.
|
|
37
|
+
"hdx-python-utilities>=3.8.0",
|
|
38
38
|
"libhxl>=5.2.2",
|
|
39
|
-
"pyphonetics",
|
|
40
39
|
"tenacity",
|
|
41
40
|
]
|
|
42
41
|
dynamic = ["version"]
|
|
@@ -65,6 +64,9 @@ packages = ["src/hdx"]
|
|
|
65
64
|
[tool.hatch.build.hooks.vcs]
|
|
66
65
|
version-file = "src/hdx/location/_version.py"
|
|
67
66
|
|
|
67
|
+
[tool.hatch.metadata]
|
|
68
|
+
allow-direct-references = true
|
|
69
|
+
|
|
68
70
|
# Versioning
|
|
69
71
|
|
|
70
72
|
[tool.hatch.version]
|
|
@@ -90,7 +92,7 @@ run = """
|
|
|
90
92
|
"""
|
|
91
93
|
|
|
92
94
|
[tool.hatch.envs.hatch-static-analysis]
|
|
93
|
-
dependencies = ["ruff==0.
|
|
95
|
+
dependencies = ["ruff==0.8.6"]
|
|
94
96
|
|
|
95
97
|
[tool.hatch.envs.hatch-static-analysis.scripts]
|
|
96
98
|
format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
|
|
@@ -2,23 +2,23 @@
|
|
|
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
|
-
attrs==24.
|
|
5
|
+
attrs==24.3.0
|
|
6
6
|
# via
|
|
7
7
|
# frictionless
|
|
8
8
|
# jsonlines
|
|
9
9
|
# jsonschema
|
|
10
10
|
# referencing
|
|
11
|
-
certifi==2024.
|
|
11
|
+
certifi==2024.12.14
|
|
12
12
|
# via requests
|
|
13
13
|
cfgv==3.4.0
|
|
14
14
|
# via pre-commit
|
|
15
15
|
chardet==5.2.0
|
|
16
16
|
# via frictionless
|
|
17
|
-
charset-normalizer==3.4.
|
|
17
|
+
charset-normalizer==3.4.1
|
|
18
18
|
# via requests
|
|
19
|
-
click==8.1.
|
|
19
|
+
click==8.1.8
|
|
20
20
|
# via typer
|
|
21
|
-
coverage==7.6.
|
|
21
|
+
coverage==7.6.10
|
|
22
22
|
# via pytest-cov
|
|
23
23
|
distlib==0.3.9
|
|
24
24
|
# via virtualenv
|
|
@@ -28,11 +28,11 @@ filelock==3.16.1
|
|
|
28
28
|
# via virtualenv
|
|
29
29
|
frictionless==5.18.0
|
|
30
30
|
# via hdx-python-utilities
|
|
31
|
-
hdx-python-utilities==3.
|
|
31
|
+
hdx-python-utilities==3.8.0
|
|
32
32
|
# via hdx-python-country (pyproject.toml)
|
|
33
33
|
humanize==4.11.0
|
|
34
34
|
# via frictionless
|
|
35
|
-
identify==2.6.
|
|
35
|
+
identify==2.6.5
|
|
36
36
|
# via pre-commit
|
|
37
37
|
idna==3.10
|
|
38
38
|
# via requests
|
|
@@ -42,7 +42,7 @@ iniconfig==2.0.0
|
|
|
42
42
|
# via pytest
|
|
43
43
|
isodate==0.7.2
|
|
44
44
|
# via frictionless
|
|
45
|
-
jinja2==3.1.
|
|
45
|
+
jinja2==3.1.5
|
|
46
46
|
# via frictionless
|
|
47
47
|
jsonlines==4.0.0
|
|
48
48
|
# via hdx-python-utilities
|
|
@@ -56,7 +56,7 @@ jsonschema-specifications==2024.10.1
|
|
|
56
56
|
# via jsonschema
|
|
57
57
|
libhxl==5.2.2
|
|
58
58
|
# via hdx-python-country (pyproject.toml)
|
|
59
|
-
loguru==0.7.
|
|
59
|
+
loguru==0.7.3
|
|
60
60
|
# via hdx-python-utilities
|
|
61
61
|
markdown-it-py==3.0.0
|
|
62
62
|
# via rich
|
|
@@ -84,15 +84,15 @@ ply==3.11
|
|
|
84
84
|
# libhxl
|
|
85
85
|
pre-commit==4.0.1
|
|
86
86
|
# via hdx-python-country (pyproject.toml)
|
|
87
|
-
pydantic==2.
|
|
87
|
+
pydantic==2.10.5
|
|
88
88
|
# via frictionless
|
|
89
|
-
pydantic-core==2.
|
|
89
|
+
pydantic-core==2.27.2
|
|
90
90
|
# via pydantic
|
|
91
|
-
pygments==2.
|
|
91
|
+
pygments==2.19.1
|
|
92
92
|
# via rich
|
|
93
93
|
pyphonetics==0.5.3
|
|
94
|
-
# via hdx-python-
|
|
95
|
-
pytest==8.3.
|
|
94
|
+
# via hdx-python-utilities
|
|
95
|
+
pytest==8.3.4
|
|
96
96
|
# via
|
|
97
97
|
# hdx-python-country (pyproject.toml)
|
|
98
98
|
# pytest-cov
|
|
@@ -129,11 +129,11 @@ rfc3986==2.0.0
|
|
|
129
129
|
# via frictionless
|
|
130
130
|
rich==13.9.4
|
|
131
131
|
# via typer
|
|
132
|
-
rpds-py==0.
|
|
132
|
+
rpds-py==0.22.3
|
|
133
133
|
# via
|
|
134
134
|
# jsonschema
|
|
135
135
|
# referencing
|
|
136
|
-
ruamel-yaml==0.18.
|
|
136
|
+
ruamel-yaml==0.18.10
|
|
137
137
|
# via hdx-python-utilities
|
|
138
138
|
ruamel-yaml-clib==0.2.12
|
|
139
139
|
# via ruamel-yaml
|
|
@@ -141,7 +141,7 @@ shellingham==1.5.4
|
|
|
141
141
|
# via typer
|
|
142
142
|
simpleeval==1.0.3
|
|
143
143
|
# via frictionless
|
|
144
|
-
six==1.
|
|
144
|
+
six==1.17.0
|
|
145
145
|
# via python-dateutil
|
|
146
146
|
stringcase==1.2.0
|
|
147
147
|
# via frictionless
|
|
@@ -155,7 +155,7 @@ tenacity==9.0.0
|
|
|
155
155
|
# via hdx-python-country (pyproject.toml)
|
|
156
156
|
text-unidecode==1.3
|
|
157
157
|
# via python-slugify
|
|
158
|
-
typer==0.
|
|
158
|
+
typer==0.15.1
|
|
159
159
|
# via frictionless
|
|
160
160
|
typing-extensions==4.12.2
|
|
161
161
|
# via
|
|
@@ -167,21 +167,21 @@ unidecode==1.3.8
|
|
|
167
167
|
# via
|
|
168
168
|
# libhxl
|
|
169
169
|
# pyphonetics
|
|
170
|
-
urllib3==2.
|
|
170
|
+
urllib3==2.3.0
|
|
171
171
|
# via
|
|
172
172
|
# libhxl
|
|
173
173
|
# requests
|
|
174
174
|
validators==0.34.0
|
|
175
175
|
# via frictionless
|
|
176
|
-
virtualenv==20.
|
|
176
|
+
virtualenv==20.28.1
|
|
177
177
|
# via pre-commit
|
|
178
|
-
wheel==0.45.
|
|
178
|
+
wheel==0.45.1
|
|
179
179
|
# via libhxl
|
|
180
180
|
xlrd==2.0.1
|
|
181
181
|
# via hdx-python-utilities
|
|
182
182
|
xlrd3==1.1.0
|
|
183
183
|
# via libhxl
|
|
184
|
-
xlsx2csv==0.8.
|
|
184
|
+
xlsx2csv==0.8.4
|
|
185
185
|
# via hdx-python-utilities
|
|
186
186
|
xlsxwriter==3.2.0
|
|
187
187
|
# via tableschema-to-template
|
|
@@ -7,11 +7,11 @@ from hxl import InputOptions
|
|
|
7
7
|
from hxl.input import HXLIOException
|
|
8
8
|
|
|
9
9
|
from hdx.location.country import Country
|
|
10
|
-
from hdx.location.phonetics import Phonetics
|
|
11
10
|
from hdx.utilities.base_downloader import DownloadError
|
|
12
11
|
from hdx.utilities.dictandlist import dict_of_sets_add
|
|
12
|
+
from hdx.utilities.matching import Phonetics, multiple_replace
|
|
13
13
|
from hdx.utilities.retriever import Retrieve
|
|
14
|
-
from hdx.utilities.text import
|
|
14
|
+
from hdx.utilities.text import normalise
|
|
15
15
|
from hdx.utilities.typehint import ListTuple
|
|
16
16
|
|
|
17
17
|
logger = logging.getLogger(__name__)
|
|
@@ -212,7 +212,7 @@ class Country:
|
|
|
212
212
|
@classmethod
|
|
213
213
|
def countriesdata(
|
|
214
214
|
cls,
|
|
215
|
-
use_live: bool =
|
|
215
|
+
use_live: bool = None,
|
|
216
216
|
country_name_overrides: Dict = None,
|
|
217
217
|
country_name_mappings: Dict = None,
|
|
218
218
|
) -> List[Dict[str, Dict]]:
|
|
@@ -227,6 +227,8 @@ class Country:
|
|
|
227
227
|
Returns:
|
|
228
228
|
List[Dict[str,Dict]]: Countries dictionaries
|
|
229
229
|
"""
|
|
230
|
+
if use_live is None:
|
|
231
|
+
use_live = cls._use_live
|
|
230
232
|
if cls._countriesdata is None:
|
|
231
233
|
countries = None
|
|
232
234
|
if country_name_overrides is not None:
|
|
@@ -326,7 +328,7 @@ class Country:
|
|
|
326
328
|
def get_country_info_from_iso3(
|
|
327
329
|
cls,
|
|
328
330
|
iso3: str,
|
|
329
|
-
use_live: bool =
|
|
331
|
+
use_live: bool = None,
|
|
330
332
|
exception: Optional[ExceptionUpperBound] = None,
|
|
331
333
|
) -> Optional[Dict[str, str]]:
|
|
332
334
|
"""Get country information from ISO3 code
|
|
@@ -352,7 +354,7 @@ class Country:
|
|
|
352
354
|
def get_country_name_from_iso3(
|
|
353
355
|
cls,
|
|
354
356
|
iso3: str,
|
|
355
|
-
use_live: bool =
|
|
357
|
+
use_live: bool = None,
|
|
356
358
|
exception: Optional[ExceptionUpperBound] = None,
|
|
357
359
|
formal: bool = False,
|
|
358
360
|
) -> Optional[str]:
|
|
@@ -389,7 +391,7 @@ class Country:
|
|
|
389
391
|
def get_currency_from_iso3(
|
|
390
392
|
cls,
|
|
391
393
|
iso3: str,
|
|
392
|
-
use_live: bool =
|
|
394
|
+
use_live: bool = None,
|
|
393
395
|
exception: Optional[ExceptionUpperBound] = None,
|
|
394
396
|
) -> Optional[int]:
|
|
395
397
|
"""Get currency code from ISO3 code
|
|
@@ -415,7 +417,7 @@ class Country:
|
|
|
415
417
|
def get_iso2_from_iso3(
|
|
416
418
|
cls,
|
|
417
419
|
iso3: str,
|
|
418
|
-
use_live: bool =
|
|
420
|
+
use_live: bool = None,
|
|
419
421
|
exception: Optional[ExceptionUpperBound] = None,
|
|
420
422
|
) -> Optional[str]:
|
|
421
423
|
"""Get ISO2 from ISO3 code
|
|
@@ -441,7 +443,7 @@ class Country:
|
|
|
441
443
|
def get_iso3_from_iso2(
|
|
442
444
|
cls,
|
|
443
445
|
iso2: str,
|
|
444
|
-
use_live: bool =
|
|
446
|
+
use_live: bool = None,
|
|
445
447
|
exception: Optional[ExceptionUpperBound] = None,
|
|
446
448
|
) -> Optional[str]:
|
|
447
449
|
"""Get ISO3 from ISO2 code
|
|
@@ -467,7 +469,7 @@ class Country:
|
|
|
467
469
|
def get_country_info_from_iso2(
|
|
468
470
|
cls,
|
|
469
471
|
iso2: str,
|
|
470
|
-
use_live: bool =
|
|
472
|
+
use_live: bool = None,
|
|
471
473
|
exception: Optional[ExceptionUpperBound] = None,
|
|
472
474
|
) -> Optional[Dict[str, str]]:
|
|
473
475
|
"""Get country name from ISO2 code
|
|
@@ -493,7 +495,7 @@ class Country:
|
|
|
493
495
|
def get_country_name_from_iso2(
|
|
494
496
|
cls,
|
|
495
497
|
iso2: str,
|
|
496
|
-
use_live: bool =
|
|
498
|
+
use_live: bool = None,
|
|
497
499
|
exception: Optional[ExceptionUpperBound] = None,
|
|
498
500
|
formal: bool = False,
|
|
499
501
|
) -> Optional[str]:
|
|
@@ -521,7 +523,7 @@ class Country:
|
|
|
521
523
|
def get_currency_from_iso2(
|
|
522
524
|
cls,
|
|
523
525
|
iso2: str,
|
|
524
|
-
use_live: bool =
|
|
526
|
+
use_live: bool = None,
|
|
525
527
|
exception: Optional[ExceptionUpperBound] = None,
|
|
526
528
|
) -> Optional[str]:
|
|
527
529
|
"""Get currency from ISO2 code
|
|
@@ -547,7 +549,7 @@ class Country:
|
|
|
547
549
|
def get_m49_from_iso3(
|
|
548
550
|
cls,
|
|
549
551
|
iso3: str,
|
|
550
|
-
use_live: bool =
|
|
552
|
+
use_live: bool = None,
|
|
551
553
|
exception: Optional[ExceptionUpperBound] = None,
|
|
552
554
|
) -> Optional[int]:
|
|
553
555
|
"""Get M49 from ISO3 code
|
|
@@ -573,7 +575,7 @@ class Country:
|
|
|
573
575
|
def get_iso3_from_m49(
|
|
574
576
|
cls,
|
|
575
577
|
m49: int,
|
|
576
|
-
use_live: bool =
|
|
578
|
+
use_live: bool = None,
|
|
577
579
|
exception: Optional[ExceptionUpperBound] = None,
|
|
578
580
|
) -> Optional[str]:
|
|
579
581
|
"""Get ISO3 from M49 code
|
|
@@ -599,7 +601,7 @@ class Country:
|
|
|
599
601
|
def get_country_info_from_m49(
|
|
600
602
|
cls,
|
|
601
603
|
m49: int,
|
|
602
|
-
use_live: bool =
|
|
604
|
+
use_live: bool = None,
|
|
603
605
|
exception: Optional[ExceptionUpperBound] = None,
|
|
604
606
|
) -> Optional[Dict[str, str]]:
|
|
605
607
|
"""Get country name from M49 code
|
|
@@ -623,7 +625,7 @@ class Country:
|
|
|
623
625
|
def get_country_name_from_m49(
|
|
624
626
|
cls,
|
|
625
627
|
m49: int,
|
|
626
|
-
use_live: bool =
|
|
628
|
+
use_live: bool = None,
|
|
627
629
|
exception: Optional[ExceptionUpperBound] = None,
|
|
628
630
|
formal: bool = False,
|
|
629
631
|
) -> Optional[str]:
|
|
@@ -651,7 +653,7 @@ class Country:
|
|
|
651
653
|
def get_currency_from_m49(
|
|
652
654
|
cls,
|
|
653
655
|
m49: int,
|
|
654
|
-
use_live: bool =
|
|
656
|
+
use_live: bool = None,
|
|
655
657
|
exception: Optional[ExceptionUpperBound] = None,
|
|
656
658
|
) -> Optional[str]:
|
|
657
659
|
"""Get currency from M49 code
|
|
@@ -754,7 +756,7 @@ class Country:
|
|
|
754
756
|
def get_iso3_country_code(
|
|
755
757
|
cls,
|
|
756
758
|
country: str,
|
|
757
|
-
use_live: bool =
|
|
759
|
+
use_live: bool = None,
|
|
758
760
|
exception: Optional[ExceptionUpperBound] = None,
|
|
759
761
|
) -> Optional[str]:
|
|
760
762
|
"""Get ISO3 code for cls. Only exact matches or None are returned.
|
|
@@ -814,7 +816,7 @@ class Country:
|
|
|
814
816
|
def get_iso3_country_code_fuzzy(
|
|
815
817
|
cls,
|
|
816
818
|
country: str,
|
|
817
|
-
use_live: bool =
|
|
819
|
+
use_live: bool = None,
|
|
818
820
|
exception: Optional[ExceptionUpperBound] = None,
|
|
819
821
|
min_chars: int = 5,
|
|
820
822
|
) -> Tuple[Optional[str], bool]:
|
|
@@ -904,7 +906,7 @@ class Country:
|
|
|
904
906
|
def get_countries_in_region(
|
|
905
907
|
cls,
|
|
906
908
|
region: Union[int, str],
|
|
907
|
-
use_live: bool =
|
|
909
|
+
use_live: bool = None,
|
|
908
910
|
exception: Optional[ExceptionUpperBound] = None,
|
|
909
911
|
) -> List[str]:
|
|
910
912
|
"""Get countries (ISO3 codes) in region
|
|
File without changes
|
|
@@ -421,7 +421,7 @@ class TestAdminLevel:
|
|
|
421
421
|
adminone = AdminLevel(config)
|
|
422
422
|
adminone.setup_from_url()
|
|
423
423
|
assert adminone.get_admin_level("YEM") == 1
|
|
424
|
-
assert len(adminone.get_pcode_list()) ==
|
|
424
|
+
assert len(adminone.get_pcode_list()) == 2527
|
|
425
425
|
assert adminone.get_pcode_length("YEM") == 4
|
|
426
426
|
assert adminone.get_pcode("YEM", "YE30", logname="test") == (
|
|
427
427
|
"YE30",
|
|
@@ -12,8 +12,19 @@ class LocationError(Exception):
|
|
|
12
12
|
pass
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
# Note that the Country class is set up in __init__.py
|
|
16
15
|
class TestCountry:
|
|
16
|
+
@pytest.fixture(scope="function", autouse=True)
|
|
17
|
+
def setup(self):
|
|
18
|
+
# Clean up Country class before each test
|
|
19
|
+
Country._countriesdata = None
|
|
20
|
+
Country.set_use_live_default(False)
|
|
21
|
+
Country.set_ocha_url()
|
|
22
|
+
Country.set_ocha_path()
|
|
23
|
+
Country.countriesdata(
|
|
24
|
+
country_name_overrides={"PSE": "oPt"},
|
|
25
|
+
country_name_mappings={"Congo DR": "COD"},
|
|
26
|
+
)
|
|
27
|
+
|
|
17
28
|
def test_get_country_name_from_iso3(self):
|
|
18
29
|
assert Country.get_country_name_from_iso3("jpn") == "Japan"
|
|
19
30
|
assert Country.get_country_name_from_iso3("awe") is None
|
|
@@ -696,8 +707,17 @@ class TestCountry:
|
|
|
696
707
|
assert Country._use_live is True
|
|
697
708
|
Country.set_use_live_default(False)
|
|
698
709
|
assert Country._use_live is False
|
|
710
|
+
# We should now be able to load from local data without setting use_live=False
|
|
711
|
+
Country._countriesdata = None
|
|
712
|
+
Country.set_ocha_path(
|
|
713
|
+
script_dir_plus_file("Countries_UZB_Deleted.csv", TestCountry)
|
|
714
|
+
)
|
|
715
|
+
assert Country.get_iso3_country_code("UZBEKISTAN") is None
|
|
699
716
|
Country.set_use_live_default(None)
|
|
700
717
|
assert Country._use_live is True
|
|
718
|
+
Country._countriesdata = None
|
|
719
|
+
assert Country.get_iso3_country_code("UZBEKISTAN") == "UZB"
|
|
720
|
+
Country._countriesdata = None
|
|
701
721
|
|
|
702
722
|
def test_ocha_feed_file_working(self):
|
|
703
723
|
countries = hxl.data(
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
from typing import Callable, Optional
|
|
2
|
-
|
|
3
|
-
import pyphonetics
|
|
4
|
-
|
|
5
|
-
from hdx.utilities.typehint import ListTuple
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Phonetics(pyphonetics.RefinedSoundex):
|
|
9
|
-
def match(
|
|
10
|
-
self,
|
|
11
|
-
possible_names: ListTuple,
|
|
12
|
-
name: str,
|
|
13
|
-
alternative_name: Optional[str] = None,
|
|
14
|
-
transform_possible_names: ListTuple[Callable] = [],
|
|
15
|
-
threshold: int = 2,
|
|
16
|
-
) -> Optional[int]:
|
|
17
|
-
"""
|
|
18
|
-
Match name to one of the given possible names. Returns None if no match
|
|
19
|
-
or the index of the matching name
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
possible_names (ListTuple): Possible names
|
|
23
|
-
name (str): Name to match
|
|
24
|
-
alternative_name (str): Alternative name to match. Defaults to None.
|
|
25
|
-
transform_possible_names (ListTuple[Callable]): Functions to transform possible names.
|
|
26
|
-
threshold: Match threshold. Defaults to 2.
|
|
27
|
-
|
|
28
|
-
Returns:
|
|
29
|
-
Optional[int]: Index of matching name from possible names or None
|
|
30
|
-
"""
|
|
31
|
-
mindistance = None
|
|
32
|
-
matching_index = None
|
|
33
|
-
|
|
34
|
-
transform_possible_names.insert(0, lambda x: x)
|
|
35
|
-
|
|
36
|
-
def check_name(name, possible_name):
|
|
37
|
-
nonlocal mindistance, matching_index # noqa: E999
|
|
38
|
-
|
|
39
|
-
distance = self.distance(name, possible_name)
|
|
40
|
-
if mindistance is None or distance < mindistance:
|
|
41
|
-
mindistance = distance
|
|
42
|
-
matching_index = i
|
|
43
|
-
|
|
44
|
-
for i, possible_name in enumerate(possible_names):
|
|
45
|
-
for transform_possible_name in transform_possible_names:
|
|
46
|
-
transformed_possible_name = transform_possible_name(
|
|
47
|
-
possible_name
|
|
48
|
-
)
|
|
49
|
-
if not transformed_possible_name:
|
|
50
|
-
continue
|
|
51
|
-
check_name(name, transformed_possible_name)
|
|
52
|
-
if alternative_name:
|
|
53
|
-
check_name(alternative_name, transformed_possible_name)
|
|
54
|
-
if mindistance is None or mindistance > threshold:
|
|
55
|
-
return None
|
|
56
|
-
return matching_index
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/.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
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/fixtures/wfp/Currency_List_1.json
RENAMED
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/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
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.6}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
File without changes
|