hdx-python-country 4.1.3__tar.gz → 4.2.0__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 (48) hide show
  1. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/PKG-INFO +3 -3
  2. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/documentation/index.md +22 -2
  3. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/pyproject.toml +1 -1
  4. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy.csv +257 -257
  5. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/_version.py +2 -2
  6. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/adminlevel.py +32 -4
  7. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/country.py +6 -3
  8. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/adminlevelparent.yaml +4 -3
  9. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/Countries_UZB_Deleted.csv +27 -27
  10. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/test_adminlevel.py +145 -42
  11. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/test_country.py +13 -1
  12. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/uv.lock +216 -4
  13. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/.github/workflows/publish.yaml +0 -0
  14. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/.github/workflows/run-python-tests.yaml +0 -0
  15. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/.gitignore +0 -0
  16. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/.pre-commit-config.yaml +0 -0
  17. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/LICENSE +0 -0
  18. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/README.md +0 -0
  19. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/documentation/.readthedocs.yaml +0 -0
  20. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/documentation/mkdocs.yaml +0 -0
  21. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/__init__.py +0 -0
  22. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/currency.py +0 -0
  23. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/int_timestamp.py +0 -0
  24. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/wfp_api.py +0 -0
  25. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/src/hdx/location/wfp_exchangerates.py +0 -0
  26. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/adminlevel.yaml +0 -0
  27. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/fixtures-download-global-pcode-lengths.csv +0 -0
  28. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/fixtures-download-global-pcodes-adm-1-2.csv +0 -0
  29. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/secondary_historic_rates.csv +0 -0
  30. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/secondary_rates.json +0 -0
  31. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_List_1.json +0 -0
  32. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_List_2.json +0 -0
  33. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
  34. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
  35. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
  36. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
  37. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
  38. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
  39. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
  40. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
  41. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
  42. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
  43. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Markets_List_AFG_1.json +0 -0
  44. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/fixtures/wfp/Markets_List_AFG_2.json +0 -0
  45. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/__init__.py +0 -0
  46. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/conftest.py +0 -0
  47. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/test_currency.py +0 -0
  48. {hdx_python_country-4.1.3 → hdx_python_country-4.2.0}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: hdx-python-country
3
- Version: 4.1.3
3
+ Version: 4.2.0
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
  Project-URL: Repository, https://github.com/OCHA-DAP/hdx-python-country
@@ -27,7 +27,7 @@ Classifier: Programming Language :: Python :: 3.13
27
27
  Classifier: Programming Language :: Python :: 3.14
28
28
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
29
  Requires-Python: >=3.10
30
- Requires-Dist: hdx-python-utilities<5,>=4.1.2
30
+ Requires-Dist: hdx-python-utilities<5,>=4.2.0
31
31
  Requires-Dist: tenacity
32
32
  Provides-Extra: docs
33
33
  Requires-Dist: mkapi; extra == 'docs'
@@ -27,7 +27,7 @@ fuzzy matching for English look up that can handle abbreviations in country name
27
27
  Dem. for Democratic and Rep. for Republic.
28
28
 
29
29
  Mapping administration level names from a source to a given base set is also handled
30
- including phonetic fuzzy name matching.
30
+ including fuzzy name matching.
31
31
 
32
32
  It also provides foreign exchange rates and conversion from amounts in local
33
33
  currency to USD and vice-versa. The conversion relies on Yahoo Finance, falling
@@ -42,6 +42,12 @@ The code for the library is [here](https://github.com/OCHA-DAP/hdx-python-countr
42
42
  The library has detailed API documentation which can be found in the menu at the top.
43
43
 
44
44
  ## Breaking Changes
45
+ From 4.2.0, AdminLevel fuzzy matches using RapidFuzzMatcher (with its place_name_scorer)
46
+ from HDX Python Utilities rather than Phonetics by default. Pass matcher=Phonetics() for
47
+ the previous behaviour. Names made of parts are resolved from their parts and lists of
48
+ names are not fuzzy matched (see Administration Level). Fuzzy matching is now tried when
49
+ parent is "" as well as when it is None.
50
+
45
51
  From 4.1.1, HXL hashtags no longer used in AdminLevel class. The header names are used
46
52
  instead. setup_from_iterable replaces setup_from_admin_info and
47
53
  setup_from_libhxl_dataset using keys: "Location", "P-Code", "Name" and "Parent P-Code".
@@ -158,6 +164,17 @@ A Retrieve object can be passed in the *retriever* parameter that enables
158
164
  saving data downloaded to a file or loading previously saved data depending
159
165
  on how the Retrieve object is configured.
160
166
 
167
+ The *matcher* parameter sets the fuzzy name matcher. It defaults to
168
+ RapidFuzzMatcher from HDX Python Utilities with its place_name_scorer. Phonetics
169
+ from HDX Python Utilities can be passed instead.
170
+
171
+ Before fuzzy matching, a name made of parts split by separators (",", ";", "/",
172
+ ":", "&", newline, "and", "et") or a hyphen is resolved from its parts. A name
173
+ with two parts where one is the parent's name gives the other part's p-code
174
+ (eg. "Falcón, Acosta" with parent Falcón). A list of names (more than two parts,
175
+ or two parts that are different admin units, eg. "Kampot & Kep") is not fuzzy
176
+ matched.
177
+
161
178
  Once an AdminLevel object is constructed, either *setup_from_iterable* or
162
179
  *setup_from_url* must be called.
163
180
 
@@ -185,11 +202,14 @@ Examples of usage:
185
202
  AdminLevel.looks_like_pcode("Yemen") # returns False
186
203
  AdminLevel.looks_like_pcode("YEME123") # returns False
187
204
  adminlevel = AdminLevel(config)
188
- adminlevel.setup_from_admin_info(admin_info, countryiso3s=("YEM",))
205
+ adminlevel.setup_from_iterable(admin_info, countryiso3s=("YEM",))
189
206
  adminlevel.get_pcode("YEM", "YEM030", logname="test") # returns ("YE30", True)
190
207
  adminlevel.get_pcode("YEM", "Al Dhale"e / الضالع") # returns ("YE30", False)
191
208
  adminlevel.get_pcode("YEM", "Al Dhale"e / الضالع", fuzzy_match=False) # returns (None, True)
192
209
  assert admintwo.get_pcode("AFG", "Kabul", parent="AF01") == ("AF0101", True)
210
+ adminlevel.get_pcode("KHM", "Kampot & Kep") # returns (None, False)
211
+ admintwo.get_pcode("VEN", "Falcón, Acosta", parent="VE11") # returns ("VE1101", False)
212
+ adminlevel = AdminLevel(config, matcher=Phonetics()) # use Phonetics
193
213
 
194
214
  There is basic admin 1 p-code length conversion by default. A more advanced
195
215
  p-code length conversion can be activated by calling *load_pcode_formats*
@@ -36,7 +36,7 @@ dynamic = ["version"]
36
36
  requires-python = ">=3.10"
37
37
 
38
38
  dependencies = [
39
- "hdx-python-utilities>=4.1.2,<5",
39
+ "hdx-python-utilities>=4.2.0,<5",
40
40
  "tenacity",
41
41
  ]
42
42