hdx-python-country 4.2.0__tar.gz → 4.2.2__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-4.2.0 → hdx_python_country-4.2.2}/PKG-INFO +1 -1
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/documentation/index.md +4 -1
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/adminlevel.py +6 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/country.py +3 -2
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/adminlevelparent.yaml +1 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/test_adminlevel.py +8 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/.gitignore +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/.pre-commit-config.yaml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/LICENSE +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/README.md +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/documentation/mkdocs.yaml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/pyproject.toml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy.csv +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/currency.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/int_timestamp.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/wfp_api.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/fixtures-download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/fixtures-download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_List_1.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_List_2.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Markets_List_AFG_1.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Markets_List_AFG_2.json +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/conftest.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/test_country.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/test_currency.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
- {hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hdx-python-country
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.2
|
|
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
|
Project-URL: Repository, https://github.com/OCHA-DAP/hdx-python-country
|
|
@@ -151,7 +151,10 @@ matching. Default is all countries.
|
|
|
151
151
|
*admin_name_mappings* is a dictionary of mappings from name to pcode. These can
|
|
152
152
|
be global or they can be restricted by country or parent (if the AdminLevel
|
|
153
153
|
object has been set up with parents). Keys take the form "MAPPING",
|
|
154
|
-
"AFG|MAPPING" or "AF01|MAPPING".
|
|
154
|
+
"AFG|MAPPING" or "AF01|MAPPING". A mapping keyed by parent is used even if
|
|
155
|
+
its pcode has a different parent (eg. "ET07|Dawuro": "ET1104" where ET07 is a
|
|
156
|
+
pre-split region). Other mappings are only used with a parent if the pcode's
|
|
157
|
+
parent matches it.
|
|
155
158
|
*admin_name_replacements* is a dictionary of textual replacements to try when
|
|
156
159
|
fuzzy matching. It maps from string to string replacement. The replacements can
|
|
157
160
|
be global or they can be restricted by country or parent (if the AdminLevel
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '4.2.
|
|
22
|
-
__version_tuple__ = version_tuple = (4, 2,
|
|
21
|
+
__version__ = version = '4.2.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (4, 2, 2)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -751,6 +751,12 @@ class AdminLevel:
|
|
|
751
751
|
parent = kwargs.get("parent")
|
|
752
752
|
else:
|
|
753
753
|
parent = None
|
|
754
|
+
if parent:
|
|
755
|
+
# A parent-keyed mapping is trusted even if its p-code has a
|
|
756
|
+
# different parent eg. a pre-split region name
|
|
757
|
+
pcode = self._admin_name_mappings.get(f"{parent}|{name}")
|
|
758
|
+
if pcode and self.pcode_to_iso3[pcode] == countryiso3:
|
|
759
|
+
return pcode, True
|
|
754
760
|
pcode = self.get_name_mapped_pcode(countryiso3, name, parent)
|
|
755
761
|
if pcode and self.pcode_to_iso3[pcode] == countryiso3:
|
|
756
762
|
if parent:
|
|
@@ -5,6 +5,7 @@ import os.path
|
|
|
5
5
|
import re
|
|
6
6
|
from collections.abc import Iterator
|
|
7
7
|
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
8
9
|
|
|
9
10
|
from hdx.utilities.base_downloader import BaseDownload, DownloadError
|
|
10
11
|
from hdx.utilities.downloader import Download
|
|
@@ -235,7 +236,7 @@ class Country:
|
|
|
235
236
|
country_name_overrides: dict | None = None,
|
|
236
237
|
country_name_mappings: dict | None = None,
|
|
237
238
|
downloader: BaseDownload | None = None,
|
|
238
|
-
) ->
|
|
239
|
+
) -> dict[str, dict[str, Any]]:
|
|
239
240
|
"""
|
|
240
241
|
Read countries data from OCHA countries feed (falling back to file).
|
|
241
242
|
include_unofficial, use_live, country_name_overrides and country_name_mappings
|
|
@@ -250,7 +251,7 @@ class Country:
|
|
|
250
251
|
downloader: Download or Retrieve object. Defaults to None.
|
|
251
252
|
|
|
252
253
|
Returns:
|
|
253
|
-
|
|
254
|
+
Dictionary of countries data lookups (countries, iso2iso3, m49iso3 etc.)
|
|
254
255
|
"""
|
|
255
256
|
if include_unofficial is not None:
|
|
256
257
|
cls._include_unofficial = include_unofficial
|
|
@@ -340,6 +340,7 @@ class TestAdminLevel:
|
|
|
340
340
|
"MyMapping: Charikar (AF0301)",
|
|
341
341
|
"AFG|MyMapping2: Maydan Shahr (AF0401)",
|
|
342
342
|
"AF05|MyMapping3: Pul-e-Alam (AF0501)",
|
|
343
|
+
"AF05|MyMapping4: Maydan Shahr (AF0401)",
|
|
343
344
|
]
|
|
344
345
|
assert admintwo.get_pcode("AFG", "MyMapping", logname="test") == (
|
|
345
346
|
"AF0301",
|
|
@@ -374,6 +375,13 @@ class TestAdminLevel:
|
|
|
374
375
|
"AFG", "MyMapping3", parent="AF04", logname="test"
|
|
375
376
|
) == (None, False)
|
|
376
377
|
|
|
378
|
+
assert admintwo.get_pcode(
|
|
379
|
+
"AFG", "MyMapping4", parent="AF05", logname="test"
|
|
380
|
+
) == ("AF0401", True)
|
|
381
|
+
assert admintwo.get_pcode(
|
|
382
|
+
"AFG", "MyMapping4", parent="AF04", logname="test"
|
|
383
|
+
) == (None, False)
|
|
384
|
+
|
|
377
385
|
# Names are garbled so that only the "qx" replacement, not fuzzy
|
|
378
386
|
# matching, can resolve them. That tests replacement scoping whatever
|
|
379
387
|
# the matcher.
|
|
File without changes
|
{hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/.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-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Currency_List_1.json
RENAMED
|
File without changes
|
{hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/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-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Markets_List_AFG_1.json
RENAMED
|
File without changes
|
{hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/fixtures/wfp/Markets_List_AFG_2.json
RENAMED
|
File without changes
|
{hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-4.2.0 → hdx_python_country-4.2.2}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
File without changes
|
|
File without changes
|