meteo-lt-pkg 0.5.3__py3-none-any.whl → 0.6.0__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.
- meteo_lt/api.py +1 -1
- meteo_lt/warnings.py +20 -24
- {meteo_lt_pkg-0.5.3.dist-info → meteo_lt_pkg-0.6.0.dist-info}/METADATA +16 -3
- meteo_lt_pkg-0.6.0.dist-info/RECORD +12 -0
- meteo_lt_pkg-0.5.3.dist-info/RECORD +0 -12
- {meteo_lt_pkg-0.5.3.dist-info → meteo_lt_pkg-0.6.0.dist-info}/WHEEL +0 -0
- {meteo_lt_pkg-0.5.3.dist-info → meteo_lt_pkg-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {meteo_lt_pkg-0.5.3.dist-info → meteo_lt_pkg-0.6.0.dist-info}/top_level.txt +0 -0
meteo_lt/api.py
CHANGED
|
@@ -67,7 +67,7 @@ class MeteoLtAPI:
|
|
|
67
67
|
|
|
68
68
|
return await self.get_forecast(place_code, include_warnings=True)
|
|
69
69
|
|
|
70
|
-
async def get_forecast(self, place_code: str, include_warnings: bool =
|
|
70
|
+
async def get_forecast(self, place_code: str, include_warnings: bool = True) -> Forecast:
|
|
71
71
|
"""Retrieves forecast data from API"""
|
|
72
72
|
forecast = await self.client.fetch_forecast(place_code)
|
|
73
73
|
|
meteo_lt/warnings.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Unified warnings processor for handling weather and hydrological warning-related logic"""
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
|
-
from datetime import datetime, timezone
|
|
4
|
+
from datetime import datetime, timedelta, timezone
|
|
5
5
|
from typing import Any, Dict, List, Literal, Optional
|
|
6
6
|
|
|
7
7
|
from .client import MeteoLtClient
|
|
@@ -109,10 +109,7 @@ class WarningsProcessor:
|
|
|
109
109
|
return False
|
|
110
110
|
|
|
111
111
|
def enrich_forecast_with_warnings(self, forecast: Forecast, warnings: List[MeteoWarning]) -> None:
|
|
112
|
-
"""Enrich forecast timestamps with relevant warnings
|
|
113
|
-
|
|
114
|
-
All warnings (weather and hydro) are added to 'warnings' attribute
|
|
115
|
-
"""
|
|
112
|
+
"""Enrich forecast timestamps with relevant warnings"""
|
|
116
113
|
if not warnings:
|
|
117
114
|
return
|
|
118
115
|
|
|
@@ -135,27 +132,26 @@ class WarningsProcessor:
|
|
|
135
132
|
def _get_warnings_for_timestamp(self, timestamp_str: str, warnings: List[MeteoWarning]) -> List[MeteoWarning]:
|
|
136
133
|
"""Get warnings that are active for a specific timestamp"""
|
|
137
134
|
try:
|
|
138
|
-
timestamp = datetime.fromisoformat(timestamp_str).
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
for warning in warnings:
|
|
142
|
-
if not warning.start_time or not warning.end_time:
|
|
143
|
-
continue
|
|
135
|
+
timestamp = datetime.fromisoformat(timestamp_str).astimezone(timezone.utc)
|
|
136
|
+
except (ValueError, AttributeError):
|
|
137
|
+
return []
|
|
144
138
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
# Forecast timestamp represents an hour starting at this time
|
|
140
|
+
hour_start = timestamp
|
|
141
|
+
hour_end = timestamp + timedelta(hours=1)
|
|
148
142
|
|
|
149
|
-
|
|
150
|
-
if start_time <= timestamp <= end_time:
|
|
151
|
-
applicable_warnings.append(warning)
|
|
143
|
+
applicable_warnings = []
|
|
152
144
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
145
|
+
for warning in warnings:
|
|
146
|
+
try:
|
|
147
|
+
start_time = datetime.fromisoformat(warning.start_time).astimezone(timezone.utc)
|
|
148
|
+
end_time = datetime.fromisoformat(warning.end_time).astimezone(timezone.utc)
|
|
149
|
+
except (ValueError, AttributeError, TypeError):
|
|
150
|
+
continue
|
|
156
151
|
|
|
157
|
-
|
|
152
|
+
# Check if warning period overlaps with the hour
|
|
153
|
+
# Warning overlaps if it starts before hour ends AND ends after hour starts
|
|
154
|
+
if start_time < hour_end and end_time > hour_start:
|
|
155
|
+
applicable_warnings.append(warning)
|
|
158
156
|
|
|
159
|
-
|
|
160
|
-
# Return empty list if timestamp parsing fails
|
|
161
|
-
return []
|
|
157
|
+
return applicable_warnings
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meteo_lt-pkg
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: A library to fetch weather data from api.meteo.lt
|
|
5
5
|
Author-email: Brunas <brunonas@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Brunas/meteo_lt-pkg
|
|
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: aiohttp>=3.13
|
|
@@ -37,6 +37,11 @@ Dynamic: license-file
|
|
|
37
37
|
|
|
38
38
|
MeteoLt-Pkg is a Python library designed to fetch weather data from [`api.meteo.lt`](https://api.meteo.lt/). This library provides convenient methods to interact with the API and obtain weather forecasts and related data. Please visit for more information.
|
|
39
39
|
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.11 or higher
|
|
43
|
+
- aiohttp 3.13 or higher
|
|
44
|
+
|
|
40
45
|
## Installation
|
|
41
46
|
|
|
42
47
|
You can install the package using pip:
|
|
@@ -153,7 +158,7 @@ To get the weather forecast for a specific place:
|
|
|
153
158
|
```python
|
|
154
159
|
async def fetch_forecast():
|
|
155
160
|
async with MeteoLtAPI() as api:
|
|
156
|
-
# Get forecast for Vilnius
|
|
161
|
+
# Get forecast for Vilnius (warnings included by default)
|
|
157
162
|
forecast = await api.get_forecast("vilnius")
|
|
158
163
|
|
|
159
164
|
# Current conditions
|
|
@@ -162,6 +167,12 @@ async def fetch_forecast():
|
|
|
162
167
|
print(f"Feels like: {current.apparent_temperature}°C")
|
|
163
168
|
print(f"Condition: {current.condition_code}")
|
|
164
169
|
|
|
170
|
+
# Check for warnings (automatically included)
|
|
171
|
+
if current.warnings:
|
|
172
|
+
print(f"\nActive warnings: {len(current.warnings)}")
|
|
173
|
+
for warning in current.warnings:
|
|
174
|
+
print(f"- {warning.warning_type}: {warning.severity}")
|
|
175
|
+
|
|
165
176
|
# Future forecasts
|
|
166
177
|
print(f"\nNext 24 hours:")
|
|
167
178
|
for timestamp in forecast.forecast_timestamps[:24]:
|
|
@@ -170,6 +181,8 @@ async def fetch_forecast():
|
|
|
170
181
|
asyncio.run(fetch_forecast())
|
|
171
182
|
```
|
|
172
183
|
|
|
184
|
+
> **NOTE**: Weather and hydrological warnings are automatically included in forecast data by default. To exclude warnings, use `get_forecast(place_code, include_warnings=False)`.
|
|
185
|
+
|
|
173
186
|
> **NOTE**: `current_conditions` is the current hour record from the `forecast_timestamps` array. Also, `forecast_timestamps` array has past time records filtered out due to `api.meteo.lt` not doing that automatically.
|
|
174
187
|
|
|
175
188
|
### Fetching Weather Forecast with Warnings
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
meteo_lt/__init__.py,sha256=3Ef5fihtzaxsRcygINTnNdQI9W_9JULe6ycyeRw8bN8,452
|
|
2
|
+
meteo_lt/api.py,sha256=Zjp_HHEyxKlrySFyBsszdpToHOeGDh-HacsBZoXJnG8,5068
|
|
3
|
+
meteo_lt/client.py,sha256=R4lfX9_m-x7Va7IcU6d3rxAE0plOg2gD4NJ9gqtIVvg,5189
|
|
4
|
+
meteo_lt/const.py,sha256=w0eEOss0YbTJzNdpfocrd5DZ7pFSwR3aQ-uMfNttvag,2791
|
|
5
|
+
meteo_lt/models.py,sha256=ENQmWFZMQmXhHIddoAuC7givYbXIlu58v_pI8iACR4o,6143
|
|
6
|
+
meteo_lt/utils.py,sha256=VhXWnqfeBdKrncrsIrSwzsiN3Sg4-kDG5v6Yz-PBOLc,1281
|
|
7
|
+
meteo_lt/warnings.py,sha256=tHoXRIxlxntXqP6XyU9qyG0nzcdjAxuRmcRDPwcr6-U,7015
|
|
8
|
+
meteo_lt_pkg-0.6.0.dist-info/licenses/LICENSE,sha256=3IGi6xn6NUdXGvcdwD0MUbhy3Yz5NRnUjJrwKanFAD4,1073
|
|
9
|
+
meteo_lt_pkg-0.6.0.dist-info/METADATA,sha256=LEds1ZWvATaad6IB21-XltyrtlEmdQ8YzZJfb5n5bIY,18804
|
|
10
|
+
meteo_lt_pkg-0.6.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
11
|
+
meteo_lt_pkg-0.6.0.dist-info/top_level.txt,sha256=-aEdc9FzHhcIH4_0TNdKNxuvDnS3chKoJy6LK9Ud-G4,9
|
|
12
|
+
meteo_lt_pkg-0.6.0.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
meteo_lt/__init__.py,sha256=3Ef5fihtzaxsRcygINTnNdQI9W_9JULe6ycyeRw8bN8,452
|
|
2
|
-
meteo_lt/api.py,sha256=GQDhDnTj3cx1hokt5188NnGz8FVDJHJDJXGm_fXxop8,5069
|
|
3
|
-
meteo_lt/client.py,sha256=R4lfX9_m-x7Va7IcU6d3rxAE0plOg2gD4NJ9gqtIVvg,5189
|
|
4
|
-
meteo_lt/const.py,sha256=w0eEOss0YbTJzNdpfocrd5DZ7pFSwR3aQ-uMfNttvag,2791
|
|
5
|
-
meteo_lt/models.py,sha256=ENQmWFZMQmXhHIddoAuC7givYbXIlu58v_pI8iACR4o,6143
|
|
6
|
-
meteo_lt/utils.py,sha256=VhXWnqfeBdKrncrsIrSwzsiN3Sg4-kDG5v6Yz-PBOLc,1281
|
|
7
|
-
meteo_lt/warnings.py,sha256=aD28RAlD-6vQdnJHNNkDBW3QkP23Dt0mgJ97A3iWRqo,7101
|
|
8
|
-
meteo_lt_pkg-0.5.3.dist-info/licenses/LICENSE,sha256=3IGi6xn6NUdXGvcdwD0MUbhy3Yz5NRnUjJrwKanFAD4,1073
|
|
9
|
-
meteo_lt_pkg-0.5.3.dist-info/METADATA,sha256=vmWdE8zOaWpCtTWRpKOBvPojy6Ru3RThzzjTqC55ZE4,18261
|
|
10
|
-
meteo_lt_pkg-0.5.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
11
|
-
meteo_lt_pkg-0.5.3.dist-info/top_level.txt,sha256=-aEdc9FzHhcIH4_0TNdKNxuvDnS3chKoJy6LK9Ud-G4,9
|
|
12
|
-
meteo_lt_pkg-0.5.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|