Skip to content

Commit

Permalink
Add show method for wetterdienst instance
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Jun 23, 2021
1 parent 7446373 commit 5945e64
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -9,6 +9,7 @@ Development
- Export: Use InfluxDBClient instead of DataFrameClient and improve connection handling with InfluxDB 1.x
- Export: Add support for InfluxDB 2.x
- Fix InfluxDB export by skipping empty fields
- Add show() method with basic information on the wetterdienst instance

0.19.0 (14.05.2021)
*******************
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/test_cli.py
Expand Up @@ -54,8 +54,8 @@ def test_cli_help():

assert "Options:\n --help Show this message and exit."
assert (
"Commands:\n about\n explorer\n radar\n restapi\n stations\n values\n"
in result.output
"Commands:\n about\n explorer\n radar\n "
"restapi\n show\n stations\n values\n" in result.output
)


Expand Down
41 changes: 39 additions & 2 deletions wetterdienst/__init__.py
@@ -1,17 +1,23 @@
# """Wetterdienst - Open weather data for humans"""
# -*- coding: utf-8 -*-
# Copyright (c) 2018-2021, earthobservations developers.
# Distributed under the MIT License. See LICENSE for more info.
"""Wetterdienst - Open weather data for humans"""
__appname__ = "wetterdienst"

from wetterdienst.api import Wetterdienst # rather use this as entry point
from pathlib import Path

import tomlkit

from wetterdienst.api import Wetterdienst
from wetterdienst.metadata.kind import Kind
from wetterdienst.metadata.period import Period
from wetterdienst.metadata.provider import Provider
from wetterdienst.metadata.resolution import Resolution

# Single-sourcing the package version
# https://cjolowicz.github.io/posts/hypermodern-python-06-ci-cd/
from wetterdienst.util.cache import cache_dir

try:
from importlib.metadata import PackageNotFoundError, version # noqa
except ImportError: # pragma: no cover
Expand All @@ -21,3 +27,34 @@
__version__ = version(__name__)
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"


def show() -> None:
here = Path(__name__).parent

with Path(here.parent / "pyproject.toml").open() as f:
pyproject_dict = tomlkit.parse(f.read())["tool"]["poetry"]

wd_info = {
"version": pyproject_dict["version"],
"authors": ", ".join(pyproject_dict["authors"]),
"documentation": pyproject_dict["homepage"],
"repository": pyproject_dict["homepage"],
"cache_dir": cache_dir,
}

text = (
"Wetterdienst - Open weather data for humans\n"
"-------------------------------------------"
)

for key, value in wd_info.items():
text += f"\n{key}:\t {value}"

print(text)

return


if __name__ == "__main__":
show()
9 changes: 9 additions & 0 deletions wetterdienst/ui/cli.py
Expand Up @@ -372,6 +372,15 @@ def explorer(listen: str, reload: bool, debug: bool):
return


@cli.command("show")
def show():
from wetterdienst import show

show()

return


@cli.group()
def about():
pass
Expand Down

0 comments on commit 5945e64

Please sign in to comment.