From 60b37eb450dfe44acf8fe8657639119aecb34656 Mon Sep 17 00:00:00 2001 From: stephan192 Date: Sat, 26 Sep 2020 21:15:16 +0200 Subject: [PATCH] CHG: Divison criteria between current and expected warnings changed from time to urgency attribute --- CHANGELOG.md | 6 ++++++ README.md | 13 +++++++++---- dwdwfsapi/weatherwarnings.py | 21 ++++++++------------- setup.py | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cee14bf..aa92880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.3 (2020-09-26) +### Added +- Urgency attribute added to warning dictionary +### Changed +- Divison criteria between current and expected warnings changed from time to urgency attribute + ## 1.0.2 (2020-04-25) ### Added - Input validation diff --git a/README.md b/README.md index b2a511b..69ec878 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Python client to retrieve data provided by DWD via their geoserver WFS API The DWD (Deutscher Wetterdienst) publishes various weather information for Germany. -The data is published via their [Geoserver](https://maps.dwd.de). For a more information have a look [here](https://www.dwd.de/DE/leistungen/geowebservice/geowebservice.html) and [here](https://maps.dwd.de/geoserver/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities). +The data is published via their [Geoserver](https://maps.dwd.de). For a more information have a look [here](https://www.dwd.de/DE/leistungen/geodienste/geodienste.html) and [here](https://maps.dwd.de/geoserver/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities). ## Install ``` @@ -100,7 +100,7 @@ Last update: 2020-04-18 17:57:29.274000+00:00 Range: 0 (=no warning) to 4 (=extreme weather) - **`current_warnings : list of dicts`** - Dictionary containing all currently active warnings + Dictionary containing all currently active warnings ("Wetterwarnungen", urgency="immediate") See section warning dictionary for more details @@ -110,7 +110,7 @@ Last update: 2020-04-18 17:57:29.274000+00:00 Range: 0 (=no warning) to 4 (=extreme weather) - **`expected_warnings : list of dicts`** - Dictionary containung all expected warnings + Dictionary containing all expected warnings ("Vorabinformationen", urgency="future") See section warning dictionary for more details expected_warnings : dict @@ -127,6 +127,8 @@ Last update: 2020-04-18 17:57:29.274000+00:00 - **`event_code: int`** Integer representation of the warning event + + For more details have a look [here](https://www.dwd.de/DE/leistungen/opendata/help/warnungen/gesamtueberblickII.pdf?__blob=publicationFile&v=3) - **`headline : str`** The official warning headline @@ -137,6 +139,9 @@ Last update: 2020-04-18 17:57:29.274000+00:00 - **`instruction : str`** Instructions and safety notices +- **`urgency : str`** + Warning urgency (either "immediate" or "future") + - **`level : int`** Warning level @@ -145,7 +150,7 @@ Last update: 2020-04-18 17:57:29.274000+00:00 - **`parameters : dict`** Dictionary containing warning specific parameters - For more details have a look [here](https://www.dwd.de/DE/leistungen/gds/help/warnungen/cap_dwd_profile_en_pdf.pdf) + For more details have a look [here](https://www.dwd.de/DE/leistungen/opendata/help/warnungen/cap_dwd_profile_de_pdf_1_11.pdf?__blob=publicationFile&v=3) - **`color : str`** Warning color formatted #rrggbb diff --git a/dwdwfsapi/weatherwarnings.py b/dwdwfsapi/weatherwarnings.py index 35bf6ca..8b4f6c5 100644 --- a/dwdwfsapi/weatherwarnings.py +++ b/dwdwfsapi/weatherwarnings.py @@ -32,6 +32,7 @@ def convert_warning_data(data_in): "headline": None, "description": None, "instruction": None, + "urgency": "immediate", "level": 0, "parameters": None, "color": "#000000", @@ -62,7 +63,10 @@ def convert_warning_data(data_in): if "instruction" in data_in: data_out["instruction"] = data_in["instruction"] if "urgency" in data_in: - data_out["urgency"] = data_in["urgency"] + if data_in["urgency"].lower() == "future": + data_out["urgency"] = "future" + else: + data_out["urgency"] = "immediate" if "severity" in data_in: try: if data_in["severity"].lower() in weather_severity_mapping: @@ -128,6 +132,8 @@ class DwdWeatherWarningsAPI: a details warning description instruction : str instructions and safety notices + urgency: str + warning urgency (either "immediate" or "future") level : int warning level (0 - 4) parameters : dict @@ -285,17 +291,7 @@ def __parse_result(self, json_obj): for feature in json_obj["features"]: warning = convert_warning_data(feature["properties"]) - current_time = datetime.datetime.now(datetime.timezone.utc) - # pylint: disable=bad-continuation - if ( - warning["end_time"] is not None - and current_time > warning["end_time"] - ): - continue - - if ( - warning["urgency"] == "Immediate" - ): + if warning["urgency"] == "immediate": current_warnings.append(warning) current_maxlevel = max( warning["level"], current_maxlevel @@ -305,7 +301,6 @@ def __parse_result(self, json_obj): expected_maxlevel = max( warning["level"], expected_maxlevel ) - # pylint: enable=bad-continuation self.current_warning_level = current_maxlevel self.current_warnings = current_warnings diff --git a/setup.py b/setup.py index bc5f197..1654fc5 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ EMAIL = "stephan192@outlook.com" AUTHOR = "stephan192" REQUIRES_PYTHON = ">=3.6" -VERSION = "1.0.2" +VERSION = "1.0.3" # Define required packages REQUIRES = ["requests>=2.23.0,<3", "ciso8601>=2.1.3,<3", "urllib3>=1.25.8,<2"]