From 52ed0cdd6e3576503fc1232d28a2290f34430c2b Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Wed, 11 Oct 2023 22:49:59 +0200 Subject: [PATCH] refactor: Refer to docs for examples in docstrings --- yr_weather/__init__.py | 21 ++++----------------- yr_weather/radar.py | 42 +++--------------------------------------- 2 files changed, 7 insertions(+), 56 deletions(-) diff --git a/yr_weather/__init__.py b/yr_weather/__init__.py index ac6c479..2366a4a 100644 --- a/yr_weather/__init__.py +++ b/yr_weather/__init__.py @@ -1,21 +1,8 @@ -"""A Python module for interaction with the Yr API. +"""A Python module for interaction with the MET API. -To get started, initialize a Locationforecast client like so: - -.. code-block:: python - - import yr_weather - - headers = { - "User-Agent": "Your User-Agent" - } - - my_client = yr_weather.Locationforecast(headers=headers) - -For valid user agents, please see: -https://api.met.no/doc/TermsOfService - -Using ``my_client``, you can receive forecasts for specified locations, get the air temperature, and more. +yr_weather supports multiple MET API products. +Please visit the docs to learn more: +https://yr-weather.readthedocs.io/en/latest/ """ from .locationforecast import Locationforecast diff --git a/yr_weather/radar.py b/yr_weather/radar.py index 3cde0cc..37725a9 100644 --- a/yr_weather/radar.py +++ b/yr_weather/radar.py @@ -35,6 +35,9 @@ def get_radar( ) -> requests.Response: """Get a radar image (png) or animation (gif). + For examples of usage, please see the docs: + https://yr-weather.readthedocs.io/ + For more information about what arguments are valid, please see: https://api.met.no/weatherapi/radar/2.0/documentation @@ -53,45 +56,6 @@ def get_radar( ------- :class:`requests.Response` A Response class, enabling for further saving or managing of the data received from the open stream. - - Examples - -------- - - Example 1: Basic usage: - - .. code-block:: python - - import yr_weather - - radar = yr_weather.Radar() - - result = radar.get_radar("central_norway", "5level_reflectivity", "image") - - with open("image.png", "wb") as f: - for chunk in result: - f.write(chunk) - - Example 2. Getting a radar image from a few hours back: - - .. code-block:: python - - import yr_weather - from datetime import datetime - - radar = yr_weather.Radar() - - # Replace with your time - time_now = datetime(2023, 1, 20, 12, 00, 00) - time_str = time_now.isoformat(timespec="seconds") + "Z" - - result = radar.get_radar("central_norway", "5level_reflectivity", "image", time_str) - - if result.status_code != 404: - with open("image.png", "wb") as f: - for chunk in result: - f.write(chunk) - else: - print("Couldn't get this radar image/animation!") """ area_args = list(get_args(RadarArea)) type_args = list(get_args(RadarType))