simple-dwd-weatherforecast 2.1.4__tar.gz → 2.1.6__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.4/simple_dwd_weatherforecast.egg-info → simple_dwd_weatherforecast-2.1.6}/PKG-INFO +3 -1
  2. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/README.md +1 -0
  3. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/setup.py +10 -2
  4. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast/dwdforecast.py +37 -33
  5. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6/simple_dwd_weatherforecast.egg-info}/PKG-INFO +3 -1
  6. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast.egg-info/requires.txt +1 -0
  7. simple_dwd_weatherforecast-2.1.6/tests/dummy_data.py +4695 -0
  8. simple_dwd_weatherforecast-2.1.6/tests/dummy_data_full.py +4695 -0
  9. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_day_values.py +110 -56
  10. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_timeframe_values.py +11 -0
  11. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_parsekml.py +7 -10
  12. simple_dwd_weatherforecast-2.1.4/tests/dummy_data.py +0 -1
  13. simple_dwd_weatherforecast-2.1.4/tests/dummy_data_full.py +0 -1
  14. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/LICENCE +0 -0
  15. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/setup.cfg +0 -0
  16. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast/__init__.py +0 -0
  17. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast/dwdmap.py +0 -0
  18. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast/stations.json +0 -0
  19. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast/uv_stations.json +0 -0
  20. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast.egg-info/SOURCES.txt +0 -0
  21. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast.egg-info/dependency_links.txt +0 -0
  22. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/simple_dwd_weatherforecast.egg-info/top_level.txt +0 -0
  23. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/__init__.py +0 -0
  24. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/dummy_uv.py +0 -0
  25. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_daily_avg.py +0 -0
  26. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_daily_condition.py +0 -0
  27. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_daily_max.py +0 -0
  28. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_daily_min.py +0 -0
  29. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_daily_sum.py +0 -0
  30. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_forecast_condition.py +0 -0
  31. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_forecast_data.py +0 -0
  32. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_station_name.py +0 -0
  33. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_timeframe_avg.py +0 -0
  34. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_timeframe_condition.py +0 -0
  35. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_timeframe_max.py +0 -0
  36. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_timeframe_min.py +0 -0
  37. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_get_timeframe_sum.py +0 -0
  38. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_is_in_timerange.py +0 -0
  39. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_is_valid_timeframe.py +0 -0
  40. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_location_tools.py +0 -0
  41. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_map.py +0 -0
  42. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_region.py +0 -0
  43. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_reported_weather.py +0 -0
  44. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_station.py +0 -0
  45. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_stationsfile.py +0 -0
  46. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_update.py +0 -0
  47. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_update_hourly.py +0 -0
  48. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/tests/test_uv_index.py +0 -0
  49. {simple_dwd_weatherforecast-2.1.4 → simple_dwd_weatherforecast-2.1.6}/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.4
3
+ Version: 2.1.6
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
@@ -14,6 +14,7 @@ Requires-Dist: lxml
14
14
  Requires-Dist: requests
15
15
  Requires-Dist: Pillow
16
16
  Requires-Dist: arrow
17
+ Requires-Dist: stream-inflate==0.0.14
17
18
  Requires-Dist: stream-unzip
18
19
  Requires-Dist: httpx
19
20
 
@@ -110,6 +111,7 @@ class WeatherDataType(Enum):
110
111
  SUN_IRRADIANCE = "Rad1h" # Unit: W/m2
111
112
  FOG_PROBABILITY = "wwM" # Unit: % (0..100)
112
113
  HUMIDITY = "humidity" # Unit: %
114
+ EVAPORATION = ("PEvap", "evaporation") # In the last 24h Unit: kg/m2
113
115
 
114
116
  class Weather:
115
117
 
@@ -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.4",
8
+ version="2.1.6",
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,
@@ -20,5 +20,13 @@ setuptools.setup(
20
20
  "Operating System :: OS Independent",
21
21
  ],
22
22
  python_requires=">=3.6",
23
- install_requires=["lxml", "requests", "Pillow", "arrow", "stream-unzip", "httpx"],
23
+ install_requires=[
24
+ "lxml",
25
+ "requests",
26
+ "Pillow",
27
+ "arrow",
28
+ "stream-inflate==0.0.14",
29
+ "stream-unzip",
30
+ "httpx",
31
+ ],
24
32
  )
@@ -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(
@@ -952,16 +954,13 @@ class Weather:
952
954
  print(f"Error in download_latest_kml: {type(error)} args: {error.args}")
953
955
 
954
956
  def get_chunks(self, url):
955
- def zipped_chunks(url):
956
- # Iterable that yields the bytes of a zip file
957
- with httpx.stream(
958
- "GET",
959
- url,
960
- ) as r:
961
- self.etags[url] = r.headers["etag"] # type: ignore
962
- yield from r.iter_bytes(chunk_size=171072)
963
-
964
- return stream_unzip(zipped_chunks(url))
957
+ # Iterable that yields the bytes of a zip file
958
+ with httpx.stream(
959
+ "GET",
960
+ url,
961
+ ) as r:
962
+ self.etags[url] = r.headers["etag"] # type: ignore
963
+ yield from r.iter_bytes(chunk_size=65536)
965
964
 
966
965
  def download_large_kml(self, stationid):
967
966
  placemark = b""
@@ -975,37 +974,42 @@ class Weather:
975
974
  if r.status_code == 304:
976
975
  return
977
976
 
978
- for file_name, file_size, unzipped_chunks in self.get_chunks(url):
979
- chunk1 = b""
980
- chunk2 = b""
981
- first_chunk = None
977
+ for file_name, file_size, unzipped_chunks in stream_unzip(self.get_chunks(url)):
978
+ header = b""
979
+ placemark = b""
982
980
 
983
- save_next = False
984
- save_next_next = False
981
+ found_header = False
982
+ found_stationid = False
985
983
  stop = False
986
984
  # unzipped_chunks must be iterated to completion or UnfinishedIterationError will be raised
987
985
  for chunk in unzipped_chunks:
988
986
  if stop:
989
987
  continue
990
- if not first_chunk:
991
- first_chunk = chunk
992
- if save_next_next:
993
- placemark = chunk1 + chunk2 + chunk
994
- save_next_next = False
995
- stop = True
996
- if save_next:
997
- chunk2 = chunk
998
- save_next_next = True
999
- save_next = False
1000
-
1001
- if stationid.encode() in chunk:
1002
- chunk1 = chunk
1003
- save_next = True
1004
- if first_chunk:
1005
- start = placemark.find(b"<kml:Placemark>\n")
1006
988
 
989
+ if not found_header:
990
+ header += chunk
991
+ if "<kml:Placemark>".encode() in chunk:
992
+ found_header = True
993
+
994
+ if found_stationid:
995
+ placemark += chunk
996
+ if "</kml:Placemark>\n".encode() in chunk:
997
+ stop = True
998
+
999
+ if f"<kml:name>{stationid}</kml:name>".encode() in chunk:
1000
+ placemark = chunk
1001
+ found_stationid = True
1002
+
1003
+ if not placemark:
1004
+ raise BufferError("Station not found")
1005
+ if header and placemark:
1006
+ start = placemark.find(b"<kml:Placemark>\n")
1007
+ if start == -1:
1008
+ raise BufferError(
1009
+ "Error during stream parsing of station {}".format(stationid)
1010
+ )
1007
1011
  result = (
1008
- first_chunk[: first_chunk.find(b"<kml:Placemark>")]
1012
+ header[: header.find(b"<kml:Placemark>")]
1009
1013
  + placemark[
1010
1014
  start : placemark.find(b"</kml:Placemark>\n", start) + 17
1011
1015
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 2.1.4
3
+ Version: 2.1.6
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
@@ -14,6 +14,7 @@ Requires-Dist: lxml
14
14
  Requires-Dist: requests
15
15
  Requires-Dist: Pillow
16
16
  Requires-Dist: arrow
17
+ Requires-Dist: stream-inflate==0.0.14
17
18
  Requires-Dist: stream-unzip
18
19
  Requires-Dist: httpx
19
20
 
@@ -110,6 +111,7 @@ class WeatherDataType(Enum):
110
111
  SUN_IRRADIANCE = "Rad1h" # Unit: W/m2
111
112
  FOG_PROBABILITY = "wwM" # Unit: % (0..100)
112
113
  HUMIDITY = "humidity" # Unit: %
114
+ EVAPORATION = ("PEvap", "evaporation") # In the last 24h Unit: kg/m2
113
115
 
114
116
  class Weather:
115
117
 
@@ -2,5 +2,6 @@ lxml
2
2
  requests
3
3
  Pillow
4
4
  arrow
5
+ stream-inflate==0.0.14
5
6
  stream-unzip
6
7
  httpx