hdx-python-country 3.7.5__tar.gz → 3.7.6__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 (36) hide show
  1. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/PKG-INFO +1 -1
  2. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/requirements.txt +1 -1
  3. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/_version.py +2 -2
  4. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/adminlevel.py +19 -14
  5. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.config/coveragerc +0 -0
  6. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.config/pre-commit-config.yaml +0 -0
  7. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.config/pytest.ini +0 -0
  8. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.config/ruff.toml +0 -0
  9. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.github/workflows/publish.yaml +0 -0
  10. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.github/workflows/run-python-tests.yaml +0 -0
  11. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/.gitignore +0 -0
  12. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/CONTRIBUTING.md +0 -0
  13. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/LICENSE +0 -0
  14. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/README.md +0 -0
  15. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/documentation/.readthedocs.yaml +0 -0
  16. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/documentation/main.md +0 -0
  17. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/documentation/pydoc-markdown.yaml +0 -0
  18. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/pyproject.toml +0 -0
  19. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
  20. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/__init__.py +0 -0
  21. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/country.py +0 -0
  22. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/currency.py +0 -0
  23. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/phonetics.py +0 -0
  24. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/src/hdx/location/wfp_exchangerates.py +0 -0
  25. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/fixtures/adminlevel.yaml +0 -0
  26. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/fixtures/adminlevelparent.yaml +0 -0
  27. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/fixtures/global_pcode_lengths.csv +0 -0
  28. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/fixtures/global_pcodes_adm_1_2.csv +0 -0
  29. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/fixtures/secondary_historic_rates.csv +0 -0
  30. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/fixtures/secondary_rates.json +0 -0
  31. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
  32. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/hdx/location/__init__.py +0 -0
  33. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/hdx/location/test_adminlevel.py +0 -0
  34. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/hdx/location/test_country.py +0 -0
  35. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/hdx/location/test_currency.py +0 -0
  36. {hdx_python_country-3.7.5 → hdx_python_country-3.7.6}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hdx-python-country
3
- Version: 3.7.5
3
+ Version: 3.7.6
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
@@ -32,7 +32,7 @@ hdx-python-utilities==3.7.2
32
32
  # via hdx-python-country (pyproject.toml)
33
33
  humanize==4.9.0
34
34
  # via frictionless
35
- identify==2.5.36
35
+ identify==2.6.0
36
36
  # via pre-commit
37
37
  idna==3.7
38
38
  # via requests
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '3.7.5'
16
- __version_tuple__ = version_tuple = (3, 7, 5)
15
+ __version__ = version = '3.7.6'
16
+ __version_tuple__ = version_tuple = (3, 7, 6)
@@ -144,8 +144,9 @@ class AdminLevel:
144
144
  self.pcodes.append(pcode)
145
145
  self.pcode_to_name[pcode] = adm_name
146
146
 
147
+ adm_name = normalise(adm_name)
147
148
  name_to_pcode = self.name_to_pcode.get(countryiso3, {})
148
- name_to_pcode[normalise(adm_name)] = pcode
149
+ name_to_pcode[adm_name] = pcode
149
150
  self.name_to_pcode[countryiso3] = name_to_pcode
150
151
  self.pcode_to_iso3[pcode] = countryiso3
151
152
  self.pcode_to_iso3[pcode] = countryiso3
@@ -155,7 +156,7 @@ class AdminLevel:
155
156
  countryiso3, {}
156
157
  )
157
158
  name_to_pcode = name_parent_to_pcode.get(parent, {})
158
- name_to_pcode[normalise(adm_name)] = pcode
159
+ name_to_pcode[adm_name] = pcode
159
160
  name_parent_to_pcode[parent] = name_to_pcode
160
161
  self.name_parent_to_pcode[countryiso3] = name_parent_to_pcode
161
162
  self.pcode_to_parent[pcode] = parent
@@ -554,6 +555,7 @@ class AdminLevel:
554
555
  self,
555
556
  countryiso3: str,
556
557
  name: str,
558
+ normalised_name: str,
557
559
  **kwargs: Any,
558
560
  ) -> Optional[str]:
559
561
  """Fuzzy match name to pcode
@@ -561,6 +563,7 @@ class AdminLevel:
561
563
  Args:
562
564
  countryiso3 (str): ISO3 country code
563
565
  name (str): Name to match
566
+ normalised_name (str): Normalised name
564
567
  **kwargs:
565
568
  parent (Optional[str]): Parent admin code
566
569
  logname (str): Log using this identifying name. Defaults to not logging.
@@ -597,13 +600,12 @@ class AdminLevel:
597
600
  if logname:
598
601
  self.errors.add((logname, countryiso3, parent))
599
602
  return None
600
- adm_name_lookup = normalise(name)
601
- adm_name_lookup2 = multiple_replace(
602
- adm_name_lookup,
603
+ alt_normalised_name = multiple_replace(
604
+ normalised_name,
603
605
  self.get_admin_name_replacements(countryiso3, parent),
604
606
  )
605
607
  pcode = name_to_pcode.get(
606
- adm_name_lookup, name_to_pcode.get(adm_name_lookup2)
608
+ normalised_name, name_to_pcode.get(alt_normalised_name)
607
609
  )
608
610
  if not pcode and name.lower() in self.admin_fuzzy_dont:
609
611
  if logname:
@@ -611,7 +613,7 @@ class AdminLevel:
611
613
  return None
612
614
  if not pcode:
613
615
  for map_name in name_to_pcode:
614
- if adm_name_lookup in map_name:
616
+ if normalised_name in map_name:
615
617
  pcode = name_to_pcode[map_name]
616
618
  if logname:
617
619
  self.matches.add(
@@ -625,7 +627,7 @@ class AdminLevel:
625
627
  )
626
628
  break
627
629
  for map_name in name_to_pcode:
628
- if adm_name_lookup2 in map_name:
630
+ if alt_normalised_name in map_name:
629
631
  pcode = name_to_pcode[map_name]
630
632
  if logname:
631
633
  self.matches.add(
@@ -659,8 +661,8 @@ class AdminLevel:
659
661
 
660
662
  matching_index = self.phonetics.match(
661
663
  map_names,
662
- adm_name_lookup,
663
- alternative_name=adm_name_lookup2,
664
+ normalised_name,
665
+ alternative_name=alt_normalised_name,
664
666
  transform_possible_names=[al_transform_1, al_transform_2],
665
667
  )
666
668
 
@@ -754,6 +756,7 @@ class AdminLevel:
754
756
  )
755
757
  return pcode, True
756
758
  else:
759
+ normalised_name = normalise(name)
757
760
  if parent:
758
761
  name_parent_to_pcode = self.name_parent_to_pcode.get(
759
762
  countryiso3
@@ -761,18 +764,20 @@ class AdminLevel:
761
764
  if name_parent_to_pcode:
762
765
  name_to_pcode = name_parent_to_pcode.get(parent)
763
766
  if name_to_pcode is not None:
764
- pcode = name_to_pcode.get(name.lower())
767
+ pcode = name_to_pcode.get(normalised_name)
765
768
  if pcode:
766
769
  return pcode, True
767
770
  else:
768
771
  name_to_pcode = self.name_to_pcode.get(countryiso3)
769
772
  if name_to_pcode is not None:
770
- pcode = name_to_pcode.get(name.lower())
773
+ pcode = name_to_pcode.get(normalised_name)
771
774
  if pcode:
772
775
  return pcode, True
773
- if not fuzzy_match or len(name) < fuzzy_length:
776
+ if not fuzzy_match or len(normalised_name) < fuzzy_length:
774
777
  return None, True
775
- pcode = self.fuzzy_pcode(countryiso3, name, **kwargs)
778
+ pcode = self.fuzzy_pcode(
779
+ countryiso3, name, normalised_name, **kwargs
780
+ )
776
781
  return pcode, False
777
782
 
778
783
  def output_matches(self) -> List[str]: