simple-dwd-weatherforecast 2.1.4__py3-none-any.whl → 2.1.6__py3-none-any.whl

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.
@@ -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
 
@@ -1,18 +1,18 @@
1
1
  simple_dwd_weatherforecast/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- simple_dwd_weatherforecast/dwdforecast.py,sha256=pMJpl7yHV_xFFdpYlpU8wYZOv4_ZBkx-JAkrXMvYOI4,38616
2
+ simple_dwd_weatherforecast/dwdforecast.py,sha256=wYg7XC9_5rb-ITdjoT-bLaBc_AGqii8d6eNEfdbfXtY,38863
3
3
  simple_dwd_weatherforecast/dwdmap.py,sha256=cPCcL1u5qeIEDLBcL0qOH0-7dPIi3mge4-PUqfZlRQc,6737
4
4
  simple_dwd_weatherforecast/stations.json,sha256=1u8qc2CT_rVy49SAlOicGixzHln6Y0FXevuFAz2maBw,838948
5
5
  simple_dwd_weatherforecast/uv_stations.json,sha256=ADenYo-aR6qbf0UFkfYr72kkFzL9HyUKe4VQ23POGF8,2292
6
6
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- tests/dummy_data.py,sha256=sF8pXxq8innSpRc4lW0XxGcr34dESSAoBdAf2F2D4AI,63395
8
- tests/dummy_data_full.py,sha256=IwYoeqVX8cpfn_gE-7arXaWV9btRm_HHqka_LfKqW-E,64053
7
+ tests/dummy_data.py,sha256=qapeQxjh8kURf5b-9h4gUdJaqQJQDVdqfMtS2g5JReY,103406
8
+ tests/dummy_data_full.py,sha256=3HRGAQBq4xPYs4jLzoLV_UAe1CXFzOsVBOouDL_5RHw,104062
9
9
  tests/dummy_uv.py,sha256=TM1TwvNq_ea4WgIJyYsNAEXZJTx1dXH1ZVrW_LfLBLg,4548
10
10
  tests/test_get_daily_avg.py,sha256=MNd7u9Y7_E6SIyxg59EKfdKx4QJ7R_WT5wvRgm7Gzks,2315
11
11
  tests/test_get_daily_condition.py,sha256=9Qrhv14-vLnLz0N0FWG7Mv6_iEbNPqrHDDWWNQNydU0,2298
12
12
  tests/test_get_daily_max.py,sha256=schjGJDflg1YEQSdfRndw2NT4AvrVheSDveyVZrFySM,2220
13
13
  tests/test_get_daily_min.py,sha256=GzqlOfLdwLqGLYVeAJ0fbK1JRq-_fT7z6Gea74lSY7E,2224
14
14
  tests/test_get_daily_sum.py,sha256=UEntbPwGSleHocu0587WnuC5ijptQtzVNreR1d6yoM0,2221
15
- tests/test_get_day_values.py,sha256=KOMkp_bh_nqZIufP8F3PNmF3WqXnPLOn6LKHrSi3SMA,29310
15
+ tests/test_get_day_values.py,sha256=hDphH7fekfcWX7slJUF1QiH3B7te23nHiS5-Fro3HY4,31013
16
16
  tests/test_get_forecast_condition.py,sha256=YVapxXH5Svq5P7XvWn48n19hriQ1-7CSezuGc6DswJQ,2866
17
17
  tests/test_get_forecast_data.py,sha256=E1pIsgcWfQLgiVBMJ4URao3rBJgXebDWcPlV6FYZF-U,3394
18
18
  tests/test_get_station_name.py,sha256=S18TZCUrLSRUgAz7sJ66igC0X-9JX_7O3Yh9Z6-QHnQ,423
@@ -21,12 +21,12 @@ tests/test_get_timeframe_condition.py,sha256=9ED_Uyx6v4Gq6qQ5SQyWtS_fOkbbhExKzfG
21
21
  tests/test_get_timeframe_max.py,sha256=gas73o1Ferkk87M4Y3k4LZ-fXKehI2ulsxcQfIviDTs,2407
22
22
  tests/test_get_timeframe_min.py,sha256=WnFO36U_E-55TW7jR598lyLS4u-TOtXmufadJF7IWQs,2407
23
23
  tests/test_get_timeframe_sum.py,sha256=hjHY9fvJUqi4o8AdFLPSDwi8GpXtjzLqsRzVMoUVjn4,2424
24
- tests/test_get_timeframe_values.py,sha256=z8ozpWlyilw8-zjbk2gDExhTobNbgmcVTbZ6ZHjxAW4,6891
24
+ tests/test_get_timeframe_values.py,sha256=D9NJ98sZykLKAW1eZgLFuy0FMb4f_jUCtr4clzg65ms,7231
25
25
  tests/test_is_in_timerange.py,sha256=3y88L3N73NxSTJ-_edx6OCnxHWKJWWFma98gjZvJDGg,1338
26
26
  tests/test_is_valid_timeframe.py,sha256=mXjeu3lUyixiBUEljirTf6qDM_FZFQGWa-Rk0NBMUDU,891
27
27
  tests/test_location_tools.py,sha256=wto_XzVnARJQ-Qc83YAn0ahfMBSaOHpfzqAeKRDsNm8,1208
28
28
  tests/test_map.py,sha256=uKxNjMXLFT3pczZKLqkfPK5xaVfmql-r5L9VPgCbS3Q,5671
29
- tests/test_parsekml.py,sha256=mpje7FoMIz566BLW-Fr_69cxLyS7w4qvrSOIlxVYoUU,1625
29
+ tests/test_parsekml.py,sha256=aG98x3B409CqxKBIq50yf3_LxPROnI4CAhdKfp350uQ,1495
30
30
  tests/test_region.py,sha256=ReUB9Cy9roBemkpEkTjZZav-Mu3Ha7ADOAfa9J-gi80,877
31
31
  tests/test_reported_weather.py,sha256=ULg4ogZRxus01p2rdxiSFL75AisqtcvnLDOc7uJMBH0,767
32
32
  tests/test_station.py,sha256=Zjx-q0yxKVxVI_L1yB_bqY5pjZPoa1L94uC8Gx6shdY,1026
@@ -35,8 +35,8 @@ tests/test_update.py,sha256=AIzzHMxcjwQjeTB0l3YFgB7HkGDbuqiHofwy41mS0m4,7440
35
35
  tests/test_update_hourly.py,sha256=7Zl8ml3FTdqw3_Qwr_Tz-sWTzypvrBWmxeig2Vwp_ZQ,1781
36
36
  tests/test_uv_index.py,sha256=tr6wnOyHlXT1S3yp1oeHc4-Brmc-EMEdM4mtyrdpcHg,579
37
37
  tests/test_weather.py,sha256=ZyX4ldUoJpJp7YpiNQwU6Od-nYRay-3qcaDJdNq8fhY,780
38
- simple_dwd_weatherforecast-2.1.4.dist-info/LICENCE,sha256=27UG7gteqvSWuZlsbIq2_OAbh7VyifGGl-1zpuUoBcw,1072
39
- simple_dwd_weatherforecast-2.1.4.dist-info/METADATA,sha256=AEI5eiSQsYm-_W8md8MAiG9xcPrSdT6pFSULJ4Ux1xQ,12103
40
- simple_dwd_weatherforecast-2.1.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
41
- simple_dwd_weatherforecast-2.1.4.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
42
- simple_dwd_weatherforecast-2.1.4.dist-info/RECORD,,
38
+ simple_dwd_weatherforecast-2.1.6.dist-info/LICENCE,sha256=27UG7gteqvSWuZlsbIq2_OAbh7VyifGGl-1zpuUoBcw,1072
39
+ simple_dwd_weatherforecast-2.1.6.dist-info/METADATA,sha256=F6Wv_Y6m1wrEFJgHlnDzMR-sx3_oUVRb9B0ocsUKhyI,12215
40
+ simple_dwd_weatherforecast-2.1.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
41
+ simple_dwd_weatherforecast-2.1.6.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
42
+ simple_dwd_weatherforecast-2.1.6.dist-info/RECORD,,