Skip to content

Commit

Permalink
Merge branch 'switch-to-pyproject-toml' of github.com:adybbroe/pyorbi…
Browse files Browse the repository at this point in the history
…tal into switch-to-pyproject-toml
  • Loading branch information
Adam.Dybbroe committed Nov 21, 2024
2 parents ac018a0 + d50ddd9 commit 71b876c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 36 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: pyorbital/tests/SGP4-VER.TLE
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
Expand Down
6 changes: 1 addition & 5 deletions pyorbital/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import numpy as np

from pyorbital import version
from pyorbital.version import __version__ # noqa


def dt2np(utc_time):
Expand All @@ -28,7 +28,3 @@ def dt2np(utc_time):
return np.datetime64(utc_time)
except ValueError:
return utc_time.astype("datetime64[ns]")

def get_version():
"""Return the Pyorbital version tag."""
return version.__version__
26 changes: 12 additions & 14 deletions pyorbital/tests/test_tlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,18 @@ def test_check_is_platform_supported_unknown(caplog):
assert expected3 in logoutput_lines[2]


@patch("pyorbital.get_version",
return_value="1.9.1+1.some-future.dirty")
def test_get_config_path_ppp_config_set_but_not_pyorbital_future(mock, caplog, monkeypatch):
"""Test getting the config path."""
monkeypatch.setenv("SATPY_CONFIG_PATH", "/path/to/satpy/etc")
monkeypatch.setenv("PPP_CONFIG_DIR", "/path/to/old/mpop/config/dir")

with caplog.at_level(logging.WARNING):
res = _get_config_path()

log_output = ("The use of PPP_CONFIG_DIR is no longer supported! " +
"Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
assert log_output in caplog.text
assert res == PKG_CONFIG_DIR
#def test_get_config_path_ppp_config_set_but_not_pyorbital_future(mock, caplog, monkeypatch):
# """Test getting the config path."""
# monkeypatch.setenv("SATPY_CONFIG_PATH", "/path/to/satpy/etc")
# monkeypatch.setenv("PPP_CONFIG_DIR", "/path/to/old/mpop/config/dir")
#
# with caplog.at_level(logging.WARNING):
# res = _get_config_path()
#
# log_output = ("The use of PPP_CONFIG_DIR is no longer supported! " +
# "Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
# assert log_output in caplog.text
# assert res == PKG_CONFIG_DIR


def test_get_config_path_ppp_config_set_but_not_pyorbital_is_deprecated(caplog, monkeypatch):
Expand Down
27 changes: 10 additions & 17 deletions pyorbital/tlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,19 @@ class TleDownloadTimeoutError(Exception):
"""TLE download timeout exception."""


def _check_support_limit_ppp_config_dir():
"""Check the version where PPP_CONFIG_DIR will no longer be supported."""
from pyorbital import get_version
return get_version() >= "1.9"


def _get_config_path():
"""Get the config path for Pyorbital."""
if "PPP_CONFIG_DIR" in os.environ and "PYORBITAL_CONFIG_PATH" not in os.environ:
if _check_support_limit_ppp_config_dir():
LOGGER.warning(
"The use of PPP_CONFIG_DIR is no longer supported!" +
" Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
LOGGER.debug("Using the package default for configuration: %s", PKG_CONFIG_DIR)
return PKG_CONFIG_DIR
else:
LOGGER.warning(
"The use of PPP_CONFIG_DIR is deprecated and will be removed in version 1.9!" +
" Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
pyorbital_config_path = os.getenv("PPP_CONFIG_DIR", PKG_CONFIG_DIR)
# XXX: Swap when pyorbital 1.9 is released
#LOGGER.warning(
# "The use of PPP_CONFIG_DIR is no longer supported!" +
# " Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
#LOGGER.debug("Using the package default for configuration: %s", PKG_CONFIG_DIR)
#return PKG_CONFIG_DIR
LOGGER.warning(
"The use of PPP_CONFIG_DIR is deprecated and will be removed in version 1.9!" +
" Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
pyorbital_config_path = os.getenv("PPP_CONFIG_DIR", PKG_CONFIG_DIR)
else:
pyorbital_config_path = os.getenv("PYORBITAL_CONFIG_PATH", PKG_CONFIG_DIR)

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers = [
]

[project.scripts]
"fetch_tles.py" = "pyorbital.fetch_tles:run"
fetch_tles = "pyorbital.fetch_tles:run"

[project.urls]
Expand Down Expand Up @@ -64,6 +65,7 @@ line_length = 120

[tool.ruff]
line-length = 120
extend-exclude = ["pyorbital/tests/SGP4-VER.TLE"]

[tool.ruff.lint]
# See https://docs.astral.sh/ruff/rules/
Expand Down

0 comments on commit 71b876c

Please sign in to comment.