python-weather 1.0.3__tar.gz → 1.1.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.
- {python-weather-1.0.3/python_weather.egg-info → python-weather-1.1.0}/PKG-INFO +4 -3
- {python-weather-1.0.3 → python-weather-1.1.0}/pyproject.toml +4 -4
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/base.py +11 -21
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/client.py +2 -2
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/constants.py +28 -3
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/forecast.py +15 -14
- {python-weather-1.0.3 → python-weather-1.1.0/python_weather.egg-info}/PKG-INFO +4 -3
- python-weather-1.1.0/python_weather.egg-info/requires.txt +1 -0
- python-weather-1.0.3/python_weather.egg-info/requires.txt +0 -1
- {python-weather-1.0.3 → python-weather-1.1.0}/LICENSE +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/MANIFEST.in +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/README.md +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/__init__.py +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/enums.py +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather/errors.py +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather.egg-info/SOURCES.txt +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather.egg-info/dependency_links.txt +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/python_weather.egg-info/top_level.txt +0 -0
- {python-weather-1.0.3 → python-weather-1.1.0}/setup.cfg +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-weather
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A free and asynchronous weather API wrapper made in Python, for Python.
|
|
5
5
|
Author: null8626
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: repository, https://github.com/null8626/python-weather
|
|
8
|
-
Project-URL: download_url, https://github.com/null8626/python-weather/archive/1.0.
|
|
8
|
+
Project-URL: download_url, https://github.com/null8626/python-weather/archive/1.1.0.tar.gz
|
|
9
9
|
Keywords: weather,forecast,weather-api,weather-forecast
|
|
10
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
11
|
Classifier: Framework :: aiohttp
|
|
@@ -29,9 +29,10 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
29
29
|
Classifier: Programming Language :: Python :: 3.10
|
|
30
30
|
Classifier: Programming Language :: Python :: 3.11
|
|
31
31
|
Classifier: Programming Language :: Python :: 3.12
|
|
32
|
-
Requires-Python: >=3.
|
|
32
|
+
Requires-Python: >=3.8
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
License-File: LICENSE
|
|
35
|
+
Requires-Dist: aiohttp==3.9.0
|
|
35
36
|
|
|
36
37
|
# [python-weather][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url] [![Build Status][ci-image]][ci-url] [![license][github-license-image]][github-license-url] [![BLAZINGLY FAST!!!][blazingly-fast-image]][blazingly-fast-url]
|
|
37
38
|
|
|
@@ -3,13 +3,13 @@ requires = ["setuptools"]
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "python-weather"
|
|
6
|
-
version = "1.0
|
|
6
|
+
version = "1.1.0"
|
|
7
7
|
description = "A free and asynchronous weather API wrapper made in Python, for Python."
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = { text = "MIT" }
|
|
10
10
|
authors = [{ name = "null8626" }]
|
|
11
11
|
keywords = ["weather", "forecast", "weather-api", "weather-forecast"]
|
|
12
|
-
dependencies = ["aiohttp==3.
|
|
12
|
+
dependencies = ["aiohttp==3.9.0"]
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Development Status :: 5 - Production/Stable",
|
|
15
15
|
"Framework :: aiohttp",
|
|
@@ -34,8 +34,8 @@ classifiers = [
|
|
|
34
34
|
"Programming Language :: Python :: 3.11",
|
|
35
35
|
"Programming Language :: Python :: 3.12"
|
|
36
36
|
]
|
|
37
|
-
requires-python = ">=3.
|
|
37
|
+
requires-python = ">=3.8"
|
|
38
38
|
|
|
39
39
|
[project.urls]
|
|
40
40
|
repository = "https://github.com/null8626/python-weather"
|
|
41
|
-
download_url = "https://github.com/null8626/python-weather/archive/1.0.
|
|
41
|
+
download_url = "https://github.com/null8626/python-weather/archive/1.1.0.tar.gz"
|
|
@@ -25,12 +25,12 @@ SOFTWARE.
|
|
|
25
25
|
from enum import auto, Enum
|
|
26
26
|
|
|
27
27
|
from .enums import WindDirection, Kind, Locale, Ultraviolet
|
|
28
|
-
from .constants import
|
|
28
|
+
from .constants import _Unit
|
|
29
29
|
|
|
30
30
|
class CustomizableBase:
|
|
31
31
|
__slots__ = ('__unit', '__locale')
|
|
32
32
|
|
|
33
|
-
def __init__(self, unit:
|
|
33
|
+
def __init__(self, unit: _Unit, locale: Locale):
|
|
34
34
|
self.unit = unit
|
|
35
35
|
self.locale = locale
|
|
36
36
|
|
|
@@ -41,7 +41,7 @@ class CustomizableBase:
|
|
|
41
41
|
return self.__unit
|
|
42
42
|
|
|
43
43
|
@unit.setter
|
|
44
|
-
def unit(self, to:
|
|
44
|
+
def unit(self, to: _Unit):
|
|
45
45
|
"""
|
|
46
46
|
Sets the default measuring unit used to display information in this object.
|
|
47
47
|
|
|
@@ -56,7 +56,7 @@ class CustomizableBase:
|
|
|
56
56
|
If the ``to`` argument is not either :attr:`METRIC` or :attr:`IMPERIAL`.
|
|
57
57
|
"""
|
|
58
58
|
|
|
59
|
-
if
|
|
59
|
+
if not isinstance(to, _Unit):
|
|
60
60
|
raise Error('Invalid measuring unit specified!')
|
|
61
61
|
|
|
62
62
|
self.__unit = to
|
|
@@ -91,7 +91,7 @@ class CustomizableBase:
|
|
|
91
91
|
class BaseForecast(CustomizableBase):
|
|
92
92
|
__slots__ = ('__inner',)
|
|
93
93
|
|
|
94
|
-
def __init__(self, json: dict, unit:
|
|
94
|
+
def __init__(self, json: dict, unit: _Unit, locale: Locale):
|
|
95
95
|
self.__inner = json
|
|
96
96
|
|
|
97
97
|
super().__init__(unit, locale)
|
|
@@ -107,8 +107,7 @@ class BaseForecast(CustomizableBase):
|
|
|
107
107
|
""":class:`int`: What it felt like, in Celcius or Fahrenheit."""
|
|
108
108
|
|
|
109
109
|
return int(
|
|
110
|
-
self.__inner[
|
|
111
|
-
f'FeelsLike{"C" if self._CustomizableBase__unit == METRIC else "F"}']
|
|
110
|
+
self.__inner[f'FeelsLike{self._CustomizableBase__unit.temperature}']
|
|
112
111
|
)
|
|
113
112
|
|
|
114
113
|
@property
|
|
@@ -121,18 +120,14 @@ class BaseForecast(CustomizableBase):
|
|
|
121
120
|
def temperature(self) -> int:
|
|
122
121
|
""":class:`int`: The weather temperature in either Celcius or Fahrenheit."""
|
|
123
122
|
|
|
124
|
-
return int(
|
|
125
|
-
self.
|
|
126
|
-
__inner[f'temp_{"C" if self._CustomizableBase__unit == METRIC else "F"}']
|
|
127
|
-
)
|
|
123
|
+
return int(self.__inner[f'temp_{self._CustomizableBase__unit.temperature}'])
|
|
128
124
|
|
|
129
125
|
@property
|
|
130
126
|
def precipitation(self) -> float:
|
|
131
127
|
""":class:`float`: The precipitation in either Millimeters or Inches."""
|
|
132
128
|
|
|
133
129
|
return float(
|
|
134
|
-
self.__inner[
|
|
135
|
-
f'precip{"MM" if self._CustomizableBase__unit == METRIC else "Inches"}']
|
|
130
|
+
self.__inner[f'precip{self._CustomizableBase__unit.precipitation}']
|
|
136
131
|
)
|
|
137
132
|
|
|
138
133
|
@property
|
|
@@ -140,8 +135,7 @@ class BaseForecast(CustomizableBase):
|
|
|
140
135
|
""":class:`float`: The pressure in either Pascal or Inches."""
|
|
141
136
|
|
|
142
137
|
return float(
|
|
143
|
-
self.__inner[
|
|
144
|
-
f'pressure{"" if self._CustomizableBase__unit == METRIC else "Inches"}']
|
|
138
|
+
self.__inner[f'pressure{self._CustomizableBase__unit.pressure}']
|
|
145
139
|
)
|
|
146
140
|
|
|
147
141
|
@property
|
|
@@ -149,9 +143,7 @@ class BaseForecast(CustomizableBase):
|
|
|
149
143
|
""":class:`int`: The visibility distance in either Kilometers or Miles."""
|
|
150
144
|
|
|
151
145
|
return int(
|
|
152
|
-
self.__inner[
|
|
153
|
-
f'visibility{"" if self._CustomizableBase__unit == METRIC else "Miles"}'
|
|
154
|
-
]
|
|
146
|
+
self.__inner[f'visibility{self._CustomizableBase__unit.visibility}']
|
|
155
147
|
)
|
|
156
148
|
|
|
157
149
|
@property
|
|
@@ -159,9 +151,7 @@ class BaseForecast(CustomizableBase):
|
|
|
159
151
|
""":class:`int`: The wind speeds in either Kilometers per hour or Miles per hour."""
|
|
160
152
|
|
|
161
153
|
return int(
|
|
162
|
-
self.__inner[
|
|
163
|
-
f'windspeed{"Kmph" if self._CustomizableBase__unit == METRIC else "Miles"}'
|
|
164
|
-
]
|
|
154
|
+
self.__inner[f'windspeed{self._CustomizableBase__unit.velocity}']
|
|
165
155
|
)
|
|
166
156
|
|
|
167
157
|
@property
|
|
@@ -28,7 +28,7 @@ from typing import Optional
|
|
|
28
28
|
from asyncio import sleep
|
|
29
29
|
from enum import auto
|
|
30
30
|
|
|
31
|
-
from .constants import
|
|
31
|
+
from .constants import _Unit, METRIC
|
|
32
32
|
from .base import CustomizableBase
|
|
33
33
|
from .forecast import Weather
|
|
34
34
|
from .errors import Error
|
|
@@ -115,7 +115,7 @@ class Client(CustomizableBase):
|
|
|
115
115
|
elif self.__session.closed:
|
|
116
116
|
raise Error('Client is already closed')
|
|
117
117
|
|
|
118
|
-
if
|
|
118
|
+
if not isinstance(unit, _Unit):
|
|
119
119
|
unit = self._CustomizableBase__unit
|
|
120
120
|
|
|
121
121
|
if not isinstance(locale, Locale):
|
|
@@ -22,11 +22,36 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
22
22
|
SOFTWARE.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
|
+
from typing import Union
|
|
25
26
|
from re import compile
|
|
26
27
|
from enum import auto
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
class _Unit:
|
|
30
|
+
__slots__ = (
|
|
31
|
+
'temperature', 'velocity', 'pressure', 'precipitation', 'visibility',
|
|
32
|
+
'cm_divisor'
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
temperature: str,
|
|
38
|
+
velocity: str,
|
|
39
|
+
pressure: str,
|
|
40
|
+
precipitation: str,
|
|
41
|
+
visibility: str,
|
|
42
|
+
cm_divisor: Union[int, float],
|
|
43
|
+
):
|
|
44
|
+
self.temperature = temperature
|
|
45
|
+
self.velocity = velocity
|
|
46
|
+
self.pressure = pressure
|
|
47
|
+
self.precipitation = precipitation
|
|
48
|
+
self.visibility = visibility
|
|
49
|
+
self.cm_divisor = cm_divisor
|
|
50
|
+
|
|
51
|
+
def __repr__(self) -> str:
|
|
52
|
+
return f'<Unit [{self.temperature}, {self.velocity}]>'
|
|
53
|
+
|
|
54
|
+
METRIC = _Unit('C', 'Kmph', '', 'MM', '', 1)
|
|
55
|
+
IMPERIAL = _Unit('F', 'Miles', 'Inches', 'Inches', 'Miles', 2.54)
|
|
30
56
|
|
|
31
57
|
LATLON_REGEX = compile(r'^Lat (\-?[\d\.]+) and Lon (\-?[\d\.]+)$')
|
|
32
|
-
VALID_UNITS = (METRIC, IMPERIAL)
|
|
@@ -26,9 +26,9 @@ from typing import Iterable, Optional, Tuple
|
|
|
26
26
|
from datetime import datetime, date, time
|
|
27
27
|
from enum import auto
|
|
28
28
|
|
|
29
|
-
from .enums import Phase, Locale
|
|
30
|
-
from .constants import LATLON_REGEX, METRIC
|
|
31
29
|
from .base import BaseForecast, CustomizableBase
|
|
30
|
+
from .constants import _Unit, LATLON_REGEX
|
|
31
|
+
from .enums import Phase, Locale
|
|
32
32
|
|
|
33
33
|
class Area:
|
|
34
34
|
"""Represents the location of the weather forecast."""
|
|
@@ -163,7 +163,7 @@ class HourlyForecast(BaseForecast):
|
|
|
163
163
|
|
|
164
164
|
__slots__ = ()
|
|
165
165
|
|
|
166
|
-
def __init__(self, json: dict, unit:
|
|
166
|
+
def __init__(self, json: dict, unit: _Unit, locale: Locale):
|
|
167
167
|
# for inheritance purposes
|
|
168
168
|
if 'temp_C' not in json:
|
|
169
169
|
json['temp_C'] = json.pop('tempC')
|
|
@@ -182,7 +182,7 @@ class HourlyForecast(BaseForecast):
|
|
|
182
182
|
""":class:`int`: The dew point in either Celcius or Fahrenheit."""
|
|
183
183
|
|
|
184
184
|
return int(
|
|
185
|
-
self._BaseForecast__inner[f'DewPoint{
|
|
185
|
+
self._BaseForecast__inner[f'DewPoint{self._CustomizableBase__unit.temperature}']
|
|
186
186
|
) # yapf: disable
|
|
187
187
|
|
|
188
188
|
@property
|
|
@@ -190,7 +190,7 @@ class HourlyForecast(BaseForecast):
|
|
|
190
190
|
""":class:`int`: The heat index in either Celcius or Fahrenheit."""
|
|
191
191
|
|
|
192
192
|
return int(
|
|
193
|
-
self._BaseForecast__inner[f'HeatIndex{
|
|
193
|
+
self._BaseForecast__inner[f'HeatIndex{self._CustomizableBase__unit.temperature}']
|
|
194
194
|
) # yapf: disable
|
|
195
195
|
|
|
196
196
|
@property
|
|
@@ -198,14 +198,14 @@ class HourlyForecast(BaseForecast):
|
|
|
198
198
|
""":class:`int`: The wind chill value in either Celcius or Fahrenheit."""
|
|
199
199
|
|
|
200
200
|
return int(
|
|
201
|
-
self._BaseForecast__inner[f'WindChill{
|
|
201
|
+
self._BaseForecast__inner[f'WindChill{self._CustomizableBase__unit.temperature}']
|
|
202
202
|
) # yapf: disable
|
|
203
203
|
|
|
204
204
|
@property
|
|
205
205
|
def wind_gust(self) -> int:
|
|
206
206
|
""":class:`int`: The wind gust value in either Kilometers per hour or Miles per hour."""
|
|
207
207
|
|
|
208
|
-
key = f'WindGust{
|
|
208
|
+
key = f'WindGust{self._CustomizableBase__unit.velocity}'
|
|
209
209
|
return int(self._BaseForecast__inner[key])
|
|
210
210
|
|
|
211
211
|
@property
|
|
@@ -283,7 +283,7 @@ class HourlyForecast(BaseForecast):
|
|
|
283
283
|
class DailyForecast(CustomizableBase):
|
|
284
284
|
__slots__ = ('__inner',)
|
|
285
285
|
|
|
286
|
-
def __init__(self, json: dict, unit:
|
|
286
|
+
def __init__(self, json: dict, unit: _Unit, locale: Locale):
|
|
287
287
|
self.__inner = json
|
|
288
288
|
|
|
289
289
|
super().__init__(unit, locale)
|
|
@@ -310,7 +310,7 @@ class DailyForecast(CustomizableBase):
|
|
|
310
310
|
""":class:`int`: The lowest temperature in either Celcius or Fahrenheit."""
|
|
311
311
|
|
|
312
312
|
return int(
|
|
313
|
-
self.__inner[f'mintemp{
|
|
313
|
+
self.__inner[f'mintemp{self._CustomizableBase__unit.temperature}']
|
|
314
314
|
) # yapf: disable
|
|
315
315
|
|
|
316
316
|
@property
|
|
@@ -318,7 +318,7 @@ class DailyForecast(CustomizableBase):
|
|
|
318
318
|
""":class:`int`: The highest temperature in either Celcius or Fahrenheit."""
|
|
319
319
|
|
|
320
320
|
return int(
|
|
321
|
-
self.__inner[f'maxtemp{
|
|
321
|
+
self.__inner[f'maxtemp{self._CustomizableBase__unit.temperature}']
|
|
322
322
|
) # yapf: disable
|
|
323
323
|
|
|
324
324
|
@property
|
|
@@ -326,7 +326,7 @@ class DailyForecast(CustomizableBase):
|
|
|
326
326
|
""":class:`int`: The average temperature in either Celcius or Fahrenheit."""
|
|
327
327
|
|
|
328
328
|
return int(
|
|
329
|
-
self.__inner[f'avgtemp{
|
|
329
|
+
self.__inner[f'avgtemp{self._CustomizableBase__unit.temperature}']
|
|
330
330
|
) # yapf: disable
|
|
331
331
|
|
|
332
332
|
@property
|
|
@@ -339,8 +339,9 @@ class DailyForecast(CustomizableBase):
|
|
|
339
339
|
def snowfall(self) -> float:
|
|
340
340
|
""":class:`float`: Total snowfall in either Centimeters or Inches."""
|
|
341
341
|
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
return float(
|
|
343
|
+
self.__inner['totalSnow_cm']
|
|
344
|
+
) / self._CustomizableBase__unit.cm_divisor
|
|
344
345
|
|
|
345
346
|
@property
|
|
346
347
|
def hourly(self) -> Iterable[HourlyForecast]:
|
|
@@ -357,7 +358,7 @@ class Weather(CustomizableBase):
|
|
|
357
358
|
|
|
358
359
|
__slots__ = ('__inner',)
|
|
359
360
|
|
|
360
|
-
def __init__(self, json: dict, unit:
|
|
361
|
+
def __init__(self, json: dict, unit: _Unit, locale: Locale):
|
|
361
362
|
self.__inner = json
|
|
362
363
|
|
|
363
364
|
super().__init__(unit, locale)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-weather
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A free and asynchronous weather API wrapper made in Python, for Python.
|
|
5
5
|
Author: null8626
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: repository, https://github.com/null8626/python-weather
|
|
8
|
-
Project-URL: download_url, https://github.com/null8626/python-weather/archive/1.0.
|
|
8
|
+
Project-URL: download_url, https://github.com/null8626/python-weather/archive/1.1.0.tar.gz
|
|
9
9
|
Keywords: weather,forecast,weather-api,weather-forecast
|
|
10
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
11
|
Classifier: Framework :: aiohttp
|
|
@@ -29,9 +29,10 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
29
29
|
Classifier: Programming Language :: Python :: 3.10
|
|
30
30
|
Classifier: Programming Language :: Python :: 3.11
|
|
31
31
|
Classifier: Programming Language :: Python :: 3.12
|
|
32
|
-
Requires-Python: >=3.
|
|
32
|
+
Requires-Python: >=3.8
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
License-File: LICENSE
|
|
35
|
+
Requires-Dist: aiohttp==3.9.0
|
|
35
36
|
|
|
36
37
|
# [python-weather][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url] [![Build Status][ci-image]][ci-url] [![license][github-license-image]][github-license-url] [![BLAZINGLY FAST!!!][blazingly-fast-image]][blazingly-fast-url]
|
|
37
38
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aiohttp==3.9.0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
aiohttp==3.8.4
|
|
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
|