python-weather 2.2.5__py3-none-any.whl → 2.2.6__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.
@@ -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
  '☀️',
@@ -4,10 +4,8 @@
4
4
  from datetime import date, datetime, time
5
5
  from typing import TYPE_CHECKING
6
6
 
7
- from babel.dates import parse_time
8
-
9
7
  from .base import BaseForecast
10
- from .constants import LATLON_REGEX
8
+ from .constants import LATLON_REGEX, TIME_REGEX
11
9
  from .enums import HeatIndex, Phase
12
10
 
13
11
  if TYPE_CHECKING:
@@ -120,6 +118,16 @@ class HourlyForecast(BaseForecast):
120
118
  return f'<{__class__.__module__}.{__class__.__name__} time={self.time!r} temperature={self.temperature} kind={self.kind!r}>'
121
119
 
122
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
+
123
131
  class DailyForecast:
124
132
  """A weather forecast for a specific day."""
125
133
 
@@ -198,10 +206,10 @@ class DailyForecast:
198
206
  ]
199
207
 
200
208
  @staticmethod
201
- def __parse_time(timestamp: str) -> time | None:
209
+ def __parse_time(timestring: str) -> time | None:
202
210
  try:
203
- return parse_time(timestamp, locale='en_US')
204
- except ValueError: # pragma: nocover
211
+ return _parse_time(timestring)
212
+ except (AssertionError, TypeError, ValueError): # pragma: nocover
205
213
  ...
206
214
 
207
215
  def __repr__(self) -> str:
@@ -260,7 +268,7 @@ class Forecast(BaseForecast):
260
268
  self.location = nearest['areaName'][0]['value']
261
269
  self.country = nearest['country'][0]['value']
262
270
  self.datetime = datetime.combine(
263
- datetime.today(), parse_time(current['observation_time'], locale='en_US')
271
+ datetime.today(), _parse_time(current['observation_time'])
264
272
  )
265
273
 
266
274
  try:
python_weather/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  # SPDX-FileCopyrightText: 2021-2026 null8626
3
3
 
4
- VERSION = '2.2.5'
4
+ VERSION = '2.2.6'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-weather
3
- Version: 2.2.5
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,8 +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.3
37
- Requires-Dist: babel>=2.18.0
36
+ Requires-Dist: aiohttp>=3.14.5
38
37
  Provides-Extra: dev
39
38
  Requires-Dist: mock>=5.2.0; extra == "dev"
40
39
  Requires-Dist: pytest>=9.1.1; extra == "dev"
@@ -0,0 +1,13 @@
1
+ python_weather/__init__.py,sha256=LY7PmFAlyMF6_4CbprO9epFr_5EwPaJEUpkNuuggTXA,761
2
+ python_weather/base.py,sha256=sApqcPLFBhdoZPF5KwKIp529HF26dV0mhiCr0VRxycc,2272
3
+ python_weather/client.py,sha256=8JzZU2T5zKch2lP79ooBQR4aVCxpvv5k8HUeJDwQTkQ,6119
4
+ python_weather/constants.py,sha256=X8olq7GffgRXEer_Ew2lRIx2tql2DnkNbA8xeIpdDvs,1014
5
+ python_weather/enums.py,sha256=jSOl2FSi7dhKbdafg2rCJ814bX5tHshXTPr4BlXbhcw,8453
6
+ python_weather/errors.py,sha256=_B2puqZHJ8gxbnd3aRS_-YsExIf5wDLWPQKRwZxNp-I,793
7
+ python_weather/forecast.py,sha256=ujiiJw0mrhykSkBwQGsVaalw20TS1dWUIRkhPEmni9E,8714
8
+ python_weather/version.py,sha256=1pmY2I5-x17tKQcE-Zhy52kOpU0z4GG9-CzHn_hME78,95
9
+ python_weather-2.2.6.dist-info/licenses/LICENSE,sha256=SDMQ_fK2dwWVC-3qqONf6VVMnBe-GtBtlfYZIN2SBXw,1080
10
+ python_weather-2.2.6.dist-info/METADATA,sha256=z3hpYx-gL5CpK5NSwgrfJuAXORnDwafes_M5RSjODEk,4262
11
+ python_weather-2.2.6.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
12
+ python_weather-2.2.6.dist-info/top_level.txt,sha256=NDqLSO3dHB1tjjiNJfEg-a9_eoOmawAZynZsy9Yu48w,15
13
+ python_weather-2.2.6.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- python_weather/__init__.py,sha256=LY7PmFAlyMF6_4CbprO9epFr_5EwPaJEUpkNuuggTXA,761
2
- python_weather/base.py,sha256=sApqcPLFBhdoZPF5KwKIp529HF26dV0mhiCr0VRxycc,2272
3
- python_weather/client.py,sha256=8JzZU2T5zKch2lP79ooBQR4aVCxpvv5k8HUeJDwQTkQ,6119
4
- python_weather/constants.py,sha256=26-FcczVWeQ8eK_0cUXvSzQmTYsIsW4aRAVeo7g73pc,960
5
- python_weather/enums.py,sha256=jSOl2FSi7dhKbdafg2rCJ814bX5tHshXTPr4BlXbhcw,8453
6
- python_weather/errors.py,sha256=_B2puqZHJ8gxbnd3aRS_-YsExIf5wDLWPQKRwZxNp-I,793
7
- python_weather/forecast.py,sha256=Nwh3e1-98IaWooV3bHkQhY_MGo39-4Q2LGzX-ClsJeM,8510
8
- python_weather/version.py,sha256=g__VZok-Um0u5jNQ5WgZP-fLJqZYva6mvgFk7pacgmw,95
9
- python_weather-2.2.5.dist-info/licenses/LICENSE,sha256=SDMQ_fK2dwWVC-3qqONf6VVMnBe-GtBtlfYZIN2SBXw,1080
10
- python_weather-2.2.5.dist-info/METADATA,sha256=kd5f1nkKrbvEfNZBEs8VgWJbC5SO1gBwDWsrJyu3TzU,4291
11
- python_weather-2.2.5.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
12
- python_weather-2.2.5.dist-info/top_level.txt,sha256=NDqLSO3dHB1tjjiNJfEg-a9_eoOmawAZynZsy9Yu48w,15
13
- python_weather-2.2.5.dist-info/RECORD,,