hdx-python-country 4.1.1__tar.gz → 4.1.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.1.1 → hdx_python_country-4.1.2}/.pre-commit-config.yaml +1 -1
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/PKG-INFO +4 -2
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/pyproject.toml +3 -1
- hdx_python_country-4.1.2/src/hdx/location/_version.py +24 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/wfp_api.py +19 -5
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/fixtures/fixtures-download-global-pcode-lengths.csv +23 -69
- hdx_python_country-4.1.2/tests/fixtures/fixtures-download-global-pcodes-adm-1-2.csv +22988 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/fixtures/wfp/Currency_List_1.json +1 -1
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_List_2.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +1 -0
- hdx_python_country-4.1.2/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +1 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/test_adminlevel.py +3 -3
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/test_wfp_exchangerates.py +2 -2
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/uv.lock +4 -4
- hdx_python_country-4.1.1/src/hdx/location/_version.py +0 -34
- hdx_python_country-4.1.1/tests/fixtures/fixtures-download-global-pcodes-adm-1-2.csv +0 -32768
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_List_2.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -1
- hdx_python_country-4.1.1/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -1
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/.gitignore +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/LICENSE +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/README.md +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/documentation/index.md +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/documentation/mkdocs.yaml +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy.csv +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/adminlevel.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/country.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/currency.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/int_timestamp.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/conftest.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/test_country.py +0 -0
- {hdx_python_country-4.1.1 → hdx_python_country-4.1.2}/tests/hdx/location/test_currency.py +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-country
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.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
|
+
Project-URL: Repository, https://github.com/OCHA-DAP/hdx-python-country
|
|
7
|
+
Project-URL: Issues, https://github.com/OCHA-DAP/hdx-python-country/issues
|
|
6
8
|
Author: Michael Rans
|
|
7
9
|
License: MIT
|
|
8
10
|
License-File: LICENSE
|
|
@@ -25,7 +27,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
25
27
|
Classifier: Programming Language :: Python :: 3.14
|
|
26
28
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
29
|
Requires-Python: >=3.10
|
|
28
|
-
Requires-Dist: hdx-python-utilities<5,>=4.
|
|
30
|
+
Requires-Dist: hdx-python-utilities<5,>=4.1.2
|
|
29
31
|
Requires-Dist: tenacity
|
|
30
32
|
Provides-Extra: docs
|
|
31
33
|
Requires-Dist: mkapi; extra == 'docs'
|
|
@@ -36,7 +36,7 @@ dynamic = ["version"]
|
|
|
36
36
|
requires-python = ">=3.10"
|
|
37
37
|
|
|
38
38
|
dependencies = [
|
|
39
|
-
"hdx-python-utilities>=4.
|
|
39
|
+
"hdx-python-utilities>=4.1.2,<5",
|
|
40
40
|
"tenacity",
|
|
41
41
|
]
|
|
42
42
|
|
|
@@ -53,6 +53,8 @@ dev = [
|
|
|
53
53
|
|
|
54
54
|
[project.urls]
|
|
55
55
|
Homepage = "https://github.com/OCHA-DAP/hdx-python-country"
|
|
56
|
+
Repository = "https://github.com/OCHA-DAP/hdx-python-country"
|
|
57
|
+
Issues = "https://github.com/OCHA-DAP/hdx-python-country/issues"
|
|
56
58
|
|
|
57
59
|
# ----------------------------------------------------------------------------
|
|
58
60
|
# Hatchling (Build & Versioning)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '4.1.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (4, 1, 2)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from os import getenv
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from typing import Any
|
|
4
5
|
|
|
@@ -27,9 +28,10 @@ class WFPAPI:
|
|
|
27
28
|
retriever: Retrieve object for interacting with WFP API
|
|
28
29
|
"""
|
|
29
30
|
|
|
30
|
-
token_url = "https://
|
|
31
|
-
base_url = "https://api.wfp.org/vam-data-bridges/
|
|
32
|
-
scope = "
|
|
31
|
+
token_url = "https://login.microsoftonline.com/462ad9ae-d7d9-4206-b874-71b1e079776f/oauth2/v2.0/token"
|
|
32
|
+
base_url = "https://gateway.api.wfp.org/vam-data-bridges/v2/"
|
|
33
|
+
scope = "api://wfp-api-mediation-service/.default"
|
|
34
|
+
grant_type = "client_credentials"
|
|
33
35
|
default_retry_params = {
|
|
34
36
|
"retry": retry_if_exception_type(DownloadError),
|
|
35
37
|
"after": after_log(logger, logging.INFO),
|
|
@@ -39,10 +41,20 @@ class WFPAPI:
|
|
|
39
41
|
self,
|
|
40
42
|
token_downloader: Download,
|
|
41
43
|
retriever: Retrieve,
|
|
44
|
+
wfp_key: str | None = None,
|
|
45
|
+
wfp_secret: str | None = None,
|
|
42
46
|
):
|
|
43
47
|
self.token_downloader = token_downloader
|
|
44
48
|
self.retriever = retriever
|
|
45
49
|
self.retry_params = {"attempts": 1, "wait": 1}
|
|
50
|
+
if wfp_key:
|
|
51
|
+
self._wfp_key = wfp_key
|
|
52
|
+
else:
|
|
53
|
+
self._wfp_key = getenv("WFP_KEY")
|
|
54
|
+
if wfp_secret:
|
|
55
|
+
self._wfp_secret = wfp_secret
|
|
56
|
+
else:
|
|
57
|
+
self._wfp_secret = getenv("WFP_SECRET")
|
|
46
58
|
|
|
47
59
|
def get_retry_params(self) -> dict:
|
|
48
60
|
return self.retry_params
|
|
@@ -57,8 +69,10 @@ class WFPAPI:
|
|
|
57
69
|
self.token_url,
|
|
58
70
|
post=True,
|
|
59
71
|
parameters={
|
|
60
|
-
"grant_type":
|
|
72
|
+
"grant_type": self.grant_type,
|
|
61
73
|
"scope": self.scope,
|
|
74
|
+
"client_id": self._wfp_key,
|
|
75
|
+
"client_secret": self._wfp_secret,
|
|
62
76
|
},
|
|
63
77
|
)
|
|
64
78
|
bearer_token = self.token_downloader.get_json()["access_token"]
|
|
@@ -146,7 +160,7 @@ class WFPAPI:
|
|
|
146
160
|
else:
|
|
147
161
|
filename = f"{base_filename}_{countryiso3}_{page}.json"
|
|
148
162
|
log = f"{base_filename} for {countryiso3} page {page}"
|
|
149
|
-
page_parameters["
|
|
163
|
+
page_parameters["countryCode"] = countryiso3
|
|
150
164
|
try:
|
|
151
165
|
json = self.retrieve(url, filename, log, page_parameters)
|
|
152
166
|
except FileNotFoundError:
|
|
@@ -1,98 +1,69 @@
|
|
|
1
|
-
Location,Country Length,Admin 1 Length,Admin 2 Length,Admin 3 Length,Admin 4 Length,Admin 5 Length
|
|
1
|
+
Location,Country Length,Admin 1 Length,Admin 2 Length,Admin 3 Length,Admin 4 Length,Admin 5 Length
|
|
2
2
|
AFG,2,2,2,,,
|
|
3
3
|
AGO,2,2,3,3,,
|
|
4
|
-
ALB,2,2,2,2,,
|
|
5
4
|
ARE,2,2,,,,
|
|
6
|
-
|
|
7
|
-
ARM,2,2,1,3,,
|
|
8
|
-
ATG,2,2,,,,
|
|
5
|
+
ARM,2,2,1,,,
|
|
9
6
|
AZE,2,8,,,,
|
|
10
7
|
BDI,3,3,3,,,
|
|
11
8
|
BEN,2,2,2,,,
|
|
12
|
-
BES,3,1,,,,
|
|
13
9
|
BFA,2,2,2,2,,
|
|
14
|
-
BGD,2,2,2,
|
|
10
|
+
BGD,2,2,2,4,,
|
|
15
11
|
BGR,2,3,3,,,
|
|
16
12
|
BLR,2,3,3,,,
|
|
17
13
|
BLZ,2,2,,,,
|
|
18
|
-
BMU,2,2,1,,,
|
|
19
14
|
BOL,2,2,2,2,,
|
|
20
|
-
BRA,2,2,5,,,
|
|
21
|
-
BRB,2,2,,,,
|
|
22
15
|
BTN,2,3,2,,,
|
|
23
|
-
|
|
24
|
-
CAF,2,2,1,1,2,
|
|
16
|
+
CAF,2,2,1,,,
|
|
25
17
|
CHL,2,2,1,2,,
|
|
26
|
-
CHN,2,3,3,,,
|
|
27
18
|
CIV,2,2,2,2,,
|
|
28
19
|
CMR,2,3,3,3,,
|
|
29
|
-
COD,2,2,2
|
|
20
|
+
COD,2,2,2,4,,
|
|
30
21
|
COG,2,2,2,,,
|
|
31
|
-
COL,2,2,3
|
|
22
|
+
COL,2,2,3,2|3,,
|
|
32
23
|
COM,2,1,1,1,,
|
|
33
24
|
CPV,2,2,2,,,
|
|
34
25
|
CRI,2,1,2,2,,
|
|
35
26
|
CUB,2,2,2,,,
|
|
36
|
-
CUW,2,2,,,,
|
|
37
|
-
CYM,2,2,,,,
|
|
38
|
-
DJI,2,2,2,,,
|
|
39
|
-
DMA,2,2,,,,
|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D,2,2,2,2,,
|
|
126
|
-
STP,2,2,2,,,
|
|
127
|
-
SUR,2,2,2,,,
|
|
128
92
|
SVK,2,3,3,,,
|
|
129
93
|
SWZ,2,1,2,,,
|
|
130
94
|
SXM,2,1,,,,
|
|
131
|
-
SYC,2,1,1,4,,
|
|
132
95
|
SYR,2,2,2,2,,
|
|
133
|
-
|
|
134
|
-
TCD,2,2,2,2,,
|
|
96
|
+
TCD,3,2,2,,,
|
|
135
97
|
TGO,2,2,2,2,,
|
|
136
98
|
THA,2,2,2,2,,
|
|
137
|
-
TJK,0,7,0,,,
|
|
138
99
|
TLS,2,2,2,2,,
|
|
139
|
-
TON,2,1,1,2,,
|
|
140
|
-
TTO,2,2,,,,
|
|
141
100
|
TUN,2,1,1,2,2,
|
|
142
|
-
TUR,3,3,3
|
|
143
|
-
TZA,2,2,2,3|4,,
|
|
101
|
+
TUR,3,3,3,,,
|
|
144
102
|
UGA,2,1,3,2,2,
|
|
145
103
|
UKR,2,2,2,3,3,
|
|
146
|
-
|
|
147
|
-
UZB,2,2,3,,,
|
|
148
|
-
VCT,2,1,2,,,
|
|
104
|
+
VCT,2,1,,,,
|
|
149
105
|
VEN,2,2,2,2,,
|
|
150
|
-
|
|
151
|
-
VIR,2,3,5,,,
|
|
152
|
-
VNM,2,3,2,,,
|
|
106
|
+
VNM,2,2,,,,
|
|
153
107
|
VUT,2,2,3,,,
|
|
154
|
-
YEM,2,2,2
|
|
108
|
+
YEM,2,2,2,,,
|
|
155
109
|
ZAF,2,1,2,1,3,
|
|
156
110
|
ZMB,2,3,3,3,3,
|
|
157
111
|
ZWE,2,2,2,2,,
|