hdx-python-country 3.8.9__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.
Files changed (51) hide show
  1. hdx_python_country-3.8.9/.config/pre-commit-config.yaml → hdx_python_country-3.9.1/.pre-commit-config.yaml +1 -2
  2. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/CONTRIBUTING.md +5 -12
  3. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/PKG-INFO +1 -1
  4. hdx_python_country-3.9.1/hatch.toml +37 -0
  5. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/pyproject.toml +0 -48
  6. {hdx_python_country-3.8.9/.config → hdx_python_country-3.9.1}/pytest.ini +1 -1
  7. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/requirements.txt +1 -1
  8. hdx_python_country-3.9.1/src/hdx/location/__init__.py +1 -0
  9. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/_version.py +2 -2
  10. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/currency.py +3 -3
  11. hdx_python_country-3.9.1/src/hdx/location/int_timestamp.py +22 -0
  12. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/wfp_exchangerates.py +5 -4
  13. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/hdx/location/test_currency.py +1 -1
  14. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/hdx/location/test_wfp_exchangerates.py +1 -1
  15. hdx_python_country-3.8.9/src/hdx/location/__init__.py +0 -17
  16. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/.github/workflows/publish.yaml +0 -0
  17. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/.github/workflows/run-python-tests.yaml +0 -0
  18. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/.gitignore +0 -0
  19. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/LICENSE +0 -0
  20. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/README.md +0 -0
  21. {hdx_python_country-3.8.9/.config → hdx_python_country-3.9.1}/coveragerc +0 -0
  22. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/documentation/.readthedocs.yaml +0 -0
  23. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/documentation/index.md +0 -0
  24. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/documentation/mkdocs.yaml +0 -0
  25. {hdx_python_country-3.8.9/.config → hdx_python_country-3.9.1}/ruff.toml +0 -0
  26. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv +0 -0
  27. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/adminlevel.py +0 -0
  28. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/country.py +0 -0
  29. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/src/hdx/location/wfp_api.py +0 -0
  30. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/adminlevel.yaml +0 -0
  31. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/adminlevelparent.yaml +0 -0
  32. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/download-global-pcode-lengths.csv +0 -0
  33. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/download-global-pcodes-adm-1-2.csv +0 -0
  34. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/secondary_historic_rates.csv +0 -0
  35. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/secondary_rates.json +0 -0
  36. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_List_1.json +0 -0
  37. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_List_2.json +0 -0
  38. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_1.json +0 -0
  39. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_10.json +0 -0
  40. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_2.json +0 -0
  41. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_3.json +0 -0
  42. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_4.json +0 -0
  43. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_5.json +0 -0
  44. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_6.json +0 -0
  45. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_7.json +0 -0
  46. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_8.json +0 -0
  47. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/fixtures/wfp/Currency_UsdIndirectQuotation_9.json +0 -0
  48. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/hdx/location/Countries_UZB_Deleted.csv +0 -0
  49. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/hdx/location/__init__.py +0 -0
  50. {hdx_python_country-3.8.9 → hdx_python_country-3.9.1}/tests/hdx/location/test_adminlevel.py +0 -0
  51. {hdx_python_country-3.8.9 → 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: [--config, .config/ruff.toml, --fix]
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.11. We recommend using a virtual
5
+ Development is currently done using Python 3.12. We recommend using a virtual
6
6
  environment such as ``venv``:
7
7
 
8
- python3.11 -m venv venv
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 --config=.config/pre-commit-config.yaml
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 -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc
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 --config=.config/pre-commit-config.yaml
53
+ pre-commit run pip-compile --all-files
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hdx-python-country
3
- Version: 3.8.9
3
+ Version: 3.9.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
@@ -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:.}",]
@@ -1,4 +1,4 @@
1
1
  [pytest]
2
- pythonpath = ../src
2
+ pythonpath = src
3
3
  addopts = "--color=yes"
4
4
  log_cli = 1
@@ -28,7 +28,7 @@ click==8.1.8
28
28
  # typer
29
29
  colorama==0.4.6
30
30
  # via mkdocs-material
31
- coverage==7.7.0
31
+ coverage==7.7.1
32
32
  # via pytest-cov
33
33
  distlib==0.3.9
34
34
  # via virtualenv
@@ -0,0 +1 @@
1
+ from ._version import version as __version__ # noqa: F401
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '3.8.9'
21
- __version_tuple__ = version_tuple = (3, 8, 9)
20
+ __version__ = version = '3.9.1'
21
+ __version_tuple__ = version_tuple = (3, 9, 1)
@@ -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.warning(f"Using secondary current rate for {currency}!")
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.warning(
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
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  from typing import Dict, List
3
3
 
4
- from . import get_int_timestamp
4
+ from .int_timestamp import get_int_timestamp
5
5
  from .wfp_api import WFPAPI
6
6
  from hdx.utilities.dateparse import parse_date
7
7
  from hdx.utilities.typehint import ListTuple
@@ -27,9 +27,10 @@ class WFPExchangeRates:
27
27
  """
28
28
  currencies = []
29
29
  for currency in self.wfp_api.get_items("Currency/List"):
30
- currencies.append(
31
- {"code": currency["name"], "name": currency["extendedName"]}
32
- )
30
+ currency_name = currency["extendedName"]
31
+ if currency_name:
32
+ currency_name = currency_name.strip()
33
+ currencies.append({"code": currency["name"], "name": currency_name})
33
34
  return currencies
34
35
 
35
36
  def get_currencies(self) -> List[str]:
@@ -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
@@ -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)))