hdx-python-country 4.0.1__tar.gz → 4.1.1__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 (57) hide show
  1. hdx_python_country-4.1.1/.github/workflows/publish.yaml +34 -0
  2. hdx_python_country-4.1.1/.github/workflows/run-python-tests.yaml +49 -0
  3. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/.pre-commit-config.yaml +8 -9
  4. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/PKG-INFO +28 -47
  5. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/README.md +24 -37
  6. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/documentation/index.md +43 -30
  7. hdx_python_country-4.1.1/pyproject.toml +139 -0
  8. hdx_python_country-4.0.1/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv → hdx_python_country-4.1.1/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy.csv +256 -257
  9. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/_version.py +2 -2
  10. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/adminlevel.py +132 -197
  11. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/country.py +151 -93
  12. hdx_python_country-4.1.1/tests/fixtures/adminlevel.yaml +563 -0
  13. hdx_python_country-4.1.1/tests/fixtures/adminlevelparent.yaml +25 -0
  14. hdx_python_country-4.0.1/tests/fixtures/download-global-pcode-lengths.csv → hdx_python_country-4.1.1/tests/fixtures/fixtures-download-global-pcode-lengths.csv +0 -1
  15. hdx_python_country-4.0.1/tests/fixtures/download-global-pcodes-adm-1-2.csv → hdx_python_country-4.1.1/tests/fixtures/fixtures-download-global-pcodes-adm-1-2.csv +0 -1
  16. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/hdx/location/Countries_UZB_Deleted.csv +2 -3
  17. hdx_python_country-4.1.1/tests/hdx/location/test_adminlevel.py +783 -0
  18. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/hdx/location/test_country.py +480 -450
  19. hdx_python_country-4.1.1/uv.lock +1749 -0
  20. hdx_python_country-4.0.1/.coveragerc +0 -17
  21. hdx_python_country-4.0.1/.github/workflows/publish.yaml +0 -37
  22. hdx_python_country-4.0.1/.github/workflows/run-python-tests.yaml +0 -53
  23. hdx_python_country-4.0.1/hatch.toml +0 -37
  24. hdx_python_country-4.0.1/pyproject.toml +0 -53
  25. hdx_python_country-4.0.1/pytest.ini +0 -4
  26. hdx_python_country-4.0.1/requirements.txt +0 -157
  27. hdx_python_country-4.0.1/ruff.toml +0 -10
  28. hdx_python_country-4.0.1/tests/fixtures/adminlevel.yaml +0 -563
  29. hdx_python_country-4.0.1/tests/fixtures/adminlevelparent.yaml +0 -25
  30. hdx_python_country-4.0.1/tests/hdx/location/test_adminlevel.py +0 -749
  31. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/.gitignore +0 -0
  32. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/LICENSE +0 -0
  33. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/documentation/.readthedocs.yaml +0 -0
  34. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/documentation/mkdocs.yaml +0 -0
  35. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/__init__.py +0 -0
  36. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/currency.py +0 -0
  37. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/int_timestamp.py +0 -0
  38. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/wfp_api.py +0 -0
  39. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/src/hdx/location/wfp_exchangerates.py +0 -0
  40. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/secondary_historic_rates.csv +0 -0
  41. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/secondary_rates.json +0 -0
  42. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_List_1.json +0 -0
  43. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_List_2.json +0 -0
  44. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
  45. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
  46. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
  47. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
  48. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
  49. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
  50. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
  51. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
  52. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
  53. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
  54. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/hdx/location/__init__.py +0 -0
  55. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/hdx/location/conftest.py +0 -0
  56. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/hdx/location/test_currency.py +0 -0
  57. {hdx_python_country-4.0.1 → hdx_python_country-4.1.1}/tests/hdx/location/test_wfp_exchangerates.py +0 -0
@@ -0,0 +1,34 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+
11
+ environment:
12
+ name: pypi
13
+ url: https://pypi.org/p/hdx-python-country
14
+
15
+ permissions:
16
+ id-token: write
17
+ contents: read
18
+
19
+ steps:
20
+ - uses: actions/checkout@v6
21
+
22
+ - name: Get history and tags for versioning to work
23
+ run: |
24
+ git fetch --prune --unshallow
25
+ git fetch --depth=1 origin +refs/tags/*:refs/tags/*
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v7
29
+
30
+ - name: Build with uv
31
+ run: uv build
32
+
33
+ - name: Publish distribution 📦 to PyPI
34
+ run: uv publish
@@ -0,0 +1,49 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches-ignore: [gh-pages, "dependabot/**"]
7
+ pull_request:
8
+ branches-ignore: [gh-pages]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ checks: write
16
+ pull-requests: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v6
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v7
23
+ with:
24
+ enable-cache: true
25
+ python-version: "3.13"
26
+
27
+ - name: Install dependencies
28
+ run: uv sync --frozen
29
+
30
+ - name: Check styling
31
+ run: |
32
+ uv run ruff format --check
33
+ uv run ruff check
34
+
35
+ - name: Test with pytest
36
+ run: uv run pytest
37
+
38
+ - name: Publish Unit Test Results
39
+ uses: EnricoMi/publish-unit-test-result-action@v2
40
+ if: always()
41
+ with:
42
+ files: test-results.xml
43
+
44
+ - name: Publish in Coveralls
45
+ uses: coverallsapp/github-action@v2
46
+ if: always()
47
+ with:
48
+ flag-name: tests
49
+ format: lcov
@@ -1,5 +1,6 @@
1
1
  default_language_version:
2
- python: python3.13
2
+ python: python3.13
3
+
3
4
  repos:
4
5
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
6
  rev: v6.0.0
@@ -7,20 +8,18 @@ repos:
7
8
  - id: trailing-whitespace
8
9
  - id: end-of-file-fixer
9
10
  - id: check-ast
11
+
10
12
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.14.10
13
+ rev: v0.14.13
12
14
  hooks:
13
15
  # Run the linter.
14
16
  - id: ruff-check
15
17
  args: [ --fix ]
16
18
  # Run the formatter.
17
19
  - id: ruff-format
20
+
18
21
  - repo: https://github.com/astral-sh/uv-pre-commit
19
- rev: 0.9.22
22
+ rev: 0.9.25
20
23
  hooks:
21
- # Run the pip compile
22
- - id: pip-compile
23
- name: pip-compile requirements.txt
24
- files: pyproject.toml
25
- args: [ pyproject.toml, --resolver=backtracking, --upgrade, -q,
26
- -o, requirements.txt ]
24
+ # Ensure the lockfile is up-to-date with pyproject.toml
25
+ - id: uv-lock
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hdx-python-country
3
- Version: 4.0.1
3
+ Version: 4.1.1
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
@@ -18,23 +18,17 @@ Classifier: Operating System :: Unix
18
18
  Classifier: Programming Language :: Python
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Classifier: Programming Language :: Python :: 3.8
22
- Classifier: Programming Language :: Python :: 3.9
23
21
  Classifier: Programming Language :: Python :: 3.10
24
22
  Classifier: Programming Language :: Python :: 3.11
25
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
27
  Requires-Python: >=3.10
28
- Requires-Dist: hdx-python-utilities>=4.0.1
29
- Requires-Dist: libhxl>=5.2.2
28
+ Requires-Dist: hdx-python-utilities<5,>=4.0.4
30
29
  Requires-Dist: tenacity
31
- Provides-Extra: dev
32
- Requires-Dist: pre-commit; extra == 'dev'
33
30
  Provides-Extra: docs
34
31
  Requires-Dist: mkapi; extra == 'docs'
35
- Provides-Extra: test
36
- Requires-Dist: pytest; extra == 'test'
37
- Requires-Dist: pytest-cov; extra == 'test'
38
32
  Description-Content-Type: text/markdown
39
33
 
40
34
  [![Build Status](https://github.com/OCHA-DAP/hdx-python-country/actions/workflows/run-python-tests.yaml/badge.svg)](https://github.com/OCHA-DAP/hdx-python-country/actions/workflows/run-python-tests.yaml)
@@ -70,30 +64,24 @@ This library is part of the [Humanitarian Data Exchange](https://data.humdata.or
70
64
  (HDX) project. If you have humanitarian related data, please upload your datasets to
71
65
  HDX.
72
66
 
73
- ## Development
67
+ # Development
74
68
 
75
- ### Environment
69
+ ## Environment
76
70
 
77
- Development is currently done using Python 3.12. We recommend using a virtual
78
- environment such as ``venv``:
71
+ Development is currently done using Python 3.13. The environment can be created with:
79
72
 
80
73
  ```shell
81
- python -m venv venv
82
- source venv/bin/activate
74
+ uv sync
83
75
  ```
84
76
 
85
- In your virtual environment, install all packages for development by running:
86
-
87
- ```shell
88
- pip install -r requirements.txt
89
- ```
77
+ This creates a .venv folder with the versions specified in the project's uv.lock file.
90
78
 
91
79
  ### Pre-commit
92
80
 
93
- Be sure to install `pre-commit`, which is run every time you make a git commit:
81
+ pre-commit will be installed when syncing uv. It is run every time you make a git
82
+ commit if you call it like this:
94
83
 
95
84
  ```shell
96
- pip install pre-commit
97
85
  pre-commit install
98
86
  ```
99
87
 
@@ -106,20 +94,6 @@ To check if your changes pass pre-commit without committing, run:
106
94
  pre-commit run --all-files
107
95
  ```
108
96
 
109
- ### Testing
110
-
111
- Ensure you have the required packages to run the tests:
112
-
113
- ```shell
114
- pip install -r requirements.txt
115
- ```
116
-
117
- To run the tests and view coverage, execute:
118
-
119
- ```shell
120
- pytest -c --cov hdx
121
- ```
122
-
123
97
  ## Packages
124
98
 
125
99
  [uv](https://github.com/astral-sh/uv) is used for package management. If
@@ -127,33 +101,40 @@ you’ve introduced a new package to the source code (i.e. anywhere in `src/`),
127
101
  please add it to the `project.dependencies` section of `pyproject.toml` with
128
102
  any known version constraints.
129
103
 
130
- To add packages required only for testing, add them to the `test` section under
131
- `[project.optional-dependencies]`.
104
+ To add packages required only for testing, add them to the
105
+ `[dependency-groups]`.
132
106
 
133
107
  Any changes to the dependencies will be automatically reflected in
134
- `requirements.txt` with `pre-commit`, but you can re-generate the file without
135
- committing by executing:
108
+ `uv.lock` with `pre-commit`, but you can re-generate the files without committing by
109
+ executing:
136
110
 
137
111
  ```shell
138
- pre-commit run pip-compile --all-files
112
+ uv lock --upgrade
139
113
  ```
140
114
 
141
115
  ## Project
142
116
 
143
- [Hatch](https://hatch.pypa.io/) is used for project management. The project can be built using:
117
+ [uv](https://github.com/astral-sh/uv) is used for project management. The project can be
118
+ built using:
144
119
 
145
120
  ```shell
146
- hatch build
121
+ uv build
147
122
  ```
148
123
 
149
124
  Linting and syntax checking can be run with:
150
125
 
151
126
  ```shell
152
- hatch fmt --check
127
+ uv run ruff check
153
128
  ```
154
129
 
155
- Tests can be executed using:
130
+ To run the tests and view coverage, execute:
156
131
 
157
132
  ```shell
158
- hatch test
133
+ uv run pytest
159
134
  ```
135
+
136
+ ## Documentation
137
+
138
+ The documentation, including API documentation, is generated using ReadtheDocs and
139
+ MkDocs with Material. As you change the source code, remember to update the
140
+ documentation at `documentation/index.md`.
@@ -31,30 +31,24 @@ This library is part of the [Humanitarian Data Exchange](https://data.humdata.or
31
31
  (HDX) project. If you have humanitarian related data, please upload your datasets to
32
32
  HDX.
33
33
 
34
- ## Development
34
+ # Development
35
35
 
36
- ### Environment
36
+ ## Environment
37
37
 
38
- Development is currently done using Python 3.12. We recommend using a virtual
39
- environment such as ``venv``:
38
+ Development is currently done using Python 3.13. The environment can be created with:
40
39
 
41
40
  ```shell
42
- python -m venv venv
43
- source venv/bin/activate
41
+ uv sync
44
42
  ```
45
43
 
46
- In your virtual environment, install all packages for development by running:
47
-
48
- ```shell
49
- pip install -r requirements.txt
50
- ```
44
+ This creates a .venv folder with the versions specified in the project's uv.lock file.
51
45
 
52
46
  ### Pre-commit
53
47
 
54
- Be sure to install `pre-commit`, which is run every time you make a git commit:
48
+ pre-commit will be installed when syncing uv. It is run every time you make a git
49
+ commit if you call it like this:
55
50
 
56
51
  ```shell
57
- pip install pre-commit
58
52
  pre-commit install
59
53
  ```
60
54
 
@@ -67,20 +61,6 @@ To check if your changes pass pre-commit without committing, run:
67
61
  pre-commit run --all-files
68
62
  ```
69
63
 
70
- ### Testing
71
-
72
- Ensure you have the required packages to run the tests:
73
-
74
- ```shell
75
- pip install -r requirements.txt
76
- ```
77
-
78
- To run the tests and view coverage, execute:
79
-
80
- ```shell
81
- pytest -c --cov hdx
82
- ```
83
-
84
64
  ## Packages
85
65
 
86
66
  [uv](https://github.com/astral-sh/uv) is used for package management. If
@@ -88,33 +68,40 @@ you’ve introduced a new package to the source code (i.e. anywhere in `src/`),
88
68
  please add it to the `project.dependencies` section of `pyproject.toml` with
89
69
  any known version constraints.
90
70
 
91
- To add packages required only for testing, add them to the `test` section under
92
- `[project.optional-dependencies]`.
71
+ To add packages required only for testing, add them to the
72
+ `[dependency-groups]`.
93
73
 
94
74
  Any changes to the dependencies will be automatically reflected in
95
- `requirements.txt` with `pre-commit`, but you can re-generate the file without
96
- committing by executing:
75
+ `uv.lock` with `pre-commit`, but you can re-generate the files without committing by
76
+ executing:
97
77
 
98
78
  ```shell
99
- pre-commit run pip-compile --all-files
79
+ uv lock --upgrade
100
80
  ```
101
81
 
102
82
  ## Project
103
83
 
104
- [Hatch](https://hatch.pypa.io/) is used for project management. The project can be built using:
84
+ [uv](https://github.com/astral-sh/uv) is used for project management. The project can be
85
+ built using:
105
86
 
106
87
  ```shell
107
- hatch build
88
+ uv build
108
89
  ```
109
90
 
110
91
  Linting and syntax checking can be run with:
111
92
 
112
93
  ```shell
113
- hatch fmt --check
94
+ uv run ruff check
114
95
  ```
115
96
 
116
- Tests can be executed using:
97
+ To run the tests and view coverage, execute:
117
98
 
118
99
  ```shell
119
- hatch test
100
+ uv run pytest
120
101
  ```
102
+
103
+ ## Documentation
104
+
105
+ The documentation, including API documentation, is generated using ReadtheDocs and
106
+ MkDocs with Material. As you change the source code, remember to update the
107
+ documentation at `documentation/index.md`.
@@ -42,7 +42,15 @@ 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.0.0, Python 3.10 or later is required
45
+ From 4.1.1, HXL hashtags no longer used in AdminLevel class. The header names are used
46
+ instead. setup_from_iterable replaces setup_from_admin_info and
47
+ setup_from_libhxl_dataset using keys: "Location", "P-Code", "Name" and "Parent P-Code".
48
+
49
+ From 4.1.0, HXL hashtags no longer used in Country class. The header names are used
50
+ instead.
51
+
52
+ From 4.0.0, Python 3.10 or later is required as well as HDX Python Utilities >= 4. To
53
+ continue using HDX Python Country < 4, please pin to HDX Python Utilities < 4.
46
54
 
47
55
  From 3.9.2, must call Currency.setup before using Currency methods.
48
56
 
@@ -91,26 +99,33 @@ The usage of the country mappings functionality is best illustrated by some exam
91
99
  # returns ("CZE", False)
92
100
 
93
101
  Country.get_country_info_from_iso2("jp")
94
- # Returns dictionary with HXL hashtags as keys. For more on HXL, see http://hxlstandard.org/
95
- # {"#country+alt+i_ar+name+v_m49": "اليابان", "#country+alt+i_ar+name+v_unterm": "اليابان",
96
- # "#country+alt+i_en+name+v_m49": "Japan", "#country+alt+i_en+name+v_unterm": "Japan",
97
- # "#country+alt+i_es+name+v_m49": "Japón", "#country+alt+i_es+name+v_unterm": "Japón",
98
- # "#country+alt+i_fr+name+v_m49": "Japon", "#country+alt+i_fr+name+v_unterm": "Japon",
99
- # "#country+alt+i_ru+name+v_m49": "Япония", "#country+alt+i_ru+name+v_unterm": "Япония",
100
- # "#country+alt+i_zh+name+v_m49": "日本", "#country+alt+i_zh+name+v_unterm": "日本",
101
- # "#country+alt+name+v_dgacm": "", "#country+alt+name+v_hpctools": "",
102
- # "#country+alt+name+v_iso": "", "#country+alt+name+v_reliefweb": "",
103
- # "#country+code+num+v_m49": "392", "#country+code+v_hpctools": "112",
104
- # "#country+code+v_iso2": "JP", "#country+code+v_iso3": "JPN",
105
- # "#country+code+v_reliefweb": "128", "#country+formal+i_en+name+v_unterm": "Japan",
106
- # "#country+name+preferred": "Japan", "#country+name+short+v_reliefweb": "",
107
- # "#country+regex": "japan", "#currency+code": "JPY", "#date+start": "1974-01-01",
108
- # "#geo+admin_level": "0", "#geo+lat": "37.63209801", "#geo+lon": "138.0812256",
109
- # "#indicator+bool+hrp": "", "#indicator+bool+gho": "", "#indicator+incomelevel": "High",
110
- # "#meta+bool+deprecated": "N", "#meta+bool+independent": "Y", "#meta+id": "112",
111
- # "#region+code+intermediate": "", "#region+code+main": "142", "#region+code+sub": "30",
112
- # "#region+intermediate+name+preferred": "", "#region+main+name+preferred": "Asia",
113
- # "#region+name+preferred+sub": "Eastern Asia"}
102
+ # Returns dictionary of country data
103
+ # {
104
+ # "Admin Level": "0", "Appears in DGACM list": "Y",
105
+ # "Appears in UNTERM list": "Y", "Arabic Short": "اليابان",
106
+ # "Chinese Short": "日本", "Concatenation": "112 - Japan",
107
+ # "Currency": "JPY", "DGACM Alt Term": None,
108
+ # "Deprecated": "N", "English Formal": "Japan",
109
+ # "English Short": "Japan", "French Short": "Japon",
110
+ # "HPC Tools API ID": "112", "HPC Tools Alt Term": None,
111
+ # "Has HRP": None, "ID": "112",
112
+ # "ISO 3166-1 Alpha 2-Codes": "JP", "ISO 3166-1 Alpha 3-Codes": "JPN",
113
+ # "ISO Alt Term": None, "In GHO": None,
114
+ # "Independent": "Y", "Intermediate Region Code": None,
115
+ # "Intermediate Region Name": None, "Latitude": "37.63209801",
116
+ # "Longitude": "138.0812256", "M49 Arabic": "اليابان",
117
+ # "M49 Chinese": "日本", "M49 English": "Japan",
118
+ # "M49 French": "Japon", "M49 Russian": "Япония",
119
+ # "M49 Spanish": "Japón", "Preferred Term": "Japan",
120
+ # "RW API Alt Term": None, "RW ID": "128",
121
+ # "RW Short Name": None, "Reference Period Start": "1974-01-01",
122
+ # "Regex": "japan", "Region Code": "142",
123
+ # "Region Name": "Asia", "Russian Short": "Япония",
124
+ # "Spanish Short": "Japón", "Sub-region Code": "30",
125
+ # "Sub-region Name": "Eastern Asia", "World Bank Income Level": "High",
126
+ # "m49 numerical code": "392", "x Alpha2 codes": None,
127
+ # "x Alpha3 codes": None
128
+ # }
114
129
  Country.get_countries_in_region("Channel Islands")
115
130
  # ["GGY", "JEY"]
116
131
  len(Country.get_countries_in_region("Africa"))
@@ -143,23 +158,21 @@ A Retrieve object can be passed in the *retriever* parameter that enables
143
158
  saving data downloaded to a file or loading previously saved data depending
144
159
  on how the Retrieve object is configured.
145
160
 
146
- Once an AdminLevel object is constructed, one of three setup methods must be
147
- called: *setup_from_admin_info*, *setup_from_libhxl_dataset* or
148
- *setup_from_url*.
161
+ Once an AdminLevel object is constructed, either *setup_from_iterable* or
162
+ *setup_from_url* must be called.
163
+
164
+ Method *setup_from_iterable* takes an iterable (eg. iterator or sequence) of the form:
149
165
 
150
- Method *setup_from_admin_info* takes key *admin_info* which is a list with
151
- values of the form:
166
+ {"Location": "AFG", "P-Code": "AF01", "Name": "Kabul"}
167
+ {"Location": "AFG", "P-Code": "AF0101", "Name": "Kabul", "Parent P-Code": "AF01"}
152
168
 
153
- {"iso3": "AFG", "pcode": "AF01", "name": "Kabul"}
154
- {"iso3": "AFG", "pcode": "AF0101", "name": "Kabul", "parent": "AF01"}
155
169
 
156
170
  Dictionaries *pcode_to_name* and *pcode_to_iso3* are populated in the
157
- AdminLevel object. *parent* is optional, but if provided enables lookup of
171
+ AdminLevel object. *Parent P-Code* is optional, but if provided enables lookup of
158
172
  location names by both country and parent rather than just country which should
159
173
  help with any name clashes. It also results in the population of a dictionary
160
174
  in the AdminLevel object *pcode_to_parent*.
161
175
 
162
- Method *setup_from_libhxl_dataset* takes a libhxl Dataset object, while
163
176
  *setup_from_url* takes a URL which defaults to a resource in the global p-codes
164
177
  dataset on HDX.
165
178
 
@@ -0,0 +1,139 @@
1
+ #########################
2
+ # Project Configuration #
3
+ #########################
4
+
5
+ [build-system]
6
+ requires = ["hatchling", "hatch-vcs"]
7
+ build-backend = "hatchling.build"
8
+
9
+ [project]
10
+ name = "hdx-python-country"
11
+ description = "HDX Python country code and exchange rate (fx) utilities"
12
+ authors = [{name = "Michael Rans"}]
13
+ license = {text = "MIT"}
14
+ keywords = ["HDX", "location", "country", "country code", "iso 3166", "iso2", "iso3", "region", "fx", "currency", "currencies", "exchange rate", "foreign exchange"]
15
+ classifiers = [
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Topic :: Software Development :: Libraries :: Python Modules",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Intended Audience :: Developers",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Natural Language :: English",
29
+ "Operating System :: POSIX :: Linux",
30
+ "Operating System :: Unix",
31
+ "Operating System :: MacOS",
32
+ "Operating System :: Microsoft :: Windows",
33
+ ]
34
+ readme = "README.md"
35
+ dynamic = ["version"]
36
+ requires-python = ">=3.10"
37
+
38
+ dependencies = [
39
+ "hdx-python-utilities>=4.0.4,<5",
40
+ "tenacity",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ docs = ["mkapi"]
45
+
46
+ [dependency-groups]
47
+ dev = [
48
+ "pytest",
49
+ "pytest-cov",
50
+ "pre-commit",
51
+ "ruff==0.14.13",
52
+ ]
53
+
54
+ [project.urls]
55
+ Homepage = "https://github.com/OCHA-DAP/hdx-python-country"
56
+
57
+ # ----------------------------------------------------------------------------
58
+ # Hatchling (Build & Versioning)
59
+ # ----------------------------------------------------------------------------
60
+
61
+ [tool.hatch.version]
62
+ source = "vcs"
63
+
64
+ [tool.hatch.version.raw-options]
65
+ local_scheme = "no-local-version"
66
+ version_scheme = "python-simplified-semver"
67
+
68
+ [tool.hatch.build.hooks.vcs]
69
+ version-file = "src/hdx/location/_version.py"
70
+
71
+ [tool.hatch.build.targets.wheel]
72
+ packages = ["src/hdx"]
73
+
74
+ [tool.hatch.metadata]
75
+ allow-direct-references = true
76
+
77
+ # ----------------------------------------------------------------------------
78
+ # Ruff (Linting & Formatting)
79
+ # ----------------------------------------------------------------------------
80
+
81
+ [tool.ruff]
82
+ target-version = "py310"
83
+ src = ["src"]
84
+ exclude = ["_version.py"]
85
+
86
+ [tool.ruff.lint]
87
+ # Defaults are E (pycodestyle) and F (pyflakes). We extend them:
88
+ extend-select = [
89
+ "I", # isort
90
+ "UP", # pyupgrade
91
+ ]
92
+ ignore = [
93
+ "E501", # Line too long
94
+ ]
95
+
96
+ [tool.ruff.lint.isort]
97
+ known-local-folder = ["hdx.location"]
98
+ known-third-party = [
99
+ "hdx.utilities",
100
+ ]
101
+
102
+ # ----------------------------------------------------------------------------
103
+ # Pytest (Testing)
104
+ # ----------------------------------------------------------------------------
105
+
106
+ [tool.pytest.ini_options]
107
+ pythonpath = "src"
108
+ log_cli = true
109
+ addopts = """
110
+ --color=yes
111
+ --rootdir=.
112
+ --junitxml=test-results.xml
113
+ --cov
114
+ --no-cov-on-fail
115
+ --cov-report=lcov
116
+ --cov-report=term-missing
117
+ """
118
+
119
+ # ----------------------------------------------------------------------------
120
+ # Coverage (Reporting)
121
+ # ----------------------------------------------------------------------------
122
+
123
+ [tool.coverage.run]
124
+ source = ["src"]
125
+ omit = ["*/_version.py"]
126
+
127
+ [tool.coverage.report]
128
+ exclude_also = [
129
+ "from ._version",
130
+ "def __repr__",
131
+ "if self.debug:",
132
+ "if settings.DEBUG",
133
+ "raise AssertionError",
134
+ "raise NotImplementedError",
135
+ "if 0:",
136
+ "if __name__ == .__main__.:",
137
+ "if TYPE_CHECKING:",
138
+ "@(abc\\.)?abstractmethod",
139
+ ]