meteo-lt-pkg 0.4.0b1__py3-none-any.whl → 0.5.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 +5 -12
- meteo_lt/models.py +13 -13
- meteo_lt/warnings.py +24 -34
- {meteo_lt_pkg-0.4.0b1.dist-info → meteo_lt_pkg-0.5.0.dist-info}/METADATA +1 -1
- meteo_lt_pkg-0.5.0.dist-info/RECORD +12 -0
- {meteo_lt_pkg-0.4.0b1.dist-info → meteo_lt_pkg-0.5.0.dist-info}/WHEEL +1 -1
- meteo_lt_pkg-0.4.0b1.dist-info/RECORD +0 -12
- {meteo_lt_pkg-0.4.0b1.dist-info → meteo_lt_pkg-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {meteo_lt_pkg-0.4.0b1.dist-info → meteo_lt_pkg-0.5.0.dist-info}/top_level.txt +0 -0
meteo_lt/api.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Main API class script"""
|
|
2
2
|
|
|
3
|
-
# pylint: disable=W0718
|
|
4
|
-
|
|
5
3
|
from typing import List
|
|
6
4
|
|
|
7
5
|
from .models import Forecast, WeatherWarning
|
|
@@ -81,14 +79,9 @@ class MeteoLtAPI:
|
|
|
81
79
|
):
|
|
82
80
|
return
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
)
|
|
82
|
+
warnings = await self.get_weather_warnings(
|
|
83
|
+
forecast.place.administrative_division
|
|
84
|
+
)
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
forecast, warnings
|
|
92
|
-
)
|
|
93
|
-
except Exception as e:
|
|
94
|
-
print(f"Warning: Could not fetch weather warnings: {e}")
|
|
86
|
+
if warnings:
|
|
87
|
+
self.warnings_processor.enrich_forecast_with_warnings(forecast, warnings)
|
meteo_lt/models.py
CHANGED
|
@@ -48,6 +48,18 @@ class Place:
|
|
|
48
48
|
self.counties.append(county)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
@dataclass
|
|
52
|
+
class WeatherWarning:
|
|
53
|
+
"""Weather Warning"""
|
|
54
|
+
|
|
55
|
+
county: str
|
|
56
|
+
warning_type: str
|
|
57
|
+
severity: str
|
|
58
|
+
description: str
|
|
59
|
+
start_time: Optional[str] = None
|
|
60
|
+
end_time: Optional[str] = None
|
|
61
|
+
|
|
62
|
+
|
|
51
63
|
@dataclass
|
|
52
64
|
class ForecastTimestamp:
|
|
53
65
|
"""ForecastTimestamp"""
|
|
@@ -63,7 +75,7 @@ class ForecastTimestamp:
|
|
|
63
75
|
pressure: float = field(metadata={"json_key": "seaLevelPressure"})
|
|
64
76
|
humidity: float = field(metadata={"json_key": "relativeHumidity"})
|
|
65
77
|
precipitation: float = field(metadata={"json_key": "totalPrecipitation"})
|
|
66
|
-
warnings: List[
|
|
78
|
+
warnings: List[WeatherWarning] = field(default_factory=list, init=False)
|
|
67
79
|
|
|
68
80
|
|
|
69
81
|
@dataclass
|
|
@@ -132,18 +144,6 @@ def from_dict(cls, data: dict):
|
|
|
132
144
|
return cls(**init_args)
|
|
133
145
|
|
|
134
146
|
|
|
135
|
-
@dataclass
|
|
136
|
-
class WeatherWarning:
|
|
137
|
-
"""Weather Warning"""
|
|
138
|
-
|
|
139
|
-
county: str
|
|
140
|
-
warning_type: str
|
|
141
|
-
severity: str
|
|
142
|
-
description: str
|
|
143
|
-
start_time: Optional[str] = None
|
|
144
|
-
end_time: Optional[str] = None
|
|
145
|
-
|
|
146
|
-
|
|
147
147
|
Coordinates.from_dict = classmethod(from_dict)
|
|
148
148
|
Place.from_dict = classmethod(from_dict)
|
|
149
149
|
ForecastTimestamp.from_dict = classmethod(from_dict)
|
meteo_lt/warnings.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Weather warnings processor for handling warning-related logic"""
|
|
2
2
|
|
|
3
|
-
# pylint: disable=W0718
|
|
4
|
-
|
|
5
3
|
import re
|
|
6
4
|
from datetime import datetime, timezone
|
|
7
5
|
from typing import List
|
|
@@ -66,38 +64,30 @@ class WeatherWarningsProcessor:
|
|
|
66
64
|
|
|
67
65
|
def _create_warning_from_alert(self, alert: dict, area: dict) -> WeatherWarning:
|
|
68
66
|
"""Create a WeatherWarning from alert data"""
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
severity=severity,
|
|
94
|
-
description=full_description,
|
|
95
|
-
start_time=alert.get("t_from"),
|
|
96
|
-
end_time=alert.get("t_to"),
|
|
97
|
-
)
|
|
98
|
-
except Exception as e:
|
|
99
|
-
print(f"Error creating warning: {e}")
|
|
100
|
-
return None
|
|
67
|
+
county = area.get("name", "Unknown")
|
|
68
|
+
phenomenon = alert.get("phenomenon", "")
|
|
69
|
+
severity = alert.get("severity", "Minor")
|
|
70
|
+
|
|
71
|
+
warning_type = re.sub(r"^(dangerous|severe|extreme)-", "", phenomenon)
|
|
72
|
+
|
|
73
|
+
desc_dict = alert.get("description", {})
|
|
74
|
+
inst_dict = alert.get("instruction", {})
|
|
75
|
+
|
|
76
|
+
description = desc_dict.get("en") or desc_dict.get("lt", "")
|
|
77
|
+
instruction = inst_dict.get("en") or inst_dict.get("lt", "")
|
|
78
|
+
|
|
79
|
+
full_description = description
|
|
80
|
+
if instruction:
|
|
81
|
+
full_description += f"\n\nRecommendations: {instruction}"
|
|
82
|
+
|
|
83
|
+
return WeatherWarning(
|
|
84
|
+
county=county,
|
|
85
|
+
warning_type=warning_type,
|
|
86
|
+
severity=severity,
|
|
87
|
+
description=full_description,
|
|
88
|
+
start_time=alert.get("t_from"),
|
|
89
|
+
end_time=alert.get("t_to"),
|
|
90
|
+
)
|
|
101
91
|
|
|
102
92
|
def _warning_affects_area(
|
|
103
93
|
self, warning: WeatherWarning, administrative_division: str
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
meteo_lt/__init__.py,sha256=TP3DhEXEpHdI6bevRjxb0cbVrEWbI8mEocYc1DwA_KI,255
|
|
2
|
+
meteo_lt/api.py,sha256=3RCNUV9guscSADrcLRbsRomhp9rpPDrMVdCmKXsohmw,3006
|
|
3
|
+
meteo_lt/client.py,sha256=j5F1Ag00EnEI8ErLz0Q2lYqWfO8YgqYlsAHfhzkGyWE,2798
|
|
4
|
+
meteo_lt/const.py,sha256=1xeQ2wErqPREnYfK4OogadlVIu0p2gGoILsOcsIfp8Q,2702
|
|
5
|
+
meteo_lt/models.py,sha256=ki0kVe_uUVOMSC2VQsW5i2pd9A06wvuupn7jgSwyQ-0,4838
|
|
6
|
+
meteo_lt/utils.py,sha256=SL7ZeTEfdrdQoe_DOJaiA2zVxt08ujyFJ24JxJm1Hks,1081
|
|
7
|
+
meteo_lt/warnings.py,sha256=XpHMOkwqXB_mgQccyPdOlmRFcOV58Dkwtva0kNDxdpQ,6520
|
|
8
|
+
meteo_lt_pkg-0.5.0.dist-info/licenses/LICENSE,sha256=3IGi6xn6NUdXGvcdwD0MUbhy3Yz5NRnUjJrwKanFAD4,1073
|
|
9
|
+
meteo_lt_pkg-0.5.0.dist-info/METADATA,sha256=-PAVjCqFFvvdg8kEvn96UJM5ZjRCbOWLwGlbzjE1wpc,10328
|
|
10
|
+
meteo_lt_pkg-0.5.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
11
|
+
meteo_lt_pkg-0.5.0.dist-info/top_level.txt,sha256=-aEdc9FzHhcIH4_0TNdKNxuvDnS3chKoJy6LK9Ud-G4,9
|
|
12
|
+
meteo_lt_pkg-0.5.0.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
meteo_lt/__init__.py,sha256=TP3DhEXEpHdI6bevRjxb0cbVrEWbI8mEocYc1DwA_KI,255
|
|
2
|
-
meteo_lt/api.py,sha256=ouM8zB51CuJVm3NmT6uuRMJsvuu49fmFMGyFzy3UJyM,3202
|
|
3
|
-
meteo_lt/client.py,sha256=j5F1Ag00EnEI8ErLz0Q2lYqWfO8YgqYlsAHfhzkGyWE,2798
|
|
4
|
-
meteo_lt/const.py,sha256=1xeQ2wErqPREnYfK4OogadlVIu0p2gGoILsOcsIfp8Q,2702
|
|
5
|
-
meteo_lt/models.py,sha256=xLx9DcrXOolED8PPQ2fcu4dNdPA6ykS9c_zherLTCj8,4840
|
|
6
|
-
meteo_lt/utils.py,sha256=SL7ZeTEfdrdQoe_DOJaiA2zVxt08ujyFJ24JxJm1Hks,1081
|
|
7
|
-
meteo_lt/warnings.py,sha256=YthSCVDAJgzxHwtZ6jZmnImq1ZZsj2Nd9y9RKMPZoG0,6954
|
|
8
|
-
meteo_lt_pkg-0.4.0b1.dist-info/licenses/LICENSE,sha256=3IGi6xn6NUdXGvcdwD0MUbhy3Yz5NRnUjJrwKanFAD4,1073
|
|
9
|
-
meteo_lt_pkg-0.4.0b1.dist-info/METADATA,sha256=yv1prhcoQzP8lug8rEbBf47W1twMj8NaINxN5eFOcBI,10330
|
|
10
|
-
meteo_lt_pkg-0.4.0b1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
-
meteo_lt_pkg-0.4.0b1.dist-info/top_level.txt,sha256=-aEdc9FzHhcIH4_0TNdKNxuvDnS3chKoJy6LK9Ud-G4,9
|
|
12
|
-
meteo_lt_pkg-0.4.0b1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|