hdx-python-country 3.8.8__tar.gz → 3.9.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 (50) hide show
  1. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.config/pre-commit-config.yaml +2 -2
  2. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.config/ruff.toml +0 -1
  3. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.github/workflows/publish.yaml +9 -6
  4. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.github/workflows/run-python-tests.yaml +4 -0
  5. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/PKG-INFO +4 -2
  6. hdx_python_country-3.9.0/documentation/.readthedocs.yaml +14 -0
  7. hdx_python_country-3.9.0/documentation/mkdocs.yaml +17 -0
  8. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/pyproject.toml +3 -3
  9. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/requirements.txt +91 -26
  10. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/_version.py +9 -4
  11. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/adminlevel.py +21 -59
  12. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/country.py +19 -53
  13. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/currency.py +8 -24
  14. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/wfp_exchangerates.py +18 -8
  15. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/hdx/location/test_adminlevel.py +58 -73
  16. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/hdx/location/test_country.py +18 -56
  17. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/hdx/location/test_currency.py +17 -64
  18. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/hdx/location/test_wfp_exchangerates.py +3 -4
  19. hdx_python_country-3.8.8/documentation/.readthedocs.yaml +0 -16
  20. hdx_python_country-3.8.8/documentation/pydoc-markdown.yaml +0 -32
  21. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.config/coveragerc +0 -0
  22. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.config/pytest.ini +0 -0
  23. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/.gitignore +0 -0
  24. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/CONTRIBUTING.md +0 -0
  25. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/LICENSE +0 -0
  26. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/README.md +0 -0
  27. /hdx_python_country-3.8.8/documentation/main.md → /hdx_python_country-3.9.0/documentation/index.md +0 -0
  28. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
  29. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/__init__.py +0 -0
  30. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/src/hdx/location/wfp_api.py +0 -0
  31. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/adminlevel.yaml +0 -0
  32. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/adminlevelparent.yaml +0 -0
  33. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
  34. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
  35. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/secondary_historic_rates.csv +0 -0
  36. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/secondary_rates.json +0 -0
  37. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_List_1.json +0 -0
  38. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_List_2.json +0 -0
  39. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
  40. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
  41. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
  42. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
  43. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
  44. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
  45. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
  46. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
  47. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
  48. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
  49. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
  50. {hdx_python_country-3.8.8 → hdx_python_country-3.9.0}/tests/hdx/location/__init__.py +0 -0
@@ -8,7 +8,7 @@ repos:
8
8
  - id: end-of-file-fixer
9
9
  - id: check-ast
10
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.8.6
11
+ rev: v0.9.10
12
12
  hooks:
13
13
  # Run the linter.
14
14
  - id: ruff
@@ -17,7 +17,7 @@ repos:
17
17
  - id: ruff-format
18
18
  args: [--config, .config/ruff.toml]
19
19
  - repo: https://github.com/astral-sh/uv-pre-commit
20
- rev: 0.5.15
20
+ rev: 0.6.5
21
21
  hooks:
22
22
  # Run the pip compile
23
23
  - id: pip-compile
@@ -1,4 +1,3 @@
1
- line-length = 79
2
1
  exclude = ["_version.py"]
3
2
 
4
3
  [lint]
@@ -8,6 +8,13 @@ jobs:
8
8
  publish:
9
9
  runs-on: ubuntu-latest
10
10
 
11
+ environment:
12
+ name: pypi
13
+ url: https://pypi.org/p/hdx-python-utilities
14
+
15
+ permissions:
16
+ id-token: write # IMPORTANT: mandatory for trusted publishing
17
+
11
18
  steps:
12
19
  - uses: actions/checkout@v4
13
20
  - name: Get history and tags for versioning to work
@@ -26,9 +33,5 @@ jobs:
26
33
  - name: Build with hatch
27
34
  run: |
28
35
  hatch build
29
- - name: Publish with hatch
30
- env:
31
- HATCH_INDEX_USER: ${{secrets.HATCH_INDEX_USER}}
32
- HATCH_INDEX_AUTH: ${{secrets.HATCH_INDEX_AUTH}}
33
- run: |
34
- hatch publish
36
+ - name: Publish distribution 📦 to PyPI
37
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -17,6 +17,10 @@ jobs:
17
17
  build:
18
18
  runs-on: ubuntu-latest
19
19
 
20
+ permissions:
21
+ checks: write
22
+ pull-requests: write
23
+
20
24
  steps:
21
25
  - uses: actions/checkout@v4
22
26
  - name: Set up Python
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hdx-python-country
3
- Version: 3.8.8
3
+ Version: 3.9.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
  Author: Michael Rans
@@ -25,11 +25,13 @@ Classifier: Programming Language :: Python :: 3.11
25
25
  Classifier: Programming Language :: Python :: 3.12
26
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
27
  Requires-Python: >=3.8
28
- Requires-Dist: hdx-python-utilities>=3.8.0
28
+ Requires-Dist: hdx-python-utilities>=3.8.5
29
29
  Requires-Dist: libhxl>=5.2.2
30
30
  Requires-Dist: tenacity
31
31
  Provides-Extra: dev
32
32
  Requires-Dist: pre-commit; extra == 'dev'
33
+ Provides-Extra: docs
34
+ Requires-Dist: mkapi; extra == 'docs'
33
35
  Provides-Extra: test
34
36
  Requires-Dist: pytest; extra == 'test'
35
37
  Requires-Dist: pytest-cov; extra == 'test'
@@ -0,0 +1,14 @@
1
+ # Required
2
+ version: 2
3
+
4
+ # Set the version of Python and other tools you might need
5
+ build:
6
+ os: ubuntu-24.04
7
+ tools:
8
+ python: "3.12"
9
+ jobs:
10
+ pre_build:
11
+ - pip install .[docs]
12
+
13
+ mkdocs:
14
+ configuration: documentation/mkdocs.yaml
@@ -0,0 +1,17 @@
1
+ site_name: HDX Python Country
2
+ repo_url: https://github.com/OCHA-DAP/hdx-python-country/
3
+ repo_name: OCHA-DAP/hdx-python-country
4
+ docs_dir: .
5
+ site_dir: ../site
6
+ theme:
7
+ name: material
8
+ highlightjs: true
9
+ plugins:
10
+ - search
11
+ - mkapi
12
+ nav:
13
+ - Home: index.md
14
+ - API Documentation:
15
+ - Countries: $src/hdx.location.country.*
16
+ - Administration Level: $src/hdx.location.adminlevel.*
17
+ - Currencies: $src/hdx.location.currency.*
@@ -34,7 +34,7 @@ classifiers = [
34
34
  requires-python = ">=3.8"
35
35
 
36
36
  dependencies = [
37
- "hdx-python-utilities>=3.8.0",
37
+ "hdx-python-utilities>=3.8.5",
38
38
  "libhxl>=5.2.2",
39
39
  "tenacity",
40
40
  ]
@@ -50,7 +50,7 @@ Homepage = "https://github.com/OCHA-DAP/hdx-python-country"
50
50
  [project.optional-dependencies]
51
51
  test = ["pytest", "pytest-cov"]
52
52
  dev = ["pre-commit"]
53
-
53
+ docs = ["mkapi"]
54
54
 
55
55
  #########
56
56
  # Hatch #
@@ -92,7 +92,7 @@ run = """
92
92
  """
93
93
 
94
94
  [tool.hatch.envs.hatch-static-analysis]
95
- dependencies = ["ruff==0.8.6"]
95
+ dependencies = ["ruff==0.9.10"]
96
96
 
97
97
  [tool.hatch.envs.hatch-static-analysis.scripts]
98
98
  format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
@@ -2,13 +2,19 @@
2
2
  # uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
3
3
  annotated-types==0.7.0
4
4
  # via pydantic
5
- attrs==24.3.0
5
+ astdoc==1.1.5
6
+ # via mkapi
7
+ attrs==25.3.0
6
8
  # via
7
9
  # frictionless
8
10
  # jsonlines
9
11
  # jsonschema
10
12
  # referencing
11
- certifi==2024.12.14
13
+ babel==2.17.0
14
+ # via mkdocs-material
15
+ backrefs==5.8
16
+ # via mkdocs-material
17
+ certifi==2025.1.31
12
18
  # via requests
13
19
  cfgv==3.4.0
14
20
  # via pre-commit
@@ -17,33 +23,43 @@ chardet==5.2.0
17
23
  charset-normalizer==3.4.1
18
24
  # via requests
19
25
  click==8.1.8
20
- # via typer
21
- coverage==7.6.10
26
+ # via
27
+ # mkdocs
28
+ # typer
29
+ colorama==0.4.6
30
+ # via mkdocs-material
31
+ coverage==7.7.0
22
32
  # via pytest-cov
23
33
  distlib==0.3.9
24
34
  # via virtualenv
25
35
  et-xmlfile==2.0.0
26
36
  # via openpyxl
27
- filelock==3.16.1
37
+ filelock==3.18.0
28
38
  # via virtualenv
29
39
  frictionless==5.18.0
30
40
  # via hdx-python-utilities
31
- hdx-python-utilities==3.8.0
41
+ ghp-import==2.1.0
42
+ # via mkdocs
43
+ hdx-python-utilities==3.8.5
32
44
  # via hdx-python-country (pyproject.toml)
33
- humanize==4.11.0
45
+ humanize==4.12.1
34
46
  # via frictionless
35
- identify==2.6.5
47
+ identify==2.6.9
36
48
  # via pre-commit
37
49
  idna==3.10
38
50
  # via requests
39
51
  ijson==3.3.0
40
52
  # via hdx-python-utilities
41
- iniconfig==2.0.0
53
+ iniconfig==2.1.0
42
54
  # via pytest
43
55
  isodate==0.7.2
44
56
  # via frictionless
45
- jinja2==3.1.5
46
- # via frictionless
57
+ jinja2==3.1.6
58
+ # via
59
+ # frictionless
60
+ # mkapi
61
+ # mkdocs
62
+ # mkdocs-material
47
63
  jsonlines==4.0.0
48
64
  # via hdx-python-utilities
49
65
  jsonpath-ng==1.7.0
@@ -58,41 +74,77 @@ libhxl==5.2.2
58
74
  # via hdx-python-country (pyproject.toml)
59
75
  loguru==0.7.3
60
76
  # via hdx-python-utilities
77
+ markdown==3.7
78
+ # via
79
+ # astdoc
80
+ # mkdocs
81
+ # mkdocs-material
82
+ # pymdown-extensions
61
83
  markdown-it-py==3.0.0
62
84
  # via rich
63
85
  marko==2.1.2
64
86
  # via frictionless
65
87
  markupsafe==3.0.2
66
- # via jinja2
88
+ # via
89
+ # jinja2
90
+ # mkdocs
67
91
  mdurl==0.1.2
68
92
  # via markdown-it-py
93
+ mergedeep==1.3.4
94
+ # via
95
+ # mkdocs
96
+ # mkdocs-get-deps
97
+ mkapi==4.1.3
98
+ # via hdx-python-country (pyproject.toml)
99
+ mkdocs==1.6.1
100
+ # via
101
+ # mkapi
102
+ # mkdocs-material
103
+ mkdocs-get-deps==0.2.0
104
+ # via mkdocs
105
+ mkdocs-material==9.6.9
106
+ # via mkapi
107
+ mkdocs-material-extensions==1.3.1
108
+ # via mkdocs-material
69
109
  nodeenv==1.9.1
70
110
  # via pre-commit
71
111
  openpyxl==3.1.5
72
112
  # via hdx-python-utilities
73
113
  packaging==24.2
74
- # via pytest
114
+ # via
115
+ # mkdocs
116
+ # pytest
117
+ paginate==0.5.7
118
+ # via mkdocs-material
119
+ pathspec==0.12.1
120
+ # via mkdocs
75
121
  petl==1.7.15
76
122
  # via frictionless
77
- platformdirs==4.3.6
78
- # via virtualenv
123
+ platformdirs==4.3.7
124
+ # via
125
+ # mkdocs-get-deps
126
+ # virtualenv
79
127
  pluggy==1.5.0
80
128
  # via pytest
81
129
  ply==3.11
82
130
  # via
83
131
  # jsonpath-ng
84
132
  # libhxl
85
- pre-commit==4.0.1
133
+ pre-commit==4.2.0
86
134
  # via hdx-python-country (pyproject.toml)
87
- pydantic==2.10.5
135
+ pydantic==2.10.6
88
136
  # via frictionless
89
137
  pydantic-core==2.27.2
90
138
  # via pydantic
91
139
  pygments==2.19.1
92
- # via rich
140
+ # via
141
+ # mkdocs-material
142
+ # rich
143
+ pymdown-extensions==10.14.3
144
+ # via mkdocs-material
93
145
  pyphonetics==0.5.3
94
146
  # via hdx-python-utilities
95
- pytest==8.3.4
147
+ pytest==8.3.5
96
148
  # via
97
149
  # hdx-python-country (pyproject.toml)
98
150
  # pytest-cov
@@ -101,6 +153,7 @@ pytest-cov==6.0.0
101
153
  python-dateutil==2.9.0.post0
102
154
  # via
103
155
  # frictionless
156
+ # ghp-import
104
157
  # hdx-python-utilities
105
158
  # libhxl
106
159
  python-io-wrapper==0.3.1
@@ -110,11 +163,17 @@ python-slugify==8.0.4
110
163
  pyyaml==6.0.2
111
164
  # via
112
165
  # frictionless
166
+ # mkdocs
167
+ # mkdocs-get-deps
113
168
  # pre-commit
169
+ # pymdown-extensions
170
+ # pyyaml-env-tag
114
171
  # tableschema-to-template
172
+ pyyaml-env-tag==0.1
173
+ # via mkdocs
115
174
  ratelimit==2.2.1
116
175
  # via hdx-python-utilities
117
- referencing==0.35.1
176
+ referencing==0.36.2
118
177
  # via
119
178
  # jsonschema
120
179
  # jsonschema-specifications
@@ -122,14 +181,17 @@ requests==2.32.3
122
181
  # via
123
182
  # frictionless
124
183
  # libhxl
184
+ # mkdocs-material
125
185
  # requests-file
126
186
  requests-file==2.1.0
127
187
  # via hdx-python-utilities
128
188
  rfc3986==2.0.0
129
189
  # via frictionless
130
190
  rich==13.9.4
131
- # via typer
132
- rpds-py==0.22.3
191
+ # via
192
+ # mkapi
193
+ # typer
194
+ rpds-py==0.23.1
133
195
  # via
134
196
  # jsonschema
135
197
  # referencing
@@ -145,7 +207,7 @@ six==1.17.0
145
207
  # via python-dateutil
146
208
  stringcase==1.2.0
147
209
  # via frictionless
148
- structlog==24.4.0
210
+ structlog==25.2.0
149
211
  # via libhxl
150
212
  tableschema-to-template==0.0.13
151
213
  # via hdx-python-utilities
@@ -155,13 +217,14 @@ tenacity==9.0.0
155
217
  # via hdx-python-country (pyproject.toml)
156
218
  text-unidecode==1.3
157
219
  # via python-slugify
158
- typer==0.15.1
220
+ typer==0.15.2
159
221
  # via frictionless
160
222
  typing-extensions==4.12.2
161
223
  # via
162
224
  # frictionless
163
225
  # pydantic
164
226
  # pydantic-core
227
+ # referencing
165
228
  # typer
166
229
  unidecode==1.3.8
167
230
  # via
@@ -173,8 +236,10 @@ urllib3==2.3.0
173
236
  # requests
174
237
  validators==0.34.0
175
238
  # via frictionless
176
- virtualenv==20.28.1
239
+ virtualenv==20.29.3
177
240
  # via pre-commit
241
+ watchdog==6.0.0
242
+ # via mkdocs
178
243
  wheel==0.45.1
179
244
  # via libhxl
180
245
  xlrd==2.0.1
@@ -183,7 +248,7 @@ xlrd3==1.1.0
183
248
  # via libhxl
184
249
  xlsx2csv==0.8.4
185
250
  # via hdx-python-utilities
186
- xlsxwriter==3.2.0
251
+ xlsxwriter==3.2.2
187
252
  # via tableschema-to-template
188
253
  xlwt==1.3.0
189
254
  # via hdx-python-utilities
@@ -1,8 +1,13 @@
1
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
3
6
  TYPE_CHECKING = False
4
7
  if TYPE_CHECKING:
5
- from typing import Tuple, Union
8
+ from typing import Tuple
9
+ from typing import Union
10
+
6
11
  VERSION_TUPLE = Tuple[Union[int, str], ...]
7
12
  else:
8
13
  VERSION_TUPLE = object
@@ -12,5 +17,5 @@ __version__: str
12
17
  __version_tuple__: VERSION_TUPLE
13
18
  version_tuple: VERSION_TUPLE
14
19
 
15
- __version__ = version = '3.8.8'
16
- __version_tuple__ = version_tuple = (3, 8, 8)
20
+ __version__ = version = '3.9.0'
21
+ __version_tuple__ = version_tuple = (3, 9, 0)
@@ -67,9 +67,7 @@ class AdminLevel:
67
67
  self.retriever: Optional[Retrieve] = retriever
68
68
  self.countries_fuzzy_try = admin_config.get("countries_fuzzy_try")
69
69
  self.admin_name_mappings = admin_config.get("admin_name_mappings", {})
70
- self.admin_name_replacements = admin_config.get(
71
- "admin_name_replacements", {}
72
- )
70
+ self.admin_name_replacements = admin_config.get("admin_name_replacements", {})
73
71
  self.admin_fuzzy_dont = admin_config.get("admin_fuzzy_dont", list())
74
72
  self.pcodes = []
75
73
  self.pcode_lengths = {}
@@ -135,9 +133,7 @@ class AdminLevel:
135
133
  try:
136
134
  url_to_use = retriever.download_file(url)
137
135
  except DownloadError:
138
- logger.exception(
139
- f"Setup of libhxl Dataset object with {url} failed!"
140
- )
136
+ logger.exception(f"Setup of libhxl Dataset object with {url} failed!")
141
137
  raise
142
138
  else:
143
139
  url_to_use = url
@@ -147,9 +143,7 @@ class AdminLevel:
147
143
  InputOptions(InputOptions(allow_local=True, encoding="utf-8")),
148
144
  )
149
145
  except (FileNotFoundError, HXLIOException):
150
- logger.exception(
151
- f"Setup of libhxl Dataset object with {url} failed!"
152
- )
146
+ logger.exception(f"Setup of libhxl Dataset object with {url} failed!")
153
147
  raise
154
148
 
155
149
  def setup_row(
@@ -178,9 +172,7 @@ class AdminLevel:
178
172
  self.pcode_to_name[pcode] = adm_name
179
173
  self.pcode_to_iso3[pcode] = countryiso3
180
174
  if not adm_name:
181
- logger.error(
182
- f"Admin name is blank for pcode {pcode} of {countryiso3}!"
183
- )
175
+ logger.error(f"Admin name is blank for pcode {pcode} of {countryiso3}!")
184
176
  return
185
177
 
186
178
  adm_name = normalise(adm_name)
@@ -189,9 +181,7 @@ class AdminLevel:
189
181
  self.name_to_pcode[countryiso3] = name_to_pcode
190
182
 
191
183
  if self.use_parent:
192
- name_parent_to_pcode = self.name_parent_to_pcode.get(
193
- countryiso3, {}
194
- )
184
+ name_parent_to_pcode = self.name_parent_to_pcode.get(countryiso3, {})
195
185
  name_to_pcode = name_parent_to_pcode.get(parent, {})
196
186
  name_to_pcode[adm_name] = pcode
197
187
  name_parent_to_pcode[parent] = name_to_pcode
@@ -216,9 +206,7 @@ class AdminLevel:
216
206
  None
217
207
  """
218
208
  if countryiso3s:
219
- countryiso3s = [
220
- countryiso3.upper() for countryiso3 in countryiso3s
221
- ]
209
+ countryiso3s = [countryiso3.upper() for countryiso3 in countryiso3s]
222
210
  self.use_parent = "parent" in admin_info[0]
223
211
  for row in admin_info:
224
212
  countryiso3 = row["iso3"].upper()
@@ -244,13 +232,9 @@ class AdminLevel:
244
232
  Returns:
245
233
  None
246
234
  """
247
- admin_info = libhxl_dataset.with_rows(
248
- f"#geo+admin_level={self.admin_level}"
249
- )
235
+ admin_info = libhxl_dataset.with_rows(f"#geo+admin_level={self.admin_level}")
250
236
  if countryiso3s:
251
- countryiso3s = [
252
- countryiso3.upper() for countryiso3 in countryiso3s
253
- ]
237
+ countryiso3s = [countryiso3.upper() for countryiso3 in countryiso3s]
254
238
  self.use_parent = "#adm+code+parent" in admin_info.display_tags
255
239
  for row in admin_info:
256
240
  countryiso3 = row.get("#country+code").upper()
@@ -411,9 +395,7 @@ class AdminLevel:
411
395
  pcode_format = self.pcode_formats.get(countryiso3)
412
396
  if not pcode_format:
413
397
  if self.get_admin_level(countryiso3) == 1:
414
- return self.convert_admin1_pcode_length(
415
- countryiso3, pcode, logname
416
- )
398
+ return self.convert_admin1_pcode_length(countryiso3, pcode, logname)
417
399
  return None
418
400
  countryiso, digits = match.groups()
419
401
  countryiso_length = len(countryiso)
@@ -465,15 +447,10 @@ class AdminLevel:
465
447
  if admin_length > 2 and pos in self.zeroes[countryiso3]:
466
448
  pcode_part = f"0{pcode_part}"
467
449
  if self.parent_admins and admin_no < self.admin_level:
468
- parent_pcode = [
469
- pcode_parts[i] for i in range(admin_no)
470
- ]
450
+ parent_pcode = [pcode_parts[i] for i in range(admin_no)]
471
451
  parent_pcode.append(pcode_part[:admin_length])
472
452
  parent_pcode = "".join(parent_pcode)
473
- if (
474
- parent_pcode
475
- not in self.parent_admins[admin_no - 1]
476
- ):
453
+ if parent_pcode not in self.parent_admins[admin_no - 1]:
477
454
  pcode_part = pcode_part[1:]
478
455
  else:
479
456
  admin_changes.append(str(admin_no))
@@ -483,15 +460,10 @@ class AdminLevel:
483
460
  if admin_length <= 2 and pcode_part[0] == "0":
484
461
  pcode_part = pcode_part[1:]
485
462
  if self.parent_admins and admin_no < self.admin_level:
486
- parent_pcode = [
487
- pcode_parts[i] for i in range(admin_no)
488
- ]
463
+ parent_pcode = [pcode_parts[i] for i in range(admin_no)]
489
464
  parent_pcode.append(pcode_part[:admin_length])
490
465
  parent_pcode = "".join(parent_pcode)
491
- if (
492
- parent_pcode
493
- not in self.parent_admins[admin_no - 1]
494
- ):
466
+ if parent_pcode not in self.parent_admins[admin_no - 1]:
495
467
  pcode_part = f"0{pcode_part}"
496
468
  else:
497
469
  admin_changes.append(str(admin_no))
@@ -533,11 +505,7 @@ class AdminLevel:
533
505
  country_pcodelength = self.pcode_lengths.get(countryiso3)
534
506
  if not country_pcodelength:
535
507
  return None
536
- if (
537
- pcode_length == country_pcodelength
538
- or pcode_length < 4
539
- or pcode_length > 6
540
- ):
508
+ if pcode_length == country_pcodelength or pcode_length < 4 or pcode_length > 6:
541
509
  return None
542
510
  if country_pcodelength == 4:
543
511
  pcode = f"{Country.get_iso2_from_iso3(pcode[:3])}{pcode[-2:]}"
@@ -690,9 +658,7 @@ class AdminLevel:
690
658
  pcode = name_to_pcode.get(
691
659
  normalised_name, name_to_pcode.get(alt_normalised_name)
692
660
  )
693
- if not pcode and name.lower() in self.get_admin_fuzzy_dont(
694
- countryiso3, parent
695
- ):
661
+ if not pcode and name.lower() in self.get_admin_fuzzy_dont(countryiso3, parent):
696
662
  if logname:
697
663
  self.ignored.add((logname, countryiso3, name))
698
664
  return None
@@ -836,16 +802,12 @@ class AdminLevel:
836
802
  return name, True
837
803
  # name looks like a p-code, but doesn't match p-codes
838
804
  # so try adjusting p-code length
839
- pcode = self.convert_admin_pcode_length(
840
- countryiso3, pcode, **kwargs
841
- )
805
+ pcode = self.convert_admin_pcode_length(countryiso3, pcode, **kwargs)
842
806
  return pcode, True
843
807
  else:
844
808
  normalised_name = normalise(name)
845
809
  if parent:
846
- name_parent_to_pcode = self.name_parent_to_pcode.get(
847
- countryiso3
848
- )
810
+ name_parent_to_pcode = self.name_parent_to_pcode.get(countryiso3)
849
811
  if name_parent_to_pcode:
850
812
  name_to_pcode = name_parent_to_pcode.get(parent)
851
813
  if name_to_pcode is not None:
@@ -860,9 +822,7 @@ class AdminLevel:
860
822
  return pcode, True
861
823
  if not fuzzy_match or len(normalised_name) < fuzzy_length:
862
824
  return None, True
863
- pcode = self.fuzzy_pcode(
864
- countryiso3, name, normalised_name, **kwargs
865
- )
825
+ pcode = self.fuzzy_pcode(countryiso3, name, normalised_name, **kwargs)
866
826
  return pcode, False
867
827
 
868
828
  def output_matches(self) -> List[str]:
@@ -905,7 +865,9 @@ class AdminLevel:
905
865
  if len(error) == 2:
906
866
  line = f"{error[0]} - Could not find {error[1]} in map names!"
907
867
  else:
908
- line = f"{error[0]} - {error[1]}: Could not find {error[2]} in map names!"
868
+ line = (
869
+ f"{error[0]} - {error[1]}: Could not find {error[2]} in map names!"
870
+ )
909
871
  logger.error(line)
910
872
  output.append(line)
911
873
  return output