hdx-python-country 3.8.4__tar.gz → 3.8.5__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.5}/PKG-INFO +1 -1
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/requirements.txt +2 -2
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/country.py +19 -17
- hdx_python_country-3.8.5/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/hdx/location/test_country.py +21 -1
- hdx_python_country-3.8.4/tests/hdx/location/__init__.py +0 -8
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.config/coveragerc +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.config/pre-commit-config.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.config/pytest.ini +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.config/ruff.toml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/.gitignore +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/CONTRIBUTING.md +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/LICENSE +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/README.md +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/documentation/main.md +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/documentation/pydoc-markdown.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/pyproject.toml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/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.5}/src/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/adminlevel.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/currency.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/phonetics.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/wfp_api.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/src/hdx/location/wfp_exchangerates.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_List_1.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_List_2.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/hdx/location/test_adminlevel.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/hdx/location/test_currency.py +0 -0
- {hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
|
@@ -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.13.
|
|
158
|
+
typer==0.13.1
|
|
159
159
|
# via frictionless
|
|
160
160
|
typing-extensions==4.12.2
|
|
161
161
|
# via
|
|
@@ -181,7 +181,7 @@ 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
|
|
@@ -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
|
|
@@ -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(
|
|
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.5}/.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.4 → hdx_python_country-3.8.5}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/fixtures/wfp/Currency_List_1.json
RENAMED
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/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.5}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.8.4 → hdx_python_country-3.8.5}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
File without changes
|