hdx-python-country 3.8.3__tar.gz → 3.8.4__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.
Files changed (49) hide show
  1. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/PKG-INFO +1 -2
  2. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/requirements.txt +8 -10
  3. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/_version.py +2 -2
  4. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/country.py +23 -5
  5. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/hdx/location/test_country.py +16 -0
  6. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.config/coveragerc +0 -0
  7. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.config/pre-commit-config.yaml +0 -0
  8. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.config/pytest.ini +0 -0
  9. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.config/ruff.toml +0 -0
  10. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.github/workflows/publish.yaml +0 -0
  11. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.github/workflows/run-python-tests.yaml +0 -0
  12. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/.gitignore +0 -0
  13. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/CONTRIBUTING.md +0 -0
  14. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/LICENSE +0 -0
  15. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/README.md +0 -0
  16. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/documentation/.readthedocs.yaml +0 -0
  17. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/documentation/main.md +0 -0
  18. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/documentation/pydoc-markdown.yaml +0 -0
  19. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/pyproject.toml +0 -0
  20. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
  21. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/__init__.py +0 -0
  22. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/adminlevel.py +0 -0
  23. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/currency.py +0 -0
  24. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/phonetics.py +0 -0
  25. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/wfp_api.py +0 -0
  26. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/src/hdx/location/wfp_exchangerates.py +0 -0
  27. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/adminlevel.yaml +0 -0
  28. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/adminlevelparent.yaml +0 -0
  29. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
  30. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
  31. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/secondary_historic_rates.csv +0 -0
  32. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/secondary_rates.json +0 -0
  33. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_List_1.json +0 -0
  34. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_List_2.json +0 -0
  35. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
  36. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
  37. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
  38. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
  39. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
  40. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
  41. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
  42. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
  43. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
  44. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
  45. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
  46. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/hdx/location/__init__.py +0 -0
  47. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/hdx/location/test_adminlevel.py +0 -0
  48. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/hdx/location/test_currency.py +0 -0
  49. {hdx_python_country-3.8.3 → hdx_python_country-3.8.4}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
@@ -1,11 +1,10 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hdx-python-country
3
- Version: 3.8.3
3
+ Version: 3.8.4
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
7
7
  License: MIT
8
- License-File: LICENSE
9
8
  Keywords: HDX,country,country code,currencies,currency,exchange rate,foreign exchange,fx,iso 3166,iso2,iso3,location,region
10
9
  Classifier: Development Status :: 5 - Production/Stable
11
10
  Classifier: Intended Audience :: Developers
@@ -18,7 +18,7 @@ charset-normalizer==3.4.0
18
18
  # via requests
19
19
  click==8.1.7
20
20
  # via typer
21
- coverage==7.6.4
21
+ coverage==7.6.7
22
22
  # via pytest-cov
23
23
  distlib==0.3.9
24
24
  # via virtualenv
@@ -32,7 +32,7 @@ hdx-python-utilities==3.7.4
32
32
  # via hdx-python-country (pyproject.toml)
33
33
  humanize==4.11.0
34
34
  # via frictionless
35
- identify==2.6.1
35
+ identify==2.6.2
36
36
  # via pre-commit
37
37
  idna==3.10
38
38
  # via requests
@@ -70,12 +70,10 @@ nodeenv==1.9.1
70
70
  # via pre-commit
71
71
  openpyxl==3.1.5
72
72
  # via hdx-python-utilities
73
- packaging==24.1
73
+ packaging==24.2
74
74
  # via pytest
75
75
  petl==1.7.15
76
76
  # via frictionless
77
- pip==24.3.1
78
- # via simpleeval
79
77
  platformdirs==4.3.6
80
78
  # via virtualenv
81
79
  pluggy==1.5.0
@@ -129,9 +127,9 @@ requests-file==2.1.0
129
127
  # via hdx-python-utilities
130
128
  rfc3986==2.0.0
131
129
  # via frictionless
132
- rich==13.9.3
130
+ rich==13.9.4
133
131
  # via typer
134
- rpds-py==0.20.0
132
+ rpds-py==0.21.0
135
133
  # via
136
134
  # jsonschema
137
135
  # referencing
@@ -141,7 +139,7 @@ ruamel-yaml-clib==0.2.12
141
139
  # via ruamel-yaml
142
140
  shellingham==1.5.4
143
141
  # via typer
144
- simpleeval==1.0.1
142
+ simpleeval==1.0.3
145
143
  # via frictionless
146
144
  six==1.16.0
147
145
  # via python-dateutil
@@ -157,7 +155,7 @@ tenacity==9.0.0
157
155
  # via hdx-python-country (pyproject.toml)
158
156
  text-unidecode==1.3
159
157
  # via python-slugify
160
- typer==0.12.5
158
+ typer==0.13.0
161
159
  # via frictionless
162
160
  typing-extensions==4.12.2
163
161
  # via
@@ -177,7 +175,7 @@ validators==0.34.0
177
175
  # via frictionless
178
176
  virtualenv==20.27.1
179
177
  # via pre-commit
180
- wheel==0.44.0
178
+ wheel==0.45.0
181
179
  # via libhxl
182
180
  xlrd==2.0.1
183
181
  # via hdx-python-utilities
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '3.8.3'
16
- __version_tuple__ = version_tuple = (3, 8, 3)
15
+ __version__ = version = '3.8.4'
16
+ __version_tuple__ = version_tuple = (3, 8, 4)
@@ -2,6 +2,7 @@
2
2
 
3
3
  import copy
4
4
  import logging
5
+ import os.path
5
6
  import re
6
7
  from string import punctuation
7
8
  from typing import Dict, List, Optional, Tuple, Union
@@ -73,6 +74,11 @@ class Country:
73
74
  _countriesdata = None
74
75
  _ochaurl_default = "https://docs.google.com/spreadsheets/d/1NjSI2LaS3SqbgYc0HdD8oIb7lofGtiHgoKKATCpwVdY/export?format=csv&gid=1088874596"
75
76
  _ochaurl = _ochaurl_default
77
+ _ochapath_default = script_dir_plus_file(
78
+ "Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv",
79
+ CountryError,
80
+ )
81
+ _ochapath = _ochapath_default
76
82
  _country_name_overrides = {}
77
83
  _country_name_mappings = {}
78
84
 
@@ -238,10 +244,7 @@ class Country:
238
244
  )
239
245
  if countries is None:
240
246
  countries = hxl.data(
241
- script_dir_plus_file(
242
- "Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv",
243
- Country,
244
- ),
247
+ cls._ochapath,
245
248
  InputOptions(allow_local=True, encoding="utf-8"),
246
249
  )
247
250
  cls.set_countriesdata(countries)
@@ -264,7 +267,7 @@ class Country:
264
267
  cls._use_live = use_live
265
268
 
266
269
  @classmethod
267
- def set_ocha_url(cls, url: Optional[str] = None) -> None:
270
+ def set_ocha_url(cls, url: str = None) -> None:
268
271
  """
269
272
  Set OCHA url from which to retrieve countries data
270
273
 
@@ -278,6 +281,21 @@ class Country:
278
281
  url = cls._ochaurl_default
279
282
  cls._ochaurl = url
280
283
 
284
+ @classmethod
285
+ def set_ocha_path(cls, path: Optional[str] = None) -> None:
286
+ """
287
+ Set local path from which to retrieve OCHA countries data
288
+
289
+ Args:
290
+ path (Optional[str]): Local path from which to retrieve countries data. Defaults to None.
291
+
292
+ Returns:
293
+ None
294
+ """
295
+ if not path or (path and not os.path.exists(path)):
296
+ path = cls._ochapath_default
297
+ cls._ochapath = path
298
+
281
299
  @classmethod
282
300
  def set_country_name_overrides(cls, country_name_overrides: Dict) -> None:
283
301
  """
@@ -716,3 +716,19 @@ class TestCountry:
716
716
  Country.set_ocha_url("NOTEXIST")
717
717
  Country._countriesdata = None
718
718
  assert Country.get_iso3_from_iso2("AF") == "AFG"
719
+
720
+ def test_ocha_feed_local_file_working(self):
721
+ Country._countriesdata = None
722
+ Country.set_ocha_path(
723
+ script_dir_plus_file("Countries_UZB_Deleted.csv", TestCountry)
724
+ )
725
+ assert (
726
+ Country.get_iso3_country_code("UZBEKISTAN", use_live=False) is None
727
+ )
728
+
729
+ Country._countriesdata = None
730
+ Country.set_ocha_path()
731
+ assert (
732
+ Country.get_iso3_country_code("UZBEKISTAN", use_live=False)
733
+ == "UZB"
734
+ )