hdx-python-country 3.9.0__tar.gz → 3.9.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.
- hdx_python_country-3.9.0/.config/pre-commit-config.yaml → hdx_python_country-3.9.1/.pre-commit-config.yaml +1 -2
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/CONTRIBUTING.md +5 -12
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/PKG-INFO +1 -1
- hdx_python_country-3.9.1/hatch.toml +37 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/pyproject.toml +0 -48
- {hdx_python_country-3.9.0/.config → hdx_python_country-3.9.1}/pytest.ini +1 -1
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/requirements.txt +1 -1
- hdx_python_country-3.9.1/src/hdx/location/__init__.py +1 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/_version.py +2 -2
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/currency.py +3 -3
- hdx_python_country-3.9.1/src/hdx/location/int_timestamp.py +22 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/wfp_exchangerates.py +1 -1
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/test_currency.py +1 -1
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/test_wfp_exchangerates.py +1 -1
- hdx_python_country-3.9.0/src/hdx/location/__init__.py +0 -17
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/.github/workflows/publish.yaml +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/.gitignore +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/LICENSE +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/README.md +0 -0
- {hdx_python_country-3.9.0/.config → hdx_python_country-3.9.1}/coveragerc +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/documentation/index.md +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/documentation/mkdocs.yaml +0 -0
- {hdx_python_country-3.9.0/.config → hdx_python_country-3.9.1}/ruff.toml +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/adminlevel.py +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/country.py +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/src/hdx/location/wfp_api.py +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/adminlevel.yaml +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/adminlevelparent.yaml +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/secondary_historic_rates.csv +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/secondary_rates.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_List_1.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_List_2.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/__init__.py +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/test_adminlevel.py +0 -0
- {hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/test_country.py +0 -0
|
@@ -12,10 +12,9 @@ repos:
|
|
|
12
12
|
hooks:
|
|
13
13
|
# Run the linter.
|
|
14
14
|
- id: ruff
|
|
15
|
-
args: [
|
|
15
|
+
args: [ --fix ]
|
|
16
16
|
# Run the formatter.
|
|
17
17
|
- id: ruff-format
|
|
18
|
-
args: [--config, .config/ruff.toml]
|
|
19
18
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
20
19
|
rev: 0.6.5
|
|
21
20
|
hooks:
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Environment
|
|
4
4
|
|
|
5
|
-
Development is currently done using Python 3.
|
|
5
|
+
Development is currently done using Python 3.12. We recommend using a virtual
|
|
6
6
|
environment such as ``venv``:
|
|
7
7
|
|
|
8
|
-
python3.
|
|
8
|
+
python3.12 -m venv venv
|
|
9
9
|
source venv/bin/activate
|
|
10
10
|
|
|
11
11
|
In your virtual environment, please install all packages for
|
|
@@ -20,25 +20,18 @@ you make a git commit:
|
|
|
20
20
|
|
|
21
21
|
pre-commit install
|
|
22
22
|
|
|
23
|
-
The configuration file for this project is in a
|
|
24
|
-
non-standard location. Thus, you will need to edit your
|
|
25
|
-
`.git/hooks/pre-commit` file to reflect this. Change
|
|
26
|
-
the line that begins with `ARGS` to:
|
|
27
|
-
|
|
28
|
-
ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit)
|
|
29
|
-
|
|
30
23
|
With pre-commit, all code is formatted according to
|
|
31
24
|
[ruff](https://github.com/astral-sh/ruff) guidelines.
|
|
32
25
|
|
|
33
26
|
To check if your changes pass pre-commit without committing, run:
|
|
34
27
|
|
|
35
|
-
pre-commit run --all-files
|
|
28
|
+
pre-commit run --all-files
|
|
36
29
|
|
|
37
30
|
## Testing
|
|
38
31
|
|
|
39
32
|
To run the tests and view coverage, execute:
|
|
40
33
|
|
|
41
|
-
pytest
|
|
34
|
+
pytest --cov hdx
|
|
42
35
|
|
|
43
36
|
Follow the example set out already in ``documentation/main.md`` as you write the documentation.
|
|
44
37
|
|
|
@@ -57,4 +50,4 @@ Any changes to the dependencies will be automatically reflected in
|
|
|
57
50
|
`requirements.txt` with `pre-commit`, but you can re-generate
|
|
58
51
|
the file without committing by executing:
|
|
59
52
|
|
|
60
|
-
pre-commit run pip-compile --all-files
|
|
53
|
+
pre-commit run pip-compile --all-files
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Build
|
|
2
|
+
|
|
3
|
+
[build.targets.wheel]
|
|
4
|
+
packages = ["src/hdx"]
|
|
5
|
+
|
|
6
|
+
[build.hooks.vcs]
|
|
7
|
+
version-file = "src/hdx/location/_version.py"
|
|
8
|
+
|
|
9
|
+
[metadata]
|
|
10
|
+
allow-direct-references = true
|
|
11
|
+
|
|
12
|
+
# Versioning
|
|
13
|
+
|
|
14
|
+
[version]
|
|
15
|
+
source = "vcs"
|
|
16
|
+
|
|
17
|
+
[version.raw-options]
|
|
18
|
+
local_scheme = "no-local-version"
|
|
19
|
+
version_scheme = "python-simplified-semver"
|
|
20
|
+
|
|
21
|
+
# Tests
|
|
22
|
+
|
|
23
|
+
[envs.hatch-test]
|
|
24
|
+
features = ["test"]
|
|
25
|
+
|
|
26
|
+
[[envs.hatch-test.matrix]]
|
|
27
|
+
python = ["3.12"]
|
|
28
|
+
|
|
29
|
+
[envs.hatch-test.scripts]
|
|
30
|
+
run = """
|
|
31
|
+
pytest --rootdir=. --junitxml=test-results.xml --cov --no-cov-on-fail \
|
|
32
|
+
--cov-report=lcov --cov-report=term-missing
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
[envs.hatch-static-analysis]
|
|
36
|
+
config-path = "none"
|
|
37
|
+
dependencies = ["ruff==0.9.10"]
|
|
@@ -51,51 +51,3 @@ Homepage = "https://github.com/OCHA-DAP/hdx-python-country"
|
|
|
51
51
|
test = ["pytest", "pytest-cov"]
|
|
52
52
|
dev = ["pre-commit"]
|
|
53
53
|
docs = ["mkapi"]
|
|
54
|
-
|
|
55
|
-
#########
|
|
56
|
-
# Hatch #
|
|
57
|
-
#########
|
|
58
|
-
|
|
59
|
-
# Build
|
|
60
|
-
|
|
61
|
-
[tool.hatch.build.targets.wheel]
|
|
62
|
-
packages = ["src/hdx"]
|
|
63
|
-
|
|
64
|
-
[tool.hatch.build.hooks.vcs]
|
|
65
|
-
version-file = "src/hdx/location/_version.py"
|
|
66
|
-
|
|
67
|
-
[tool.hatch.metadata]
|
|
68
|
-
allow-direct-references = true
|
|
69
|
-
|
|
70
|
-
# Versioning
|
|
71
|
-
|
|
72
|
-
[tool.hatch.version]
|
|
73
|
-
source = "vcs"
|
|
74
|
-
|
|
75
|
-
[tool.hatch.version.raw-options]
|
|
76
|
-
local_scheme = "no-local-version"
|
|
77
|
-
version_scheme = "python-simplified-semver"
|
|
78
|
-
|
|
79
|
-
# Tests
|
|
80
|
-
|
|
81
|
-
[tool.hatch.envs.hatch-test]
|
|
82
|
-
features = ["test"]
|
|
83
|
-
|
|
84
|
-
[[tool.hatch.envs.hatch-test.matrix]]
|
|
85
|
-
python = ["3.12"]
|
|
86
|
-
|
|
87
|
-
[tool.hatch.envs.hatch-test.scripts]
|
|
88
|
-
run = """
|
|
89
|
-
pytest -c .config/pytest.ini --rootdir=. --junitxml=test-results.xml \
|
|
90
|
-
--cov --cov-config=.config/coveragerc --no-cov-on-fail \
|
|
91
|
-
--cov-report=lcov --cov-report=term-missing
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
[tool.hatch.envs.hatch-static-analysis]
|
|
95
|
-
dependencies = ["ruff==0.9.10"]
|
|
96
|
-
|
|
97
|
-
[tool.hatch.envs.hatch-static-analysis.scripts]
|
|
98
|
-
format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
|
|
99
|
-
format-fix = ["ruff format --config .config/ruff.toml {args:.}",]
|
|
100
|
-
lint-check = ["ruff check --config .config/ruff.toml {args:.}",]
|
|
101
|
-
lint-fix = ["ruff check --config .config/ruff.toml --fix {args:.}",]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from ._version import version as __version__ # noqa: F401
|
|
@@ -5,7 +5,7 @@ from copy import copy
|
|
|
5
5
|
from datetime import datetime, timezone
|
|
6
6
|
from typing import Dict, Optional, Union
|
|
7
7
|
|
|
8
|
-
from . import get_int_timestamp
|
|
8
|
+
from .int_timestamp import get_int_timestamp
|
|
9
9
|
from hdx.utilities.dateparse import (
|
|
10
10
|
now_utc,
|
|
11
11
|
parse_date,
|
|
@@ -318,7 +318,7 @@ class Currency:
|
|
|
318
318
|
return fx_rate
|
|
319
319
|
fx_rate = cls._get_secondary_current_rate(currency)
|
|
320
320
|
if fx_rate is not None:
|
|
321
|
-
logger.
|
|
321
|
+
logger.debug(f"Using secondary current rate for {currency}!")
|
|
322
322
|
cls._cached_current_rates[currency] = fx_rate
|
|
323
323
|
return fx_rate
|
|
324
324
|
raise CurrencyError(f"Failed to get rate for currency {currency}!")
|
|
@@ -480,7 +480,7 @@ class Currency:
|
|
|
480
480
|
if cls._fallback_to_current:
|
|
481
481
|
fx_rate = cls.get_current_rate(currency)
|
|
482
482
|
if fx_rate:
|
|
483
|
-
logger.
|
|
483
|
+
logger.debug(
|
|
484
484
|
f"Falling back to current rate for currency {currency} on date {date.isoformat()}!"
|
|
485
485
|
)
|
|
486
486
|
return fx_rate
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
from hdx.utilities.dateparse import get_timestamp_from_datetime
|
|
4
|
+
|
|
5
|
+
_cache_timestamp_lookup = {}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def get_int_timestamp(date: datetime) -> int:
|
|
9
|
+
"""
|
|
10
|
+
Get integer timestamp from datetime object with caching
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
date (datetime): datetime object
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
int: Integer timestamp
|
|
17
|
+
"""
|
|
18
|
+
timestamp = _cache_timestamp_lookup.get(date)
|
|
19
|
+
if timestamp is None:
|
|
20
|
+
timestamp = int(round(get_timestamp_from_datetime(date)))
|
|
21
|
+
_cache_timestamp_lookup[date] = timestamp
|
|
22
|
+
return timestamp
|
|
@@ -4,8 +4,8 @@ from os.path import join
|
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
6
|
|
|
7
|
-
from hdx.location import get_int_timestamp
|
|
8
7
|
from hdx.location.currency import Currency, CurrencyError
|
|
8
|
+
from hdx.location.int_timestamp import get_int_timestamp
|
|
9
9
|
from hdx.utilities.dateparse import parse_date
|
|
10
10
|
from hdx.utilities.downloader import Download
|
|
11
11
|
from hdx.utilities.path import get_temp_dir
|
{hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/test_wfp_exchangerates.py
RENAMED
|
@@ -2,8 +2,8 @@ from os.path import join
|
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
|
-
from hdx.location import get_int_timestamp
|
|
6
5
|
from hdx.location.currency import Currency
|
|
6
|
+
from hdx.location.int_timestamp import get_int_timestamp
|
|
7
7
|
from hdx.location.wfp_api import WFPAPI
|
|
8
8
|
from hdx.location.wfp_exchangerates import WFPExchangeRates
|
|
9
9
|
from hdx.utilities.dateparse import parse_date
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
|
|
3
|
-
from ._version import version as __version__ # noqa: F401
|
|
4
|
-
from hdx.utilities.dateparse import get_timestamp_from_datetime
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def get_int_timestamp(date: datetime) -> int:
|
|
8
|
-
"""
|
|
9
|
-
Get integer timestamp from datetime object
|
|
10
|
-
|
|
11
|
-
Args:
|
|
12
|
-
date (datetime): datetime object
|
|
13
|
-
|
|
14
|
-
Returns:
|
|
15
|
-
int: Integer timestamp
|
|
16
|
-
"""
|
|
17
|
-
return int(round(get_timestamp_from_datetime(date)))
|
|
File without changes
|
{hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/.github/workflows/run-python-tests.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/secondary_historic_rates.csv
RENAMED
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_List_1.json
RENAMED
|
File without changes
|
{hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_List_2.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hdx_python_country-3.9.0 → hdx_python_country-3.9.1}/tests/hdx/location/Countries_UZB_Deleted.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|