python-weather 1.0.3__tar.gz → 1.1.1__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
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021-2023 null (https://github.com/null8626)
3
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-weather
3
- Version: 1.0.3
3
+ Version: 1.1.1
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.3.tar.gz
8
+ Project-URL: download_url, https://github.com/null8626/python-weather/archive/1.1.1.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.7
32
+ Requires-Python: >=3.8
33
33
  Description-Content-Type: text/markdown
34
34
  License-File: LICENSE
35
+ Requires-Dist: aiohttp==3.9.3
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.3"
6
+ version = "1.1.1"
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.8.4"]
12
+ dependencies = ["aiohttp==3.9.3"]
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.7"
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.3.tar.gz"
41
+ download_url = "https://github.com/null8626/python-weather/archive/1.1.1.tar.gz"
@@ -4,7 +4,7 @@ A free and asynchronous weather API wrapper made in Python, for Python.
4
4
 
5
5
  The MIT License (MIT)
6
6
 
7
- Copyright (c) 2021-2023 null (https://github.com/null8626)
7
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
8
8
 
9
9
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
10
  of this software and associated documentation files (the 'Software'), to deal
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2021-2023 null (https://github.com/null8626)
4
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the 'Software'), to deal
@@ -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 METRIC, VALID_UNITS
28
+ from .constants import _Unit
29
29
 
30
30
  class CustomizableBase:
31
31
  __slots__ = ('__unit', '__locale')
32
32
 
33
- def __init__(self, unit: auto, locale: Locale):
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: auto):
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 to not in VALID_UNITS:
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: auto, locale: Locale):
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
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2021-2023 null (https://github.com/null8626)
4
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the 'Software'), to deal
@@ -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 METRIC, VALID_UNITS
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 unit not in VALID_UNITS:
118
+ if not isinstance(unit, _Unit):
119
119
  unit = self._CustomizableBase__unit
120
120
 
121
121
  if not isinstance(locale, Locale):
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2021-2023 null (https://github.com/null8626)
4
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the 'Software'), to deal
@@ -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
- METRIC = auto()
29
- IMPERIAL = auto()
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)
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2021-2023 null (https://github.com/null8626)
4
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the 'Software'), to deal
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2021-2023 null (https://github.com/null8626)
4
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the 'Software'), to deal
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2021-2023 null (https://github.com/null8626)
4
+ Copyright (c) 2021-2024 null (https://github.com/null8626)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the 'Software'), to deal
@@ -22,13 +22,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  SOFTWARE.
23
23
  """
24
24
 
25
+ import warnings
25
26
  from typing import Iterable, Optional, Tuple
26
27
  from datetime import datetime, date, time
27
28
  from enum import auto
28
29
 
29
- from .enums import Phase, Locale
30
- from .constants import LATLON_REGEX, METRIC
31
30
  from .base import BaseForecast, CustomizableBase
31
+ from .constants import _Unit, LATLON_REGEX
32
+ from .enums import Phase, Locale
32
33
 
33
34
  class Area:
34
35
  """Represents the location of the weather forecast."""
@@ -163,7 +164,7 @@ class HourlyForecast(BaseForecast):
163
164
 
164
165
  __slots__ = ()
165
166
 
166
- def __init__(self, json: dict, unit: auto, locale: Locale):
167
+ def __init__(self, json: dict, unit: _Unit, locale: Locale):
167
168
  # for inheritance purposes
168
169
  if 'temp_C' not in json:
169
170
  json['temp_C'] = json.pop('tempC')
@@ -182,7 +183,7 @@ class HourlyForecast(BaseForecast):
182
183
  """:class:`int`: The dew point in either Celcius or Fahrenheit."""
183
184
 
184
185
  return int(
185
- self._BaseForecast__inner[f'DewPoint{"C" if self._CustomizableBase__unit == METRIC else "F"}']
186
+ self._BaseForecast__inner[f'DewPoint{self._CustomizableBase__unit.temperature}']
186
187
  ) # yapf: disable
187
188
 
188
189
  @property
@@ -190,7 +191,7 @@ class HourlyForecast(BaseForecast):
190
191
  """:class:`int`: The heat index in either Celcius or Fahrenheit."""
191
192
 
192
193
  return int(
193
- self._BaseForecast__inner[f'HeatIndex{"C" if self._CustomizableBase__unit == METRIC else "F"}']
194
+ self._BaseForecast__inner[f'HeatIndex{self._CustomizableBase__unit.temperature}']
194
195
  ) # yapf: disable
195
196
 
196
197
  @property
@@ -198,14 +199,14 @@ class HourlyForecast(BaseForecast):
198
199
  """:class:`int`: The wind chill value in either Celcius or Fahrenheit."""
199
200
 
200
201
  return int(
201
- self._BaseForecast__inner[f'WindChill{"C" if self._CustomizableBase__unit == METRIC else "F"}']
202
+ self._BaseForecast__inner[f'WindChill{self._CustomizableBase__unit.temperature}']
202
203
  ) # yapf: disable
203
204
 
204
205
  @property
205
206
  def wind_gust(self) -> int:
206
207
  """:class:`int`: The wind gust value in either Kilometers per hour or Miles per hour."""
207
208
 
208
- key = f'WindGust{"Kmph" if self._CustomizableBase__unit == METRIC else "Miles"}'
209
+ key = f'WindGust{self._CustomizableBase__unit.velocity}'
209
210
  return int(self._BaseForecast__inner[key])
210
211
 
211
212
  @property
@@ -239,11 +240,21 @@ class HourlyForecast(BaseForecast):
239
240
  return int(self._BaseForecast__inner['chanceofrain'])
240
241
 
241
242
  @property
242
- def chances_of_remdry(self) -> int:
243
- """:class:`int`: Chances of a rem dry in percent."""
243
+ def chances_of_remaining_dry(self) -> int:
244
+ """:class:`int`: Chances of remaining dry in percent."""
244
245
 
245
246
  return int(self._BaseForecast__inner['chanceofremdry'])
246
247
 
248
+ @property
249
+ def chances_of_remdry(self) -> int:
250
+ """:class:`int`: Deprecated, use chances_of_remaining_dry instead."""
251
+
252
+ warnings.warn(
253
+ 'Deprecated as of v1.1.1. Use `chances_of_remaining_dry` instead.',
254
+ DeprecationWarning
255
+ )
256
+ return self.chances_of_remaining_dry
257
+
247
258
  @property
248
259
  def chances_of_snow(self) -> int:
249
260
  """:class:`int`: Chances of a snow in percent."""
@@ -283,7 +294,7 @@ class HourlyForecast(BaseForecast):
283
294
  class DailyForecast(CustomizableBase):
284
295
  __slots__ = ('__inner',)
285
296
 
286
- def __init__(self, json: dict, unit: auto, locale: Locale):
297
+ def __init__(self, json: dict, unit: _Unit, locale: Locale):
287
298
  self.__inner = json
288
299
 
289
300
  super().__init__(unit, locale)
@@ -310,7 +321,7 @@ class DailyForecast(CustomizableBase):
310
321
  """:class:`int`: The lowest temperature in either Celcius or Fahrenheit."""
311
322
 
312
323
  return int(
313
- self.__inner[f'mintemp{"C" if self._CustomizableBase__unit == METRIC else "F"}']
324
+ self.__inner[f'mintemp{self._CustomizableBase__unit.temperature}']
314
325
  ) # yapf: disable
315
326
 
316
327
  @property
@@ -318,7 +329,7 @@ class DailyForecast(CustomizableBase):
318
329
  """:class:`int`: The highest temperature in either Celcius or Fahrenheit."""
319
330
 
320
331
  return int(
321
- self.__inner[f'maxtemp{"C" if self._CustomizableBase__unit == METRIC else "F"}']
332
+ self.__inner[f'maxtemp{self._CustomizableBase__unit.temperature}']
322
333
  ) # yapf: disable
323
334
 
324
335
  @property
@@ -326,7 +337,7 @@ class DailyForecast(CustomizableBase):
326
337
  """:class:`int`: The average temperature in either Celcius or Fahrenheit."""
327
338
 
328
339
  return int(
329
- self.__inner[f'avgtemp{"C" if self._CustomizableBase__unit == METRIC else "F"}']
340
+ self.__inner[f'avgtemp{self._CustomizableBase__unit.temperature}']
330
341
  ) # yapf: disable
331
342
 
332
343
  @property
@@ -339,8 +350,9 @@ class DailyForecast(CustomizableBase):
339
350
  def snowfall(self) -> float:
340
351
  """:class:`float`: Total snowfall in either Centimeters or Inches."""
341
352
 
342
- width = float(self.__inner['totalSnow_cm'])
343
- return width if self._CustomizableBase__unit == METRIC else width / 2.54
353
+ return float(
354
+ self.__inner['totalSnow_cm']
355
+ ) / self._CustomizableBase__unit.cm_divisor
344
356
 
345
357
  @property
346
358
  def hourly(self) -> Iterable[HourlyForecast]:
@@ -357,7 +369,7 @@ class Weather(CustomizableBase):
357
369
 
358
370
  __slots__ = ('__inner',)
359
371
 
360
- def __init__(self, json: dict, unit: auto, locale: Locale):
372
+ def __init__(self, json: dict, unit: _Unit, locale: Locale):
361
373
  self.__inner = json
362
374
 
363
375
  super().__init__(unit, locale)
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-weather
3
- Version: 1.0.3
3
+ Version: 1.1.1
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.3.tar.gz
8
+ Project-URL: download_url, https://github.com/null8626/python-weather/archive/1.1.1.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.7
32
+ Requires-Python: >=3.8
33
33
  Description-Content-Type: text/markdown
34
34
  License-File: LICENSE
35
+ Requires-Dist: aiohttp==3.9.3
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.3
@@ -1 +0,0 @@
1
- aiohttp==3.8.4
File without changes
File without changes