pyastroweatherio 0.62.0.dev7__tar.gz → 0.62.0.dev8__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.
Files changed (17) hide show
  1. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/PKG-INFO +1 -1
  2. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/client.py +62 -70
  3. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/dataclasses.py +215 -22
  4. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/helper_functions.py +71 -159
  5. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/PKG-INFO +1 -1
  6. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/SOURCES.txt +0 -1
  7. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/setup.py +1 -1
  8. pyastroweatherio-0.62.0.dev7/pyastroweatherio/models.py +0 -209
  9. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/LICENSE +0 -0
  10. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/README.md +0 -0
  11. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/__init__.py +0 -0
  12. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/const.py +0 -0
  13. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/errors.py +0 -0
  14. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
  15. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/requires.txt +0 -0
  16. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/top_level.txt +0 -0
  17. {pyastroweatherio-0.62.0.dev7 → pyastroweatherio-0.62.0.dev8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyastroweatherio
3
- Version: 0.62.0.dev7
3
+ Version: 0.62.0.dev8
4
4
  Summary: Python Wrapper for 7Timer and Met.no REST API
5
5
  Home-page: https://github.com/mawinkler/pyastroweatherio
6
6
  Author: Markus Winkler
@@ -7,12 +7,12 @@ import math
7
7
  import os.path
8
8
  from datetime import UTC, datetime, timedelta
9
9
  from json.decoder import JSONDecodeError
10
+ from pprint import pprint as pp
10
11
  from typing import Optional
11
12
 
12
13
  import aiofiles
13
14
  from aiohttp import ClientSession, ClientTimeout
14
15
  from aiohttp.client_exceptions import ClientError
15
- from pydantic import ValidationError
16
16
 
17
17
  from pyastroweatherio.const import (
18
18
  BASE_URL_MET,
@@ -41,15 +41,25 @@ from pyastroweatherio.const import (
41
41
  )
42
42
  from pyastroweatherio.dataclasses import (
43
43
  AtmosphereData,
44
- TimeData,
45
- GeoLocationData,
44
+ AtmosphereDataModel,
46
45
  ConditionData,
46
+ ConditionDataModel,
47
47
  ForecastData,
48
+ ForecastDataModel,
49
+ GeoLocationData,
50
+ GeoLocationDataModel,
48
51
  LocationData,
52
+ LocationDataModel,
49
53
  NightlyConditionsData,
50
- UpTonightDSOData,
54
+ NightlyConditionsDataModel,
55
+ TimeData,
56
+ TimeDataModel,
51
57
  UpTonightBodiesData,
58
+ UpTonightBodiesDataModel,
52
59
  UpTonightCometsData,
60
+ UpTonightCometsDataModel,
61
+ UpTonightDSOData,
62
+ UpTonightDSODataModel,
53
63
  )
54
64
  from pyastroweatherio.errors import RequestError
55
65
  from pyastroweatherio.helper_functions import (
@@ -57,20 +67,6 @@ from pyastroweatherio.helper_functions import (
57
67
  AtmosphericRoutines,
58
68
  ConversionFunctions,
59
69
  )
60
- from pyastroweatherio.models import (
61
- AtmosphereDataModel,
62
- ConditionDataModel,
63
- ForecastDataModel,
64
- GeoLocationDataModel,
65
- LocationDataModel,
66
- TimeDataModel,
67
- NightlyConditionsDataModel,
68
- UpTonightDSODataModel,
69
- UpTonightBodiesDataModel,
70
- UpTonightCometsDataModel,
71
- )
72
-
73
- from pprint import pprint as pp
74
70
 
75
71
  _LOGGER = logging.getLogger(__name__)
76
72
  _NOT_AVAILABLE = -9999
@@ -174,8 +170,8 @@ class AstroWeather:
174
170
  timezone_info,
175
171
  ) -> GeoLocationData | None:
176
172
 
177
- geolocation = GeoLocationData(
178
- data={
173
+ geolocation = GeoLocationDataModel(
174
+ {
179
175
  "latitude": latitude,
180
176
  "longitude": longitude,
181
177
  "elevation": elevation,
@@ -184,9 +180,8 @@ class AstroWeather:
184
180
  )
185
181
 
186
182
  try:
187
- GeoLocationDataModel.validate(geolocation)
188
- return geolocation
189
- except ValidationError as ve:
183
+ return GeoLocationData(data=geolocation)
184
+ except TypeError as ve:
190
185
  _LOGGER.error(f"Failed to parse geo location data: {geolocation}")
191
186
  _LOGGER.error(ve)
192
187
  return None
@@ -233,8 +228,8 @@ class AstroWeather:
233
228
  else:
234
229
  lifted_index = LIFTED_INDEX_7TIMER_MAPPING[details_seventimer["lifted_index"]]
235
230
 
236
- atmosphere = AtmosphereData(
237
- data={
231
+ atmosphere = AtmosphereDataModel(
232
+ {
238
233
  "seeing": seeing,
239
234
  "transparency": transparency,
240
235
  "lifted_index": lifted_index,
@@ -242,9 +237,8 @@ class AstroWeather:
242
237
  )
243
238
 
244
239
  try:
245
- AtmosphereDataModel.validate(atmosphere)
246
- return atmosphere
247
- except ValidationError as ve:
240
+ return AtmosphereData(data=atmosphere)
241
+ except TypeError as ve:
248
242
  _LOGGER.error(f"Failed to parse atmosphere data: {atmosphere}")
249
243
  _LOGGER.error(ve)
250
244
  return None
@@ -259,8 +253,8 @@ class AstroWeather:
259
253
  lifted_index,
260
254
  ) -> ConditionData | None:
261
255
 
262
- condition = ConditionData(
263
- data={
256
+ condition = ConditionDataModel(
257
+ {
264
258
  "cloudcover": details_metno.get("cloud_area_fraction"),
265
259
  "cloud_area_fraction": details_metno.get("cloud_area_fraction"),
266
260
  "cloud_area_fraction_high": details_metno.get("cloud_area_fraction_high"),
@@ -292,9 +286,8 @@ class AstroWeather:
292
286
  )
293
287
 
294
288
  try:
295
- ConditionDataModel.validate(condition)
296
- return condition
297
- except ValidationError as ve:
289
+ return ConditionData(data=condition)
290
+ except TypeError as ve:
298
291
  _LOGGER.error(f"Failed to parse condition data: {condition}")
299
292
  _LOGGER.error(ve)
300
293
  return None
@@ -435,8 +428,8 @@ class AstroWeather:
435
428
 
436
429
  atmosphere_data = await self._get_atmosphere(details_seventimer, details_metno)
437
430
 
438
- time_data = TimeData(
439
- data={
431
+ time_data = TimeDataModel(
432
+ {
440
433
  # seventimer_init is "init" of 7timer astro data
441
434
  "seventimer_init": seventimer_init,
442
435
  # seventimer_timepoint is "timepoint" of 7timer astro data and defines the data for init + timepoint
@@ -448,13 +441,13 @@ class AstroWeather:
448
441
  )
449
442
 
450
443
  try:
451
- TimeDataModel.validate(time_data)
452
- except ValidationError as ve:
444
+ time_data = TimeData(data=time_data)
445
+ except TypeError as ve:
453
446
  _LOGGER.error(f"Failed to parse location data model data: {time_data}")
454
447
  _LOGGER.error(ve)
455
448
 
456
- item = LocationData(
457
- data={
449
+ item = LocationDataModel(
450
+ {
458
451
  # Time data
459
452
  "time_data": time_data,
460
453
  # Time shift to UTC
@@ -486,9 +479,8 @@ class AstroWeather:
486
479
  )
487
480
 
488
481
  try:
489
- LocationDataModel.validate(item)
490
- items.append(item)
491
- except ValidationError as ve:
482
+ items.append(LocationData(data=item))
483
+ except TypeError as ve:
492
484
  _LOGGER.error(f"Failed to parse location data model data: {item}")
493
485
  _LOGGER.error(ve)
494
486
 
@@ -566,8 +558,8 @@ class AstroWeather:
566
558
 
567
559
  atmosphere_data = await self._get_atmosphere(details_seventimer, details_metno)
568
560
 
569
- time_data = TimeData(
570
- data={
561
+ td = TimeDataModel(
562
+ {
571
563
  # seventimer_init is "init" of 7timer astro data
572
564
  "seventimer_init": init_ts,
573
565
  # seventimer_timepoint is "timepoint" of 7timer astro data and defines the data for init + timepoint
@@ -579,13 +571,13 @@ class AstroWeather:
579
571
  )
580
572
 
581
573
  try:
582
- TimeDataModel.validate(time_data)
583
- except ValidationError as ve:
574
+ time_data = TimeData(data=td)
575
+ except TypeError as ve:
584
576
  _LOGGER.error(f"Failed to parse location data model data: {time_data}")
585
577
  _LOGGER.error(ve)
586
578
 
587
- item = ForecastData(
588
- data={
579
+ item = ForecastDataModel(
580
+ {
589
581
  # Time data
590
582
  "time_data": time_data,
591
583
  "hour": datetime.strptime(
@@ -603,9 +595,9 @@ class AstroWeather:
603
595
  )
604
596
 
605
597
  try:
606
- ForecastDataModel.validate(item)
607
- items.append(item)
608
- except ValidationError as ve:
598
+
599
+ items.append(ForecastData(data=item))
600
+ except TypeError as ve:
609
601
  _LOGGER.error(f"Failed to parse forecast data: {item}")
610
602
  _LOGGER.error(ve)
611
603
 
@@ -704,8 +696,8 @@ class AstroWeather:
704
696
  )
705
697
 
706
698
  if details_forecast.forecast_time.hour == sun_next_rising.hour or index >= (forecast_data_len - 1):
707
- item = NightlyConditionsData(
708
- data={
699
+ item = NightlyConditionsDataModel(
700
+ {
709
701
  "seventimer_init": init_ts,
710
702
  "dayname": forecast_dayname,
711
703
  "hour": start_forecast_hour,
@@ -716,8 +708,8 @@ class AstroWeather:
716
708
  )
717
709
 
718
710
  try:
719
- NightlyConditionsDataModel.validate(item)
720
- except ValidationError as ve:
711
+ item = NightlyConditionsData(data=item)
712
+ except TypeError as ve:
721
713
  _LOGGER.error(f"Failed to parse nightly conditions model data: {item}")
722
714
  _LOGGER.error(ve)
723
715
 
@@ -783,8 +775,8 @@ class AstroWeather:
783
775
  else:
784
776
  dso_meridian_antitransit_utc = ""
785
777
 
786
- item = UpTonightDSOData(
787
- data={
778
+ item = UpTonightDSODataModel(
779
+ {
788
780
  "id": dso_id.get(str(row), ""),
789
781
  "target_name": dso_target_name.get(str(row), ""),
790
782
  "type": dso_type.get(str(row), ""),
@@ -797,9 +789,9 @@ class AstroWeather:
797
789
  }
798
790
  )
799
791
  try:
800
- UpTonightDSODataModel.validate(item)
801
- items.append(item)
802
- except ValidationError as ve:
792
+
793
+ items.append(UpTonightDSOData(data=item))
794
+ except TypeError as ve:
803
795
  _LOGGER.error(f"Failed to parse deep sky object data: {item}")
804
796
  _LOGGER.error(ve)
805
797
 
@@ -839,8 +831,8 @@ class AstroWeather:
839
831
  else:
840
832
  body_meridian_transit_utc = ""
841
833
 
842
- item = UpTonightBodiesData(
843
- data={
834
+ item = UpTonightBodiesDataModel(
835
+ {
844
836
  "target_name": body_target_name.get(str(row), ""),
845
837
  "max_altitude": body_max_altitude.get(str(row), ""),
846
838
  "azimuth": body_azimuth.get(str(row), ""),
@@ -851,9 +843,9 @@ class AstroWeather:
851
843
  }
852
844
  )
853
845
  try:
854
- UpTonightBodiesDataModel.validate(item)
855
- items.append(item)
856
- except ValidationError as ve:
846
+
847
+ items.append(UpTonightBodiesData(data=item))
848
+ except TypeError as ve:
857
849
  _LOGGER.error(f"Failed to parse bodies data: {item}")
858
850
  _LOGGER.error(ve)
859
851
 
@@ -891,8 +883,8 @@ class AstroWeather:
891
883
  - timedelta(seconds=await self._astro_routines.time_shift())
892
884
  ).replace(tzinfo=UTC)
893
885
 
894
- item = UpTonightCometsData(
895
- data={
886
+ item = UpTonightCometsDataModel(
887
+ {
896
888
  "designation": comet_target_name.get(str(row), ""),
897
889
  "distance_au_earth": distance_au_earth.get(str(row), ""),
898
890
  "distance_au_sun": distance_au_sun.get(str(row), ""),
@@ -905,9 +897,9 @@ class AstroWeather:
905
897
  }
906
898
  )
907
899
  try:
908
- UpTonightCometsDataModel.validate(item)
909
- items.append(item)
910
- except ValidationError as ve:
900
+
901
+ items.append(UpTonightCometsData(data=item))
902
+ except TypeError as ve:
911
903
  _LOGGER.error(f"Failed to parse comets data: {item}")
912
904
  _LOGGER.error(ve)
913
905