hdx-python-country 3.8.0__tar.gz → 3.8.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-3.8.0 → hdx_python_country-3.8.1}/PKG-INFO +1 -1
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/adminlevel.py +25 -10
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/test_adminlevel.py +2 -2
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.config/coveragerc +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.config/pre-commit-config.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.config/pytest.ini +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.config/ruff.toml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/.gitignore +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/CONTRIBUTING.md +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/LICENSE +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/README.md +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/documentation/main.md +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/documentation/pydoc-markdown.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/pyproject.toml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/requirements.txt +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/country.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/currency.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/phonetics.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/test_country.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/test_currency.py +0 -0
- {hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
|
@@ -50,9 +50,10 @@ class AdminLevel:
|
|
|
50
50
|
|
|
51
51
|
pcode_regex = re.compile(r"^([a-zA-Z]{2,3})(\d+)$")
|
|
52
52
|
_admin_url_default = "https://data.humdata.org/dataset/cb963915-d7d1-4ffa-90dc-31277e24406f/resource/f65bc260-4d8b-416f-ac07-f2433b4d5142/download/global_pcodes_adm_1_2.csv"
|
|
53
|
-
|
|
53
|
+
admin_url = _admin_url_default
|
|
54
|
+
admin_all_pcodes_url = "https://data.humdata.org/dataset/cb963915-d7d1-4ffa-90dc-31277e24406f/resource/793e66fe-4cdb-4076-b037-fb8c053239e2/download/global_pcodes.csv"
|
|
54
55
|
_formats_url_default = "https://data.humdata.org/dataset/cb963915-d7d1-4ffa-90dc-31277e24406f/resource/f1161807-dab4-4331-b7b0-4e5dac56e0e4/download/global_pcode_lengths.csv"
|
|
55
|
-
|
|
56
|
+
formats_url = _formats_url_default
|
|
56
57
|
|
|
57
58
|
def __init__(
|
|
58
59
|
self,
|
|
@@ -113,11 +114,11 @@ class AdminLevel:
|
|
|
113
114
|
"""
|
|
114
115
|
if admin_url is None:
|
|
115
116
|
admin_url = cls._admin_url_default
|
|
116
|
-
cls.
|
|
117
|
+
cls.admin_url = admin_url
|
|
117
118
|
|
|
118
119
|
@staticmethod
|
|
119
120
|
def get_libhxl_dataset(
|
|
120
|
-
url: str =
|
|
121
|
+
url: str = admin_url, retriever: Optional[Retrieve] = None
|
|
121
122
|
) -> hxl.Dataset:
|
|
122
123
|
"""
|
|
123
124
|
Get libhxl Dataset object given a URL which defaults to global p-codes
|
|
@@ -262,7 +263,7 @@ class AdminLevel:
|
|
|
262
263
|
|
|
263
264
|
def setup_from_url(
|
|
264
265
|
self,
|
|
265
|
-
admin_url: str =
|
|
266
|
+
admin_url: str = admin_url,
|
|
266
267
|
countryiso3s: Optional[ListTuple[str]] = None,
|
|
267
268
|
) -> None:
|
|
268
269
|
"""
|
|
@@ -278,18 +279,19 @@ class AdminLevel:
|
|
|
278
279
|
admin_info = self.get_libhxl_dataset(admin_url, self.retriever)
|
|
279
280
|
self.setup_from_libhxl_dataset(admin_info, countryiso3s)
|
|
280
281
|
|
|
281
|
-
def
|
|
282
|
+
def load_pcode_formats_from_libhxl_dataset(
|
|
283
|
+
self, libhxl_dataset: hxl.Dataset
|
|
284
|
+
) -> None:
|
|
282
285
|
"""
|
|
283
|
-
Load p-code formats from a
|
|
286
|
+
Load p-code formats from a libhxl Dataset object.
|
|
284
287
|
|
|
285
288
|
Args:
|
|
286
|
-
|
|
289
|
+
libhxl_dataset (hxl.Dataset): Dataset object from libhxl library
|
|
287
290
|
|
|
288
291
|
Returns:
|
|
289
292
|
None
|
|
290
293
|
"""
|
|
291
|
-
|
|
292
|
-
for row in formats_info:
|
|
294
|
+
for row in libhxl_dataset:
|
|
293
295
|
pcode_format = [int(row.get("#country+len"))]
|
|
294
296
|
for admin_no in range(1, 4):
|
|
295
297
|
length = row.get(f"#adm{admin_no}+len")
|
|
@@ -303,6 +305,19 @@ class AdminLevel:
|
|
|
303
305
|
for x in re.finditer("0", pcode):
|
|
304
306
|
dict_of_sets_add(self.zeroes, countryiso3, x.start())
|
|
305
307
|
|
|
308
|
+
def load_pcode_formats(self, formats_url: str = formats_url) -> None:
|
|
309
|
+
"""
|
|
310
|
+
Load p-code formats from a URL. Defaults to global p-codes dataset on HDX.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
formats_url (str): URL from which to load data. Defaults to global p-codes dataset.
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
None
|
|
317
|
+
"""
|
|
318
|
+
formats_info = self.get_libhxl_dataset(formats_url, self.retriever)
|
|
319
|
+
self.load_pcode_formats_from_libhxl_dataset(formats_info)
|
|
320
|
+
|
|
306
321
|
def set_parent_admins(self, parent_admins: List[List]) -> None:
|
|
307
322
|
"""
|
|
308
323
|
Set parent admins
|
|
@@ -381,9 +381,9 @@ class TestAdminLevel:
|
|
|
381
381
|
adminone.setup_from_url("fake_url")
|
|
382
382
|
adminone = AdminLevel(config)
|
|
383
383
|
AdminLevel.set_default_admin_url()
|
|
384
|
-
assert AdminLevel.
|
|
384
|
+
assert AdminLevel.admin_url == AdminLevel._admin_url_default
|
|
385
385
|
AdminLevel.set_default_admin_url(url)
|
|
386
|
-
assert AdminLevel.
|
|
386
|
+
assert AdminLevel.admin_url == url
|
|
387
387
|
adminone.setup_from_url(countryiso3s=("YEM",))
|
|
388
388
|
assert len(adminone.get_pcode_list()) == 22
|
|
389
389
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.0 → hdx_python_country-3.8.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
|
|
File without changes
|
{hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.0 → hdx_python_country-3.8.1}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
File without changes
|