weathergrabber 0.0.6__py3-none-any.whl → 0.0.7a2__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.
@@ -0,0 +1,7 @@
1
+ """weathergrabber - Python interface and CLI for weather.com data."""
2
+
3
+ from .core import main
4
+ from .cli import main_cli
5
+
6
+ __all__ = ["main", "main_cli"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ """weathergrabber CLI entry point."""
2
+ from .cli import main_cli
3
+ if __name__ == "__main__":
4
+ main_cli()
weathergrabber/cli.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import argparse
2
2
  import os
3
- from .core import main
3
+ from weathergrabber import main
4
4
 
5
5
  def main_cli():
6
6
  ## Get current locale, or use the default one
@@ -30,9 +30,12 @@ class Timestamp:
30
30
  @classmethod
31
31
  def from_string(cls, text) -> "Timestamp":
32
32
  # "As of 4:23 pm GMT-03:00",
33
+ # "As of 4:23 pm EDT",
33
34
  # "As of 16:37 GMT-03:00",
34
35
  # "Até 16:38 GMT-03:00"
35
- pattern = re.compile(r'(\d{1,2}:\d{2}(?: ?[ap]m)?)\s+(GMT[+-]\d{2}:\d{2})')
36
+ # "Até 20:44 EDT"
37
+ # Simplified: just match time (with optional am/pm) and timezone (GMT offset or abbreviation)
38
+ pattern = re.compile(r'(\d{1,2}:\d{2}(?: ?[ap]m)?)\s*((?:GMT[+-]\d{2}:\d{2})|[A-Z]{2,4})', re.IGNORECASE)
36
39
  match = pattern.search(text)
37
40
  if match:
38
41
  time, gmt = match.groups()
@@ -7,6 +7,7 @@ class WeatherIconEnum(Enum):
7
7
  CLOUDY_FOGGY_DAY = ('cloudy-foggy-day', chr(0xF013), '🌥️')
8
8
  CLOUDY_FOGGY_NIGHT = ('cloudy-foggy-night', chr(0xF013), '🌥️')
9
9
  DAY = ('day', '\uf185', '🌞')
10
+ DRIZZLE = ('drizzle', '\uf0e9', '🌦️')
10
11
  FEEL = ('feel', '\uf2c9', '🥵')
11
12
  FOGGY = ('foggy', '\uf74e', '🌫️')
12
13
  HUMIDITY = ('humidity', '\uf043', '💧')
@@ -22,6 +23,8 @@ class WeatherIconEnum(Enum):
22
23
  RAINY_NIGHT = ('rainy-night', chr(0x1F326), '🌧️')
23
24
  SCATTERED_SHOWERS_DAY = ('scattered-showers-day', chr(0x1F326), '🌦️')
24
25
  SCATTERED_SHOWERS_NIGHT = ('scattered-showers-night', chr(0x1F326), '🌦️')
26
+ SCATTERED_THUNDERSTORMS_DAY = ('scattered-thunderstorms-day', chr(0x26C8), '⛈️')
27
+ SCATTERED_THUNDERSTORMS_NIGHT = ('scattered-thunderstorms-night', chr(0x26C8), '⛈️')
25
28
  SEVERE = ('severe', '\ue317', '🌩️')
26
29
  SHOWERS = ('showers', '\u26c6', '🌧️')
27
30
  SNOW = ('snow', '\uf2dc', '❄️')
@@ -30,9 +33,10 @@ class WeatherIconEnum(Enum):
30
33
  SUNNY = ('sunny', chr(0xF0599), '☀️')
31
34
  SUNRISE = ('sunrise', '\ue34c', '🌅')
32
35
  SUNSET = ('sunset', '\ue34d', '🌇')
33
- THUNDERSTORM = ('thunderstorm', '\uf0e7', '⛈️')
36
+ THUNDERSTORMS = ('thunderstorms', '\uf0e7', '⛈️')
34
37
  VISIBILITY = ('visibility', '\uf06e', '👁️')
35
38
  WIND = ('wind', chr(0xf059d), '🌪️')
39
+ WINDY = ('windy', chr(0xf059d), '🌪️')
36
40
 
37
41
  def __init__(self, name: str, fa_icon: str, emoji_icon: str):
38
42
  self._name = name
@@ -56,4 +60,4 @@ class WeatherIconEnum(Enum):
56
60
  for item in WeatherIconEnum:
57
61
  if item._name == name:
58
62
  return item
59
- return None
63
+ raise ValueError(f'WeatherIconEnum: No icon found for name "{name}"')
@@ -59,11 +59,13 @@ class UseCase:
59
59
  try:
60
60
  hourly_predictions = self.extract_hourly_forecast_service.execute(weather_data)
61
61
  except ValueError:
62
+ self.logger.warning("Falling back to old style hourly forecast extraction")
62
63
  hourly_predictions = self.extract_hourly_forecast_oldstyle_service.execute(weather_data)
63
64
 
64
65
  try:
65
66
  daily_predictions = self.extract_daily_forecast_service.execute(weather_data)
66
67
  except ValueError:
68
+ self.logger.warning("Falling back to old style daily forecast extraction")
67
69
  daily_predictions = self.extract_daily_forecast_oldstyle_service.execute(weather_data)
68
70
 
69
71
  forecast = Forecast(
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weathergrabber
3
- Version: 0.0.6
3
+ Version: 0.0.7a2
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
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: homepage, https://github.com/cjuniorfox/weather
8
8
  Project-URL: repository, https://github.com/cjuniorfox/weather
9
9
  Requires-Python: >=3.12
@@ -140,7 +140,21 @@ weathergrabber [location_name] [options]
140
140
  Or as a Python module:
141
141
 
142
142
  ```sh
143
- python -m weathergrabber.cli [location_name] [options]
143
+ python -m weathergrabber [location_name] [options]
144
+ ```
145
+
146
+ ### Importing as a Python module
147
+
148
+ You can also use the main API or CLI entry point in your own Python code:
149
+
150
+ ```python
151
+ import weathergrabber
152
+
153
+ # Call the main API
154
+ weathergrabber.main(log_level="INFO", location_name="London", location_id="", lang="en-GB", output="console", keep_open=False, icons="emoji")
155
+
156
+ # Or run the CLI programmatically
157
+ weathergrabber.main_cli()
144
158
  ```
145
159
 
146
160
  ### Arguments
@@ -172,7 +186,7 @@ weathergrabber "Paris" -o waybar -i fa
172
186
  Or as a Python module:
173
187
 
174
188
  ```sh
175
- python -m weathergrabber.cli "London" --output console --lang en-GB
176
- python -m weathergrabber.cli --location-id 1234567890abcdef... --output json
177
- python -m weathergrabber.cli "Paris" -o waybar -i fa
189
+ python -m weathergrabber "London" --output console --lang en-GB
190
+ python -m weathergrabber --location-id 1234567890abcdef... --output json
191
+ python -m weathergrabber "Paris" -o waybar -i fa
178
192
  ```
@@ -1,5 +1,6 @@
1
- weathergrabber/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- weathergrabber/cli.py,sha256=QzBqR4N70W1bSfrSngQAL79vfY8_h8U8s5-LRzzesKo,1970
1
+ weathergrabber/__init__.py,sha256=ZIzvBQBCry-C_ieN_oSQpTYfFeUOOi-ymjYNNqje1uw,173
2
+ weathergrabber/__main__.py,sha256=K10wQv3-LSRD_FRLHWphdSs3OAcuzIb4sQaKmj7Fql0,105
3
+ weathergrabber/cli.py,sha256=YOWoVLfwktgqK1bp89GUKkAEKyMM4DaNL4akBi6xVVk,1979
3
4
  weathergrabber/core.py,sha256=TiZ2utmYKf9lkIXWv8YBfSdiHZXJZXuHS8B-dBDvevw,1138
4
5
  weathergrabber/weathergrabber_application.py,sha256=2JfZAR94En3rmGrYKWRKxdRXmK_ikhJdgrGotFjtDys,3987
5
6
  weathergrabber/adapter/client/weather_api.py,sha256=9S7JmXaAVvvPY60dz6rC3lx7X68BcqyvNzvSVM1-af8,963
@@ -23,10 +24,10 @@ weathergrabber/domain/precipitation.py,sha256=eXrpwMOsEJWGqV4bEBhN9niWYXalgdZRLG
23
24
  weathergrabber/domain/search.py,sha256=j3BzskyPl0hDWV02XTOC4tJonV5RHxr5Rop_rYMKUtA,387
24
25
  weathergrabber/domain/sunrise_sunset.py,sha256=wNTk01NIuLbQ7gN_giAFv4f3FaRx9khul-mj19g57vE,1207
25
26
  weathergrabber/domain/temperature_hight_low.py,sha256=PQOJ5uDtfMRBR5yMxXA46xuorJC08jva2C0-WAV5yxs,909
26
- weathergrabber/domain/timestamp.py,sha256=tbUdTiWUf1mKhVq9SESeFGlu_sZ2FdmQCb1gr7u9I0c,1032
27
+ weathergrabber/domain/timestamp.py,sha256=Bk6f8Tx0-yNitYmEKIWHnqh_ALDwxEHrhoCRSrfvYTU,1222
27
28
  weathergrabber/domain/today_details.py,sha256=EUlV7xerYw5QhEsBfvO5m6-9Ghm4nPkXJz9zCmSYTbA,2398
28
29
  weathergrabber/domain/uv_index.py,sha256=lNdk38Jq-A9msuzOLjIKrZIHUc2C9J8V4MA7HU3s1ZM,1420
29
- weathergrabber/domain/weather_icon_enum.py,sha256=1nfWZmk8MCki5Dit-Exblpm0A1InxDldaoHxSgPfxP4,2360
30
+ weathergrabber/domain/weather_icon_enum.py,sha256=tAaN6w9g3ZcwB5KLN5ivjO7Hp_C1tBynSkyxRQaChTI,2696
30
31
  weathergrabber/domain/wind.py,sha256=wTDz3X1rYsnw_eNoDi1miwaomxwhiJkY_q6xrdZtLak,789
31
32
  weathergrabber/domain/adapter/icon_enum.py,sha256=YxGYS5vBRV2AiAfeuPOdqaQOHixAssiMbOzQnTmdSBg,84
32
33
  weathergrabber/domain/adapter/output_enum.py,sha256=61iR10ppY8DNALPKV-vLnDQni5HxEzpoRNZbdBdRygk,117
@@ -62,10 +63,10 @@ weathergrabber/service/extract_temperature_service.py,sha256=46nRO3Izj1QmG4BNTh8
62
63
  weathergrabber/service/extract_today_details_service.py,sha256=QAwF7EzVaL1STGNDyxve9r7oQTjvNKhYQ53d_68lbKA,4126
63
64
  weathergrabber/service/read_weather_service.py,sha256=7_B8E9IN1KCwOhpuS5PfWazI1sCrDyYrZhkV2R38bhc,649
64
65
  weathergrabber/service/search_location_service.py,sha256=tZmVgO45hjwoa4cl5bKPjMBmYlGxJiH_I9Ymb5pwEwU,1422
65
- weathergrabber/usecase/use_case.py,sha256=wmNmJSiy0t00-KaxQqSryiu0keX0kI4PcLI2hBBHT_0,4460
66
- weathergrabber-0.0.6.dist-info/licenses/LICENSE,sha256=X5JFljoqN43yFwpMLudQ9rtty4K_FeZfnz3v8Yhw23Q,1067
67
- weathergrabber-0.0.6.dist-info/METADATA,sha256=4CewXY3qa4NaKuSZoX6GvC8oDWzrUJO9MPGERQVsqYk,5440
68
- weathergrabber-0.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
69
- weathergrabber-0.0.6.dist-info/entry_points.txt,sha256=m2P9a4mrJDTzuNaiTU438NA60GxCfaw7VKvruWw43N8,63
70
- weathergrabber-0.0.6.dist-info/top_level.txt,sha256=P3NMDJJYRIvQujf994Vb4gZrobkKWkL2gh3NF_ajQWM,15
71
- weathergrabber-0.0.6.dist-info/RECORD,,
66
+ weathergrabber/usecase/use_case.py,sha256=K2RBIEi7S0ixAM6oDKmCPYkuJ9azatxle8zAqX0xM1E,4635
67
+ weathergrabber-0.0.7a2.dist-info/licenses/LICENSE,sha256=X5JFljoqN43yFwpMLudQ9rtty4K_FeZfnz3v8Yhw23Q,1067
68
+ weathergrabber-0.0.7a2.dist-info/METADATA,sha256=J2-5LBiUVjhvV1-cwVN4v_0mFQGzunE3w4I37mRug2o,5807
69
+ weathergrabber-0.0.7a2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
70
+ weathergrabber-0.0.7a2.dist-info/entry_points.txt,sha256=m2P9a4mrJDTzuNaiTU438NA60GxCfaw7VKvruWw43N8,63
71
+ weathergrabber-0.0.7a2.dist-info/top_level.txt,sha256=P3NMDJJYRIvQujf994Vb4gZrobkKWkL2gh3NF_ajQWM,15
72
+ weathergrabber-0.0.7a2.dist-info/RECORD,,