simple-dwd-weatherforecast 2.1.11__tar.gz → 2.1.14__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 (48) hide show
  1. {simple_dwd_weatherforecast-2.1.11/simple_dwd_weatherforecast.egg-info → simple_dwd_weatherforecast-2.1.14}/PKG-INFO +17 -9
  2. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/README.md +5 -5
  3. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/setup.py +3 -3
  4. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast/dwdforecast.py +6 -2
  5. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast/dwdmap.py +28 -1
  6. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14/simple_dwd_weatherforecast.egg-info}/PKG-INFO +17 -9
  7. simple_dwd_weatherforecast-2.1.14/simple_dwd_weatherforecast.egg-info/requires.txt +7 -0
  8. simple_dwd_weatherforecast-2.1.11/simple_dwd_weatherforecast.egg-info/requires.txt +0 -7
  9. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/LICENCE +0 -0
  10. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/setup.cfg +0 -0
  11. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast/__init__.py +0 -0
  12. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast/stations.json +0 -0
  13. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast/uv_stations.json +0 -0
  14. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast.egg-info/SOURCES.txt +0 -0
  15. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast.egg-info/dependency_links.txt +0 -0
  16. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/simple_dwd_weatherforecast.egg-info/top_level.txt +0 -0
  17. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/__init__.py +0 -0
  18. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/dummy_data.py +0 -0
  19. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/dummy_data_full.py +0 -0
  20. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/dummy_uv.py +0 -0
  21. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_daily_avg.py +0 -0
  22. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_daily_condition.py +0 -0
  23. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_daily_max.py +0 -0
  24. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_daily_min.py +0 -0
  25. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_daily_sum.py +0 -0
  26. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_day_values.py +0 -0
  27. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_forecast_condition.py +0 -0
  28. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_forecast_data.py +0 -0
  29. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_station_name.py +0 -0
  30. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_timeframe_avg.py +0 -0
  31. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_timeframe_condition.py +0 -0
  32. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_timeframe_max.py +0 -0
  33. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_timeframe_min.py +0 -0
  34. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_timeframe_sum.py +0 -0
  35. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_get_timeframe_values.py +0 -0
  36. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_is_in_timerange.py +0 -0
  37. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_is_valid_timeframe.py +0 -0
  38. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_location_tools.py +0 -0
  39. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_map.py +0 -0
  40. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_parsekml.py +0 -0
  41. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_region.py +0 -0
  42. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_reported_weather.py +0 -0
  43. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_station.py +0 -0
  44. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_stationsfile.py +0 -0
  45. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_update.py +0 -0
  46. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_update_hourly.py +0 -0
  47. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_uv_index.py +0 -0
  48. {simple_dwd_weatherforecast-2.1.11 → simple_dwd_weatherforecast-2.1.14}/tests/test_weather.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 2.1.11
3
+ Version: 2.1.14
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,9 +14,17 @@ 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.40
18
- Requires-Dist: stream-unzip
17
+ Requires-Dist: stream-inflate==0.0.41
18
+ Requires-Dist: stream-unzip==0.0.98
19
19
  Requires-Dist: httpx
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
20
28
 
21
29
  # Simple DWD weather forecast
22
30
 
@@ -208,7 +216,7 @@ class MarkerShape(Enum):
208
216
  CIRCLE = "circle"
209
217
  SQUARE = "square"
210
218
  CROSS = "cross"
211
-
219
+
212
220
  class Marker(
213
221
  latitude: float,
214
222
  longitude: float,
@@ -218,11 +226,11 @@ class Marker(
218
226
  width: int = 0,
219
227
  )
220
228
 
221
- get_from_location(longitude, latitude, radius_km, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image with given radius from coordinates
229
+ get_from_location(longitude, latitude, radius_km, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image with given radius from coordinates
222
230
 
223
- get_germany(map_type: WeatherMapType, optional WeatherBackgroundMapType background_type, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image of whole germany
231
+ get_germany(map_type: WeatherMapType, optional WeatherBackgroundMapType background_type, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image of whole germany
224
232
 
225
- get_map(minx,miny,maxx,maxy, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image
233
+ get_map(minx,miny,maxx,maxy, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image
226
234
  ```
227
235
 
228
236
 
@@ -254,7 +262,7 @@ for image in enumerate(maploop._images):
254
262
 
255
263
  ```python
256
264
  ImageLoop(minx: float, miny: float, maxx: float, maxy: float, map_type: WeatherMapType, background_type: WeatherBackgroundMapType,
257
- steps: int = 6, image_width: int = 520,image_height: int = 580, markers: list[Marker] = []) -> ImageLoop
265
+ steps: int = 6, image_width: int = 520,image_height: int = 580, markers: list[Marker] = [], optional bool dark_mode) -> ImageLoop
258
266
 
259
267
  get_images() -> Iterable[ImageFile.ImageFile] # Returns the image loop
260
268
 
@@ -188,7 +188,7 @@ class MarkerShape(Enum):
188
188
  CIRCLE = "circle"
189
189
  SQUARE = "square"
190
190
  CROSS = "cross"
191
-
191
+
192
192
  class Marker(
193
193
  latitude: float,
194
194
  longitude: float,
@@ -198,11 +198,11 @@ class Marker(
198
198
  width: int = 0,
199
199
  )
200
200
 
201
- get_from_location(longitude, latitude, radius_km, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image with given radius from coordinates
201
+ get_from_location(longitude, latitude, radius_km, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image with given radius from coordinates
202
202
 
203
- get_germany(map_type: WeatherMapType, optional WeatherBackgroundMapType background_type, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image of whole germany
203
+ get_germany(map_type: WeatherMapType, optional WeatherBackgroundMapType background_type, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image of whole germany
204
204
 
205
- get_map(minx,miny,maxx,maxy, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image
205
+ get_map(minx,miny,maxx,maxy, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image
206
206
  ```
207
207
 
208
208
 
@@ -234,7 +234,7 @@ for image in enumerate(maploop._images):
234
234
 
235
235
  ```python
236
236
  ImageLoop(minx: float, miny: float, maxx: float, maxy: float, map_type: WeatherMapType, background_type: WeatherBackgroundMapType,
237
- steps: int = 6, image_width: int = 520,image_height: int = 580, markers: list[Marker] = []) -> ImageLoop
237
+ steps: int = 6, image_width: int = 520,image_height: int = 580, markers: list[Marker] = [], optional bool dark_mode) -> ImageLoop
238
238
 
239
239
  get_images() -> Iterable[ImageFile.ImageFile] # Returns the image loop
240
240
 
@@ -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.11",
8
+ version="v2.1.14",
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,
@@ -25,8 +25,8 @@ setuptools.setup(
25
25
  "requests",
26
26
  "Pillow",
27
27
  "arrow",
28
- "stream-inflate==0.0.40",
29
- "stream-unzip",
28
+ "stream-inflate==0.0.41",
29
+ "stream-unzip==0.0.98",
30
30
  "httpx",
31
31
  ],
32
32
  )
@@ -757,9 +757,13 @@ class Weather:
757
757
  return issue_time_new
758
758
 
759
759
  def parse_station_name(self, tree):
760
- return tree.xpath(
760
+ parsed_name = tree.xpath(
761
761
  "./kml:Document/kml:Placemark/kml:description", namespaces=self.namespaces
762
- )[0].text
762
+ )
763
+ if len(parsed_name) == 0:
764
+ return None
765
+ else:
766
+ return parsed_name[0].text
763
767
 
764
768
  def parse_timesteps(self, tree):
765
769
  return [
@@ -89,6 +89,7 @@ def get_from_location(
89
89
  image_width=520,
90
90
  image_height=580,
91
91
  markers: list[Marker] = [],
92
+ dark_mode: bool = False,
92
93
  ):
93
94
  if radius_km <= 0:
94
95
  raise ValueError("Radius must be greater than 0")
@@ -107,6 +108,7 @@ def get_from_location(
107
108
  image_width,
108
109
  image_height,
109
110
  markers,
111
+ dark_mode,
110
112
  )
111
113
 
112
114
 
@@ -116,6 +118,7 @@ def get_germany(
116
118
  image_width=520,
117
119
  image_height=580,
118
120
  markers: list[Marker] = [],
121
+ dark_mode: bool = False,
119
122
  ):
120
123
  return get_map(
121
124
  germany_boundaries.minx,
@@ -127,6 +130,7 @@ def get_germany(
127
130
  image_width,
128
131
  image_height,
129
132
  markers,
133
+ dark_mode,
130
134
  )
131
135
 
132
136
 
@@ -140,6 +144,7 @@ def get_map(
140
144
  image_width=520,
141
145
  image_height=580,
142
146
  markers: list[Marker] = [],
147
+ dark_mode: bool = False,
143
148
  ):
144
149
  if image_width > 1200 or image_height > 1400:
145
150
  raise ValueError(
@@ -157,6 +162,16 @@ def get_map(
157
162
  request = requests.get(url, stream=True)
158
163
  if request.status_code == 200:
159
164
  image = Image.open(BytesIO(request.content))
165
+ if dark_mode:
166
+ new_image_data = []
167
+ for item in image.getdata(): # type: ignore
168
+ if item[0] == 255 and item[1] == 255 and item[2] == 255:
169
+ new_image_data.append((0, 0, 0))
170
+ else:
171
+ new_image_data.append(item)
172
+
173
+ # update image data
174
+ image.putdata(new_image_data)
160
175
  image = draw_marker(image, ImageBoundaries(minx, maxx, miny, maxy), markers)
161
176
  return image
162
177
 
@@ -186,6 +201,7 @@ class ImageLoop:
186
201
  image_width: int = 520,
187
202
  image_height: int = 580,
188
203
  markers: list[Marker] = [],
204
+ dark_mode: bool = False,
189
205
  ):
190
206
  if image_width > 1200 or image_height > 1400:
191
207
  raise ValueError(
@@ -203,6 +219,7 @@ class ImageLoop:
203
219
  self._image_width = image_width
204
220
  self._image_height = image_height
205
221
  self.markers = markers
222
+ self.dark_mode = dark_mode
206
223
  self._images = deque([], steps)
207
224
 
208
225
  self._full_reload()
@@ -246,11 +263,21 @@ class ImageLoop:
246
263
  layers = f"{self._background_type.value}, {self._map_type.value}"
247
264
  else:
248
265
  layers = f"{self._map_type.value}, {self._background_type.value}"
249
- url = f"https://maps.dwd.de/geoserver/dwd/wms?service=WMS&version=1.1.0&request=GetMap&layers={layers}&bbox={self._minx},{self._miny},{self._maxx},{self._maxy}&width={self._image_width}&height={self._image_height}&srs=EPSG:4326&styles=&format=image/png&TIME={date.strftime("%Y-%m-%dT%H:%M:00.0Z")}"
266
+ url = f"https://maps.dwd.de/geoserver/dwd/wms?service=WMS&version=1.1.0&request=GetMap&layers={layers}&bbox={self._minx},{self._miny},{self._maxx},{self._maxy}&width={self._image_width}&height={self._image_height}&srs=EPSG:4326&styles=&format=image/png&TIME={date.strftime('%Y-%m-%dT%H:%M:00.0Z')}"
250
267
  request = requests.get(url, stream=True)
251
268
  if request.status_code != 200:
252
269
  raise ConnectionError("Error during image request from DWD servers")
253
270
  image = Image.open(BytesIO(request.content))
271
+ if self.dark_mode:
272
+ new_image_data = []
273
+ for item in image.getdata(): # type: ignore
274
+ if item[0] == 255 and item[1] == 255 and item[2] == 255:
275
+ new_image_data.append((0, 0, 0))
276
+ else:
277
+ new_image_data.append(item)
278
+
279
+ # update image data
280
+ image.putdata(new_image_data)
254
281
  image = draw_marker(
255
282
  image,
256
283
  ImageBoundaries(self._minx, self._maxx, self._miny, self._maxy),
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 2.1.11
3
+ Version: 2.1.14
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,9 +14,17 @@ 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.40
18
- Requires-Dist: stream-unzip
17
+ Requires-Dist: stream-inflate==0.0.41
18
+ Requires-Dist: stream-unzip==0.0.98
19
19
  Requires-Dist: httpx
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
20
28
 
21
29
  # Simple DWD weather forecast
22
30
 
@@ -208,7 +216,7 @@ class MarkerShape(Enum):
208
216
  CIRCLE = "circle"
209
217
  SQUARE = "square"
210
218
  CROSS = "cross"
211
-
219
+
212
220
  class Marker(
213
221
  latitude: float,
214
222
  longitude: float,
@@ -218,11 +226,11 @@ class Marker(
218
226
  width: int = 0,
219
227
  )
220
228
 
221
- get_from_location(longitude, latitude, radius_km, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image with given radius from coordinates
229
+ get_from_location(longitude, latitude, radius_km, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image with given radius from coordinates
222
230
 
223
- get_germany(map_type: WeatherMapType, optional WeatherBackgroundMapType background_type, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image of whole germany
231
+ get_germany(map_type: WeatherMapType, optional WeatherBackgroundMapType background_type, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image of whole germany
224
232
 
225
- get_map(minx,miny,maxx,maxy, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker]) #Returns map as pillow image
233
+ get_map(minx,miny,maxx,maxy, map_type: WeatherMapType, background_type: WeatherBackgroundMapType, optional integer image_width, optional integer image_height, optional markers: list[Marker], optional bool dark_mode) #Returns map as pillow image
226
234
  ```
227
235
 
228
236
 
@@ -254,7 +262,7 @@ for image in enumerate(maploop._images):
254
262
 
255
263
  ```python
256
264
  ImageLoop(minx: float, miny: float, maxx: float, maxy: float, map_type: WeatherMapType, background_type: WeatherBackgroundMapType,
257
- steps: int = 6, image_width: int = 520,image_height: int = 580, markers: list[Marker] = []) -> ImageLoop
265
+ steps: int = 6, image_width: int = 520,image_height: int = 580, markers: list[Marker] = [], optional bool dark_mode) -> ImageLoop
258
266
 
259
267
  get_images() -> Iterable[ImageFile.ImageFile] # Returns the image loop
260
268
 
@@ -0,0 +1,7 @@
1
+ lxml
2
+ requests
3
+ Pillow
4
+ arrow
5
+ stream-inflate==0.0.41
6
+ stream-unzip==0.0.98
7
+ httpx
@@ -1,7 +0,0 @@
1
- lxml
2
- requests
3
- Pillow
4
- arrow
5
- stream-inflate==0.0.40
6
- stream-unzip
7
- httpx