simple-dwd-weatherforecast 2.1.3__tar.gz → 2.1.5__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 (49) hide show
  1. {simple_dwd_weatherforecast-2.1.3/simple_dwd_weatherforecast.egg-info → simple_dwd_weatherforecast-2.1.5}/PKG-INFO +2 -1
  2. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/README.md +1 -0
  3. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/setup.py +1 -1
  4. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast/dwdforecast.py +22 -7
  5. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5/simple_dwd_weatherforecast.egg-info}/PKG-INFO +2 -1
  6. simple_dwd_weatherforecast-2.1.5/tests/dummy_data.py +4695 -0
  7. simple_dwd_weatherforecast-2.1.5/tests/dummy_data_full.py +4695 -0
  8. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_day_values.py +110 -56
  9. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_timeframe_values.py +11 -0
  10. simple_dwd_weatherforecast-2.1.3/tests/dummy_data.py +0 -1
  11. simple_dwd_weatherforecast-2.1.3/tests/dummy_data_full.py +0 -1
  12. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/LICENCE +0 -0
  13. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/setup.cfg +0 -0
  14. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast/__init__.py +0 -0
  15. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast/dwdmap.py +0 -0
  16. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast/stations.json +0 -0
  17. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast/uv_stations.json +0 -0
  18. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast.egg-info/SOURCES.txt +0 -0
  19. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast.egg-info/dependency_links.txt +0 -0
  20. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast.egg-info/requires.txt +0 -0
  21. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/simple_dwd_weatherforecast.egg-info/top_level.txt +0 -0
  22. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/__init__.py +0 -0
  23. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/dummy_uv.py +0 -0
  24. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_daily_avg.py +0 -0
  25. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_daily_condition.py +0 -0
  26. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_daily_max.py +0 -0
  27. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_daily_min.py +0 -0
  28. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_daily_sum.py +0 -0
  29. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_forecast_condition.py +0 -0
  30. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_forecast_data.py +0 -0
  31. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_station_name.py +0 -0
  32. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_timeframe_avg.py +0 -0
  33. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_timeframe_condition.py +0 -0
  34. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_timeframe_max.py +0 -0
  35. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_timeframe_min.py +0 -0
  36. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_get_timeframe_sum.py +0 -0
  37. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_is_in_timerange.py +0 -0
  38. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_is_valid_timeframe.py +0 -0
  39. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_location_tools.py +0 -0
  40. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_map.py +0 -0
  41. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_parsekml.py +0 -0
  42. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_region.py +0 -0
  43. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_reported_weather.py +0 -0
  44. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_station.py +0 -0
  45. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_stationsfile.py +0 -0
  46. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_update.py +0 -0
  47. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_update_hourly.py +0 -0
  48. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_uv_index.py +0 -0
  49. {simple_dwd_weatherforecast-2.1.3 → simple_dwd_weatherforecast-2.1.5}/tests/test_weather.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 2.1.3
3
+ Version: 2.1.5
4
4
  Summary: A simple tool to retrieve a weather forecast from DWD OpenData
5
5
  Home-page: https://github.com/FL550/simple_dwd_weatherforecast.git
6
6
  Author: Max Fermor
@@ -110,6 +110,7 @@ class WeatherDataType(Enum):
110
110
  SUN_IRRADIANCE = "Rad1h" # Unit: W/m2
111
111
  FOG_PROBABILITY = "wwM" # Unit: % (0..100)
112
112
  HUMIDITY = "humidity" # Unit: %
113
+ EVAPORATION = ("PEvap", "evaporation") # In the last 24h Unit: kg/m2
113
114
 
114
115
  class Weather:
115
116
 
@@ -91,6 +91,7 @@ class WeatherDataType(Enum):
91
91
  SUN_IRRADIANCE = "Rad1h" # Unit: W/m2
92
92
  FOG_PROBABILITY = "wwM" # Unit: % (0..100)
93
93
  HUMIDITY = "humidity" # Unit: %
94
+ EVAPORATION = ("PEvap", "evaporation") # In the last 24h Unit: kg/m2
94
95
 
95
96
  class Weather:
96
97
 
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="simple_dwd_weatherforecast",
8
- version="2.1.3",
8
+ version="2.1.5",
9
9
  author="Max Fermor",
10
10
  description="A simple tool to retrieve a weather forecast from DWD OpenData",
11
11
  long_description=long_description,
@@ -111,6 +111,7 @@ class WeatherDataType(Enum):
111
111
  SUN_IRRADIANCE = ("Rad1h", "global_radiation_last_hour") # Unit: kJ/m^2
112
112
  FOG_PROBABILITY = ("wwM", "") # Unit: % (0..100)
113
113
  HUMIDITY = ("humidity", "relative_humidity") # Unit: %
114
+ EVAPORATION = ("PEvap", "evaporation") # Unit: kg/m2
114
115
 
115
116
 
116
117
  class Weather:
@@ -725,6 +726,7 @@ class Weather:
725
726
  WeatherDataType.SUN_DURATION,
726
727
  WeatherDataType.SUN_IRRADIANCE,
727
728
  WeatherDataType.FOG_PROBABILITY,
729
+ WeatherDataType.EVAPORATION,
728
730
  )
729
731
  ]
730
732
  values.extend(
@@ -951,21 +953,31 @@ class Weather:
951
953
  except Exception as error:
952
954
  print(f"Error in download_latest_kml: {type(error)} args: {error.args}")
953
955
 
954
- def get_chunks(self):
955
- def zipped_chunks():
956
+ def get_chunks(self, url):
957
+ def zipped_chunks(url):
956
958
  # Iterable that yields the bytes of a zip file
957
959
  with httpx.stream(
958
960
  "GET",
959
- "https://opendata.dwd.de/weather/local_forecasts/mos/MOSMIX_S/all_stations/kml/MOSMIX_S_LATEST_240.kmz",
961
+ url,
960
962
  ) as r:
961
- yield from r.iter_bytes(chunk_size=131072)
963
+ self.etags[url] = r.headers["etag"] # type: ignore
964
+ yield from r.iter_bytes(chunk_size=171072)
962
965
 
963
- return stream_unzip(zipped_chunks())
966
+ return stream_unzip(zipped_chunks(url))
964
967
 
965
968
  def download_large_kml(self, stationid):
966
969
  placemark = b""
970
+ url = "https://opendata.dwd.de/weather/local_forecasts/mos/MOSMIX_S/all_stations/kml/MOSMIX_S_LATEST_240.kmz"
971
+ # Check if content has updated
972
+ headers = {"If-None-Match": self.etags[url] if url in self.etags else ""} # type: ignore
973
+ r = httpx.head(
974
+ url,
975
+ headers=headers,
976
+ )
977
+ if r.status_code == 304:
978
+ return
967
979
 
968
- for file_name, file_size, unzipped_chunks in self.get_chunks():
980
+ for file_name, file_size, unzipped_chunks in self.get_chunks(url):
969
981
  chunk1 = b""
970
982
  chunk2 = b""
971
983
  first_chunk = None
@@ -988,9 +1000,12 @@ class Weather:
988
1000
  save_next_next = True
989
1001
  save_next = False
990
1002
 
991
- if stationid.encode() in chunk:
1003
+ if f"<kml:name>{stationid}</kml:name>".encode() in chunk:
992
1004
  chunk1 = chunk
993
1005
  save_next = True
1006
+
1007
+ if not chunk1:
1008
+ raise BufferError("Station not found")
994
1009
  if first_chunk:
995
1010
  start = placemark.find(b"<kml:Placemark>\n")
996
1011
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 2.1.3
3
+ Version: 2.1.5
4
4
  Summary: A simple tool to retrieve a weather forecast from DWD OpenData
5
5
  Home-page: https://github.com/FL550/simple_dwd_weatherforecast.git
6
6
  Author: Max Fermor
@@ -110,6 +110,7 @@ class WeatherDataType(Enum):
110
110
  SUN_IRRADIANCE = "Rad1h" # Unit: W/m2
111
111
  FOG_PROBABILITY = "wwM" # Unit: % (0..100)
112
112
  HUMIDITY = "humidity" # Unit: %
113
+ EVAPORATION = ("PEvap", "evaporation") # In the last 24h Unit: kg/m2
113
114
 
114
115
  class Weather:
115
116