python-weather 2.2.4__tar.gz → 2.2.6__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.
- {python_weather-2.2.4/python_weather.egg-info → python_weather-2.2.6}/PKG-INFO +2 -2
- {python_weather-2.2.4 → python_weather-2.2.6}/pyproject.toml +2 -2
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/__init__.py +2 -1
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/base.py +1 -5
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/constants.py +1 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/forecast.py +15 -6
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/version.py +1 -1
- {python_weather-2.2.4 → python_weather-2.2.6/python_weather.egg-info}/PKG-INFO +2 -2
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather.egg-info/requires.txt +1 -1
- {python_weather-2.2.4 → python_weather-2.2.6}/LICENSE +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/MANIFEST.in +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/README.md +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/client.py +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/enums.py +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather/errors.py +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather.egg-info/SOURCES.txt +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather.egg-info/dependency_links.txt +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/python_weather.egg-info/top_level.txt +0 -0
- {python_weather-2.2.4 → python_weather-2.2.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-weather
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.6
|
|
4
4
|
Summary: A free and asynchronous weather API wrapper made in Python, for Python.
|
|
5
5
|
Author: null8626
|
|
6
6
|
License-Expression: MIT
|
|
@@ -33,7 +33,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
33
33
|
Requires-Python: >=3.10
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
License-File: LICENSE
|
|
36
|
-
Requires-Dist: aiohttp>=3.14.
|
|
36
|
+
Requires-Dist: aiohttp>=3.14.5
|
|
37
37
|
Provides-Extra: dev
|
|
38
38
|
Requires-Dist: mock>=5.2.0; extra == "dev"
|
|
39
39
|
Requires-Dist: pytest>=9.1.1; extra == "dev"
|
|
@@ -3,13 +3,13 @@ requires = ["setuptools"]
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "python-weather"
|
|
6
|
-
version = "2.2.
|
|
6
|
+
version = "2.2.6"
|
|
7
7
|
description = "A free and asynchronous weather API wrapper made in Python, for Python."
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
authors = [{ name = "null8626" }]
|
|
11
11
|
keywords = ["weather", "forecast", "weather-forecast"]
|
|
12
|
-
dependencies = ["aiohttp>=3.14.
|
|
12
|
+
dependencies = ["aiohttp>=3.14.5"]
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Development Status :: 5 - Production/Stable",
|
|
15
15
|
"Intended Audience :: Education",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# SPDX-FileCopyrightText: 2021-2026 null8626
|
|
3
3
|
|
|
4
4
|
from .client import Client
|
|
5
|
-
from .constants import IMPERIAL, METRIC
|
|
5
|
+
from .constants import IMPERIAL, METRIC, _Unit
|
|
6
6
|
from .enums import HeatIndex, Kind, Locale, Phase, UltraViolet, WindDirection
|
|
7
7
|
from .errors import Error, RequestError
|
|
8
8
|
from .forecast import Forecast
|
|
@@ -30,4 +30,5 @@ __all__ = (
|
|
|
30
30
|
'RequestError',
|
|
31
31
|
'UltraViolet',
|
|
32
32
|
'WindDirection',
|
|
33
|
+
'_Unit',
|
|
33
34
|
)
|
|
@@ -64,11 +64,7 @@ class BaseForecast:
|
|
|
64
64
|
"""The description regarding the forecast depending on the localization used."""
|
|
65
65
|
|
|
66
66
|
def __init__(self, json: dict, unit: '_Unit', locale: Locale):
|
|
67
|
-
description = (
|
|
68
|
-
json['weatherDesc'][0]['value']
|
|
69
|
-
if locale is Locale.ENGLISH
|
|
70
|
-
else json[f'lang_{locale.value}'][0]['value']
|
|
71
|
-
)
|
|
67
|
+
description = json.get(f'lang_{locale.value}', json['weatherDesc'])[0]['value']
|
|
72
68
|
|
|
73
69
|
self.cloud_cover = int(json['cloudcover'])
|
|
74
70
|
self.ultraviolet = UltraViolet._new(int(json['uvIndex']))
|
|
@@ -25,6 +25,7 @@ METRIC = _Unit('C', 'Kmph', '', 'MM', '', 1)
|
|
|
25
25
|
IMPERIAL = _Unit('F', 'Miles', 'Inches', 'Inches', 'Miles', 2.54)
|
|
26
26
|
|
|
27
27
|
LATLON_REGEX = re.compile(r'^Lat (\-?[\d\.]+) and Lon (\-?[\d\.]+)$')
|
|
28
|
+
TIME_REGEX = re.compile(r'^(\d{2}):(\d{2}) ([AP])M$')
|
|
28
29
|
|
|
29
30
|
KIND_EMOJIS = (
|
|
30
31
|
'☀️',
|
|
@@ -5,7 +5,7 @@ from datetime import date, datetime, time
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
from .base import BaseForecast
|
|
8
|
-
from .constants import LATLON_REGEX
|
|
8
|
+
from .constants import LATLON_REGEX, TIME_REGEX
|
|
9
9
|
from .enums import HeatIndex, Phase
|
|
10
10
|
|
|
11
11
|
if TYPE_CHECKING:
|
|
@@ -118,6 +118,16 @@ class HourlyForecast(BaseForecast):
|
|
|
118
118
|
return f'<{__class__.__module__}.{__class__.__name__} time={self.time!r} temperature={self.temperature} kind={self.kind!r}>'
|
|
119
119
|
|
|
120
120
|
|
|
121
|
+
def _parse_time(timestring: str) -> time:
|
|
122
|
+
match = TIME_REGEX.fullmatch(timestring)
|
|
123
|
+
|
|
124
|
+
assert match is not None
|
|
125
|
+
|
|
126
|
+
hour, minute, ampm = match.groups()
|
|
127
|
+
|
|
128
|
+
return time(int(hour) % 12 + (12 if ampm == 'P' else 0), int(minute))
|
|
129
|
+
|
|
130
|
+
|
|
121
131
|
class DailyForecast:
|
|
122
132
|
"""A weather forecast for a specific day."""
|
|
123
133
|
|
|
@@ -196,10 +206,10 @@ class DailyForecast:
|
|
|
196
206
|
]
|
|
197
207
|
|
|
198
208
|
@staticmethod
|
|
199
|
-
def __parse_time(
|
|
209
|
+
def __parse_time(timestring: str) -> time | None:
|
|
200
210
|
try:
|
|
201
|
-
return
|
|
202
|
-
except ValueError: # pragma: nocover
|
|
211
|
+
return _parse_time(timestring)
|
|
212
|
+
except (AssertionError, TypeError, ValueError): # pragma: nocover
|
|
203
213
|
...
|
|
204
214
|
|
|
205
215
|
def __repr__(self) -> str:
|
|
@@ -258,8 +268,7 @@ class Forecast(BaseForecast):
|
|
|
258
268
|
self.location = nearest['areaName'][0]['value']
|
|
259
269
|
self.country = nearest['country'][0]['value']
|
|
260
270
|
self.datetime = datetime.combine(
|
|
261
|
-
datetime.today(),
|
|
262
|
-
datetime.strptime(current['observation_time'], '%I:%M %p').time(),
|
|
271
|
+
datetime.today(), _parse_time(current['observation_time'])
|
|
263
272
|
)
|
|
264
273
|
|
|
265
274
|
try:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-weather
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.6
|
|
4
4
|
Summary: A free and asynchronous weather API wrapper made in Python, for Python.
|
|
5
5
|
Author: null8626
|
|
6
6
|
License-Expression: MIT
|
|
@@ -33,7 +33,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
33
33
|
Requires-Python: >=3.10
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
License-File: LICENSE
|
|
36
|
-
Requires-Dist: aiohttp>=3.14.
|
|
36
|
+
Requires-Dist: aiohttp>=3.14.5
|
|
37
37
|
Provides-Extra: dev
|
|
38
38
|
Requires-Dist: mock>=5.2.0; extra == "dev"
|
|
39
39
|
Requires-Dist: pytest>=9.1.1; extra == "dev"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|