simple-dwd-weatherforecast 2.1.5__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.
- simple_dwd_weatherforecast/dwdforecast.py +31 -32
- {simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/METADATA +2 -1
- {simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/RECORD +7 -7
- tests/test_parsekml.py +7 -10
- {simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/LICENCE +0 -0
- {simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/WHEEL +0 -0
- {simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/top_level.txt +0 -0
@@ -954,16 +954,13 @@ class Weather:
|
|
954
954
|
print(f"Error in download_latest_kml: {type(error)} args: {error.args}")
|
955
955
|
|
956
956
|
def get_chunks(self, url):
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
yield from r.iter_bytes(chunk_size=171072)
|
965
|
-
|
966
|
-
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)
|
967
964
|
|
968
965
|
def download_large_kml(self, stationid):
|
969
966
|
placemark = b""
|
@@ -977,40 +974,42 @@ class Weather:
|
|
977
974
|
if r.status_code == 304:
|
978
975
|
return
|
979
976
|
|
980
|
-
for file_name, file_size, unzipped_chunks in self.get_chunks(url):
|
981
|
-
|
982
|
-
|
983
|
-
first_chunk = None
|
977
|
+
for file_name, file_size, unzipped_chunks in stream_unzip(self.get_chunks(url)):
|
978
|
+
header = b""
|
979
|
+
placemark = b""
|
984
980
|
|
985
|
-
|
986
|
-
|
981
|
+
found_header = False
|
982
|
+
found_stationid = False
|
987
983
|
stop = False
|
988
984
|
# unzipped_chunks must be iterated to completion or UnfinishedIterationError will be raised
|
989
985
|
for chunk in unzipped_chunks:
|
990
986
|
if stop:
|
991
987
|
continue
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
if
|
999
|
-
|
1000
|
-
|
1001
|
-
|
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
|
1002
998
|
|
1003
999
|
if f"<kml:name>{stationid}</kml:name>".encode() in chunk:
|
1004
|
-
|
1005
|
-
|
1000
|
+
placemark = chunk
|
1001
|
+
found_stationid = True
|
1006
1002
|
|
1007
|
-
if not
|
1003
|
+
if not placemark:
|
1008
1004
|
raise BufferError("Station not found")
|
1009
|
-
if
|
1005
|
+
if header and placemark:
|
1010
1006
|
start = placemark.find(b"<kml:Placemark>\n")
|
1011
|
-
|
1007
|
+
if start == -1:
|
1008
|
+
raise BufferError(
|
1009
|
+
"Error during stream parsing of station {}".format(stationid)
|
1010
|
+
)
|
1012
1011
|
result = (
|
1013
|
-
|
1012
|
+
header[: header.find(b"<kml:Placemark>")]
|
1014
1013
|
+ placemark[
|
1015
1014
|
start : placemark.find(b"</kml:Placemark>\n", start) + 17
|
1016
1015
|
]
|
{simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: simple_dwd_weatherforecast
|
3
|
-
Version: 2.1.
|
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
|
|
{simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/RECORD
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
simple_dwd_weatherforecast/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
simple_dwd_weatherforecast/dwdforecast.py,sha256=
|
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
|
@@ -26,7 +26,7 @@ tests/test_is_in_timerange.py,sha256=3y88L3N73NxSTJ-_edx6OCnxHWKJWWFma98gjZvJDGg
|
|
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=
|
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.
|
39
|
-
simple_dwd_weatherforecast-2.1.
|
40
|
-
simple_dwd_weatherforecast-2.1.
|
41
|
-
simple_dwd_weatherforecast-2.1.
|
42
|
-
simple_dwd_weatherforecast-2.1.
|
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,,
|
tests/test_parsekml.py
CHANGED
@@ -23,27 +23,24 @@ class KMLParseTestCase(unittest.TestCase):
|
|
23
23
|
)
|
24
24
|
|
25
25
|
|
26
|
-
def helper():
|
27
|
-
result = []
|
28
|
-
read_size = 131072
|
26
|
+
def helper(file):
|
29
27
|
# Iterable that yields the bytes of a zip file
|
30
|
-
with open(
|
31
|
-
content = kml.read(
|
28
|
+
with open(file, "rb") as kml:
|
29
|
+
content = kml.read()
|
32
30
|
while len(content) > 0:
|
33
|
-
|
34
|
-
content = kml.read(
|
35
|
-
return zip([0], [0], [result])
|
31
|
+
yield content
|
32
|
+
content = kml.read()
|
36
33
|
|
37
34
|
|
38
35
|
class KMLParseFullTestCase(unittest.TestCase):
|
39
|
-
FILE_NAME = "development/MOSMIX_L_2023100809_stripped.
|
36
|
+
FILE_NAME = "development/MOSMIX_L_2023100809_stripped.kmz"
|
40
37
|
|
41
38
|
def setUp(self):
|
42
39
|
self.dwd_weather = dwdforecast.Weather("L511")
|
43
40
|
|
44
41
|
@patch(
|
45
42
|
"simple_dwd_weatherforecast.dwdforecast.Weather.get_chunks",
|
46
|
-
return_value=helper(),
|
43
|
+
return_value=helper(FILE_NAME),
|
47
44
|
)
|
48
45
|
def test_parse_kml(self, _):
|
49
46
|
self.dwd_weather.download_latest_kml(
|
{simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/LICENCE
RENAMED
File without changes
|
{simple_dwd_weatherforecast-2.1.5.dist-info → simple_dwd_weatherforecast-2.1.6.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|