hdx-python-country 4.0.0__tar.gz → 4.0.1__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.0.0 → hdx_python_country-4.0.1}/PKG-INFO +2 -2
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/pyproject.toml +1 -1
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/requirements.txt +1 -1
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/adminlevel.py +5 -4
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/country.py +6 -3
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/currency.py +5 -4
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/wfp_api.py +2 -1
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/conftest.py +3 -3
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/test_adminlevel.py +4 -6
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/test_country.py +1 -1
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/test_currency.py +2 -4
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/.coveragerc +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/.gitignore +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/.pre-commit-config.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/LICENSE +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/README.md +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/documentation/index.md +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/documentation/mkdocs.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/hatch.toml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/pytest.ini +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/ruff.toml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/int_timestamp.py +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_List_1.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_List_2.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-country
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.1
|
|
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.10
|
|
28
|
-
Requires-Dist: hdx-python-utilities>=4.0.
|
|
28
|
+
Requires-Dist: hdx-python-utilities>=4.0.1
|
|
29
29
|
Requires-Dist: libhxl>=5.2.2
|
|
30
30
|
Requires-Dist: tenacity
|
|
31
31
|
Provides-Extra: dev
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '4.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (4, 0,
|
|
31
|
+
__version__ = version = '4.0.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (4, 0, 1)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import re
|
|
3
3
|
from collections.abc import Sequence
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
6
7
|
import hxl
|
|
@@ -116,7 +117,7 @@ class AdminLevel:
|
|
|
116
117
|
|
|
117
118
|
@staticmethod
|
|
118
119
|
def get_libhxl_dataset(
|
|
119
|
-
url: str = admin_url, retriever: Retrieve | None = None
|
|
120
|
+
url: Path | str = admin_url, retriever: Retrieve | None = None
|
|
120
121
|
) -> hxl.Dataset:
|
|
121
122
|
"""
|
|
122
123
|
Get libhxl Dataset object given a URL which defaults to global p-codes
|
|
@@ -139,7 +140,7 @@ class AdminLevel:
|
|
|
139
140
|
url_to_use = url
|
|
140
141
|
try:
|
|
141
142
|
return hxl.data(
|
|
142
|
-
url_to_use,
|
|
143
|
+
str(url_to_use),
|
|
143
144
|
InputOptions(InputOptions(allow_local=True, encoding="utf-8")),
|
|
144
145
|
)
|
|
145
146
|
except (FileNotFoundError, HXLIOException):
|
|
@@ -247,7 +248,7 @@ class AdminLevel:
|
|
|
247
248
|
|
|
248
249
|
def setup_from_url(
|
|
249
250
|
self,
|
|
250
|
-
admin_url: str = admin_url,
|
|
251
|
+
admin_url: Path | str = admin_url,
|
|
251
252
|
countryiso3s: Sequence[str] | None = None,
|
|
252
253
|
) -> None:
|
|
253
254
|
"""
|
|
@@ -289,7 +290,7 @@ class AdminLevel:
|
|
|
289
290
|
for x in re.finditer("0", pcode):
|
|
290
291
|
dict_of_sets_add(self.zeroes, countryiso3, x.start())
|
|
291
292
|
|
|
292
|
-
def load_pcode_formats(self, formats_url: str = formats_url) -> None:
|
|
293
|
+
def load_pcode_formats(self, formats_url: Path | str = formats_url) -> None:
|
|
293
294
|
"""
|
|
294
295
|
Load p-code formats from a URL. Defaults to global p-codes dataset on HDX.
|
|
295
296
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
import os.path
|
|
5
5
|
import re
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
import hxl
|
|
8
9
|
from hdx.utilities.path import script_dir_plus_file
|
|
@@ -239,14 +240,16 @@ class Country:
|
|
|
239
240
|
cls.set_country_name_mappings(country_name_mappings)
|
|
240
241
|
if cls._use_live:
|
|
241
242
|
try:
|
|
242
|
-
countries = hxl.data(
|
|
243
|
+
countries = hxl.data(
|
|
244
|
+
str(cls._ochaurl), InputOptions(encoding="utf-8")
|
|
245
|
+
)
|
|
243
246
|
except OSError:
|
|
244
247
|
logger.exception(
|
|
245
248
|
"Download from OCHA feed failed! Falling back to stored file."
|
|
246
249
|
)
|
|
247
250
|
if countries is None:
|
|
248
251
|
countries = hxl.data(
|
|
249
|
-
cls._ochapath,
|
|
252
|
+
str(cls._ochapath),
|
|
250
253
|
InputOptions(allow_local=True, encoding="utf-8"),
|
|
251
254
|
)
|
|
252
255
|
cls.set_countriesdata(countries)
|
|
@@ -302,7 +305,7 @@ class Country:
|
|
|
302
305
|
cls._ochaurl = url
|
|
303
306
|
|
|
304
307
|
@classmethod
|
|
305
|
-
def set_ocha_path(cls, path: str | None = None) -> None:
|
|
308
|
+
def set_ocha_path(cls, path: Path | str | None = None) -> None:
|
|
306
309
|
"""
|
|
307
310
|
Set local path from which to retrieve OCHA countries data
|
|
308
311
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from copy import deepcopy
|
|
5
5
|
from datetime import datetime, timezone
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
from hdx.utilities.dateparse import (
|
|
8
9
|
now_utc,
|
|
@@ -50,9 +51,9 @@ class Currency:
|
|
|
50
51
|
def setup(
|
|
51
52
|
cls,
|
|
52
53
|
retriever: Retrieve | None = None,
|
|
53
|
-
primary_rates_url: str = _primary_rates_url,
|
|
54
|
-
secondary_rates_url: str = _secondary_rates_url,
|
|
55
|
-
secondary_historic_url: str | None = _secondary_historic_url,
|
|
54
|
+
primary_rates_url: Path | str = _primary_rates_url,
|
|
55
|
+
secondary_rates_url: Path | str = _secondary_rates_url,
|
|
56
|
+
secondary_historic_url: Path | str | None = _secondary_historic_url,
|
|
56
57
|
secondary_historic_rates: dict | None = None,
|
|
57
58
|
fallback_historic_to_current: bool = False,
|
|
58
59
|
fallback_current_to_static: bool = False,
|
|
@@ -100,7 +101,7 @@ class Currency:
|
|
|
100
101
|
temp_dir = get_temp_dir(cls._user_agent)
|
|
101
102
|
retriever = Retrieve(
|
|
102
103
|
downloader,
|
|
103
|
-
|
|
104
|
+
temp_dir,
|
|
104
105
|
temp_dir,
|
|
105
106
|
temp_dir,
|
|
106
107
|
save=False,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
from typing import Any
|
|
3
4
|
|
|
4
5
|
from hdx.utilities.base_downloader import DownloadError
|
|
@@ -65,7 +66,7 @@ class WFPAPI:
|
|
|
65
66
|
|
|
66
67
|
def retrieve(
|
|
67
68
|
self,
|
|
68
|
-
url: str,
|
|
69
|
+
url: Path | str,
|
|
69
70
|
filename: str,
|
|
70
71
|
log: str,
|
|
71
72
|
parameters: dict | None = None,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from
|
|
1
|
+
from pathlib import Path
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
@@ -7,12 +7,12 @@ from hdx.location.currency import Currency
|
|
|
7
7
|
|
|
8
8
|
@pytest.fixture(scope="session")
|
|
9
9
|
def fixtures_dir():
|
|
10
|
-
return
|
|
10
|
+
return Path("tests") / "fixtures"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
@pytest.fixture(scope="session")
|
|
14
14
|
def input_dir(fixtures_dir):
|
|
15
|
-
return
|
|
15
|
+
return fixtures_dir / "wfp"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@pytest.fixture(scope="function")
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""location Tests"""
|
|
2
2
|
|
|
3
|
-
from os.path import join
|
|
4
|
-
|
|
5
3
|
import pytest
|
|
6
4
|
from hdx.utilities.base_downloader import DownloadError
|
|
7
5
|
from hdx.utilities.downloader import Download
|
|
@@ -15,19 +13,19 @@ from hdx.location.adminlevel import AdminLevel
|
|
|
15
13
|
class TestAdminLevel:
|
|
16
14
|
@pytest.fixture(scope="function")
|
|
17
15
|
def config(self, fixtures_dir):
|
|
18
|
-
return load_yaml(
|
|
16
|
+
return load_yaml(fixtures_dir / "adminlevel.yaml")
|
|
19
17
|
|
|
20
18
|
@pytest.fixture(scope="function")
|
|
21
19
|
def config_parent(self, fixtures_dir):
|
|
22
|
-
return load_yaml(
|
|
20
|
+
return load_yaml(fixtures_dir / "adminlevelparent.yaml")
|
|
23
21
|
|
|
24
22
|
@pytest.fixture(scope="function")
|
|
25
23
|
def url(self, fixtures_dir):
|
|
26
|
-
return
|
|
24
|
+
return fixtures_dir / "download-global-pcodes-adm-1-2.csv"
|
|
27
25
|
|
|
28
26
|
@pytest.fixture(scope="function")
|
|
29
27
|
def formats_url(self, fixtures_dir):
|
|
30
|
-
return
|
|
28
|
+
return fixtures_dir / "download-global-pcode-lengths.csv"
|
|
31
29
|
|
|
32
30
|
def test_adminlevel(self, config):
|
|
33
31
|
adminone = AdminLevel(config)
|
|
@@ -996,7 +996,7 @@ class TestCountry:
|
|
|
996
996
|
|
|
997
997
|
def test_ocha_feed_file_working(self):
|
|
998
998
|
countries = hxl.data(
|
|
999
|
-
script_dir_plus_file("Countries_UZB_Deleted.csv", TestCountry),
|
|
999
|
+
str(script_dir_plus_file("Countries_UZB_Deleted.csv", TestCountry)),
|
|
1000
1000
|
InputOptions(allow_local=True, encoding="utf-8"),
|
|
1001
1001
|
)
|
|
1002
1002
|
Country.set_countriesdata(countries)
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Currency Tests"""
|
|
2
2
|
|
|
3
|
-
from os.path import join
|
|
4
|
-
|
|
5
3
|
import pytest
|
|
6
4
|
from hdx.utilities.dateparse import parse_date
|
|
7
5
|
from hdx.utilities.downloader import Download
|
|
@@ -16,11 +14,11 @@ from hdx.location.int_timestamp import get_int_timestamp
|
|
|
16
14
|
class TestCurrency:
|
|
17
15
|
@pytest.fixture(scope="class")
|
|
18
16
|
def secondary_rates_url(self, fixtures_dir):
|
|
19
|
-
return
|
|
17
|
+
return fixtures_dir / "secondary_rates.json"
|
|
20
18
|
|
|
21
19
|
@pytest.fixture(scope="class")
|
|
22
20
|
def secondary_historic_url(self, fixtures_dir):
|
|
23
|
-
return
|
|
21
|
+
return fixtures_dir / "secondary_historic_rates.csv"
|
|
24
22
|
|
|
25
23
|
@pytest.fixture(scope="class", autouse=True)
|
|
26
24
|
def retrievers(self, fixtures_dir):
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/.github/workflows/run-python-tests.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/fixtures/wfp/Currency_List_1.json
RENAMED
|
File without changes
|
{hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/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.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-4.0.0 → hdx_python_country-4.0.1}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
File without changes
|