weathergrabber 0.0.10__py3-none-any.whl → 0.0.11__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.
@@ -4,7 +4,7 @@ from .core import main
4
4
  from .cli import main_cli
5
5
 
6
6
  __all__ = ["main", "main_cli"]
7
- __version__ = "0.0.10"
7
+ __version__ = "0.0.11"
8
8
 
9
9
  def get_version():
10
10
  return __version__
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ import json
2
3
  from pyquery import PyQuery
3
4
  from weathergrabber.domain.entities.weather_icon_enum import WeatherIconEnum
4
5
  from weathergrabber.domain.entities.city_location import CityLocation
@@ -16,12 +17,12 @@ class ExtractCurrentConditionsService:
16
17
 
17
18
  data = PyQuery(weather_data('div[data-testid="CurrentConditionsContainer"]'))
18
19
 
19
- city_location_data = data.find('h1').text() #'Nova Friburgo, Rio de Janeiro, Brazil'
20
+
20
21
  timestamp_data = data.find('span[class*="timestamp"]').text() # 'As of 8:01 pm GMT-03:00'
21
22
  icon_data = data.find('svg[class*="wxIcon"]').attr('name') # 'partly-cloudy-night'
22
23
  temp_day_night = data.find('div[class*="tempHiLoValue"]').text() #'Day\xa063°\xa0•\xa0Night\xa046°'
23
24
 
24
- city_location = CityLocation.from_string(city_location_data)
25
+ city_location = self.__location(weather_data)
25
26
  timestamp = Timestamp.from_string(timestamp_data)
26
27
  temperature = data.find('span[class*="tempValue"]').text() # '48°'
27
28
  icon = WeatherIconEnum.from_name(icon_data)
@@ -39,4 +40,15 @@ class ExtractCurrentConditionsService:
39
40
 
40
41
  self.logger.debug(f"Extracted current conditions: {current_conditions}")
41
42
 
42
- return current_conditions
43
+ return current_conditions
44
+
45
+ def __location(self, weather_data: PyQuery) -> CityLocation:
46
+ location_str = weather_data.find('script[type="application/ld+json"]').contents().eq(2).text()
47
+ location_data = json.loads(location_str)
48
+ address = location_data.get("address", {})
49
+
50
+ return CityLocation(
51
+ city=address.get("addressLocality"),
52
+ state_province=address.get("addressRegion"),
53
+ country=address.get("addressCountry")
54
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weathergrabber
3
- Version: 0.0.10
3
+ Version: 0.0.11
4
4
  Summary: A grabber for weather.com data with various output formats.
5
5
  Author-email: Carlos Anselmo Mendes Junior <cjuniorfox@gmail.com>
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- weathergrabber/__init__.py,sha256=Va0sMEDstFkxITOxgjKch6t71YsUCU7gPI_1Pqu0Ngw,217
1
+ weathergrabber/__init__.py,sha256=jyad_PXvxFjRMqfok4rwKL7ULoOSuH6Cwf7SJef7XIE,217
2
2
  weathergrabber/__main__.py,sha256=yYL-jc4kVHqaYVADzjKZfmCN2mziRofsXgnzrECbGDo,68
3
3
  weathergrabber/cli.py,sha256=oGHgkWWC3wnMDuisV2XgImQpQRHWNUL_yoqNhnJT2V4,2474
4
4
  weathergrabber/core.py,sha256=ARQrqtLI-UMqJVS_T2l16dpANXLj-3bxctui2RGChpA,1618
@@ -11,7 +11,7 @@ weathergrabber/adapter/tty/statistics_tty.py,sha256=6ES5AsnCAnXl6Bp_8tyqz2_C2j92
11
11
  weathergrabber/adapter/tty/waybar_tty.py,sha256=vGErv9NshqPVzP2eh-O3govZRumUM-VXiwWRBsiRGzo,6191
12
12
  weathergrabber/application/weathergrabber_application.py,sha256=yFbo920vGLi6TreDMw6n1bZ-wy1lcBJewKurP0qKfCA,5190
13
13
  weathergrabber/application/services/extract_aqi_service.py,sha256=OIDbdXankKCn3LrxUsZkAlpf0tIgniFxuGiSDviL5UM,1099
14
- weathergrabber/application/services/extract_current_conditions_service.py,sha256=lUo7meqt5SMCuZTKEjVW-iWYpxsYksvsDOGZdHD57ac,1883
14
+ weathergrabber/application/services/extract_current_conditions_service.py,sha256=2LUkHwF8zS9xQg-TjchbdK8_4DR8KmZb80lG_57e7ig,2269
15
15
  weathergrabber/application/services/extract_daily_forecast_oldstyle_service.py,sha256=HPODxFKinUIhZrE6O-1PyaKavWtp1go4Xp5yY2KnC10,2226
16
16
  weathergrabber/application/services/extract_daily_forecast_service.py,sha256=tJ7Lvi3bEiAT1cN6byoq4nx00BG91fG16iXEhwT0MDc,2762
17
17
  weathergrabber/application/services/extract_health_activities_service.py,sha256=efrJMsVXEGTURGqOTmlbD973eF00vrX53tQqwbtytmo,1023
@@ -72,9 +72,9 @@ weathergrabber/domain/entities/today_details.py,sha256=EUlV7xerYw5QhEsBfvO5m6-9G
72
72
  weathergrabber/domain/entities/uv_index.py,sha256=7XalamfjJdVSqo4x7G4JVf_HJtrPJxO1BpbvmAfBhnw,1481
73
73
  weathergrabber/domain/entities/weather_icon_enum.py,sha256=2JqK3MJEAdbmL_jqzJUw0V31qF9EXJFq6zF1J653eRU,4165
74
74
  weathergrabber/domain/entities/wind.py,sha256=wTDz3X1rYsnw_eNoDi1miwaomxwhiJkY_q6xrdZtLak,789
75
- weathergrabber-0.0.10.dist-info/licenses/LICENSE,sha256=X5JFljoqN43yFwpMLudQ9rtty4K_FeZfnz3v8Yhw23Q,1067
76
- weathergrabber-0.0.10.dist-info/METADATA,sha256=jUtmerghLvf8yOG2qKbenOOIRrq8keEidosBoy1JERA,7474
77
- weathergrabber-0.0.10.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
78
- weathergrabber-0.0.10.dist-info/entry_points.txt,sha256=m2P9a4mrJDTzuNaiTU438NA60GxCfaw7VKvruWw43N8,63
79
- weathergrabber-0.0.10.dist-info/top_level.txt,sha256=P3NMDJJYRIvQujf994Vb4gZrobkKWkL2gh3NF_ajQWM,15
80
- weathergrabber-0.0.10.dist-info/RECORD,,
75
+ weathergrabber-0.0.11.dist-info/licenses/LICENSE,sha256=X5JFljoqN43yFwpMLudQ9rtty4K_FeZfnz3v8Yhw23Q,1067
76
+ weathergrabber-0.0.11.dist-info/METADATA,sha256=q0ESC-yO8eh_aNuDF_ASFuXg6GZPeG1ryX9qawdA-kk,7474
77
+ weathergrabber-0.0.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
78
+ weathergrabber-0.0.11.dist-info/entry_points.txt,sha256=m2P9a4mrJDTzuNaiTU438NA60GxCfaw7VKvruWw43N8,63
79
+ weathergrabber-0.0.11.dist-info/top_level.txt,sha256=P3NMDJJYRIvQujf994Vb4gZrobkKWkL2gh3NF_ajQWM,15
80
+ weathergrabber-0.0.11.dist-info/RECORD,,