meteo-lt-pkg 0.5.3__tar.gz → 0.6.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meteo_lt-pkg
3
- Version: 0.5.3
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.10
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
@@ -10,6 +10,11 @@
10
10
 
11
11
  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.
12
12
 
13
+ ## Requirements
14
+
15
+ - Python 3.11 or higher
16
+ - aiohttp 3.13 or higher
17
+
13
18
  ## Installation
14
19
 
15
20
  You can install the package using pip:
@@ -126,7 +131,7 @@ To get the weather forecast for a specific place:
126
131
  ```python
127
132
  async def fetch_forecast():
128
133
  async with MeteoLtAPI() as api:
129
- # Get forecast for Vilnius
134
+ # Get forecast for Vilnius (warnings included by default)
130
135
  forecast = await api.get_forecast("vilnius")
131
136
 
132
137
  # Current conditions
@@ -135,6 +140,12 @@ async def fetch_forecast():
135
140
  print(f"Feels like: {current.apparent_temperature}°C")
136
141
  print(f"Condition: {current.condition_code}")
137
142
 
143
+ # Check for warnings (automatically included)
144
+ if current.warnings:
145
+ print(f"\nActive warnings: {len(current.warnings)}")
146
+ for warning in current.warnings:
147
+ print(f"- {warning.warning_type}: {warning.severity}")
148
+
138
149
  # Future forecasts
139
150
  print(f"\nNext 24 hours:")
140
151
  for timestamp in forecast.forecast_timestamps[:24]:
@@ -143,6 +154,8 @@ async def fetch_forecast():
143
154
  asyncio.run(fetch_forecast())
144
155
  ```
145
156
 
157
+ > **NOTE**: Weather and hydrological warnings are automatically included in forecast data by default. To exclude warnings, use `get_forecast(place_code, include_warnings=False)`.
158
+
146
159
  > **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.
147
160
 
148
161
  ### Fetching Weather Forecast with Warnings
@@ -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 = False) -> Forecast:
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
 
@@ -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).replace(tzinfo=timezone.utc)
139
- applicable_warnings = []
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
- try:
146
- start_time = datetime.fromisoformat(warning.start_time.replace("Z", "+00:00"))
147
- end_time = datetime.fromisoformat(warning.end_time.replace("Z", "+00:00"))
139
+ # Forecast timestamp represents an hour starting at this time
140
+ hour_start = timestamp
141
+ hour_end = timestamp + timedelta(hours=1)
148
142
 
149
- # Check if timestamp falls within warning period
150
- if start_time <= timestamp <= end_time:
151
- applicable_warnings.append(warning)
143
+ applicable_warnings = []
152
144
 
153
- except (ValueError, AttributeError):
154
- # Skip warnings with invalid time formats
155
- continue
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
- return applicable_warnings
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
- except (ValueError, AttributeError):
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.5.3
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.10
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
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "meteo_lt-pkg"
3
- version = "0.5.3"
3
+ version = "0.6.0"
4
4
  authors = [
5
5
  { name="Brunas", email="brunonas@gmail.com" },
6
6
  ]
7
7
  description = "A library to fetch weather data from api.meteo.lt"
8
8
  readme = "README.md"
9
- requires-python = ">=3.10"
9
+ requires-python = ">=3.11"
10
10
  classifiers = [
11
11
  "Programming Language :: Python :: 3",
12
12
  "License :: OSI Approved :: MIT License",
File without changes
File without changes
File without changes