Cached weather data.
authorScott Gasch <[email protected]>
Sun, 26 Sep 2021 15:28:01 +0000 (08:28 -0700)
committerScott Gasch <[email protected]>
Sun, 26 Sep 2021 15:28:01 +0000 (08:28 -0700)
cached/weather_data.py
cached/weather_forecast.py

index 4c464483386b103c4a3618174e22a3e3f0b3e433..78f7ade4b571a01436cf79876fc1b540d5ee52b3 100644 (file)
@@ -3,6 +3,7 @@
 from dataclasses import dataclass
 import datetime
 import json
+import os
 from typing import List
 import urllib.request
 
@@ -19,7 +20,7 @@ cfg = config.add_commandline_args(
 cfg.add_argument(
     '--weather_data_cachefile',
     type=str,
-    default='/home/scott/.weather_summary_cache',
+    default=f'{os.environ["HOME"]}/.weather_summary_cache',
     metavar='FILENAME',
     help='File in which to cache weather data'
 )
index ce4725d64a6c43699ab702b85d60d1f070366cf5..4be53c8367c5d26fbbf1d29abe987ae0ae4ad85d 100644 (file)
@@ -3,6 +3,7 @@
 from dataclasses import dataclass
 import datetime
 import logging
+import os
 import urllib.request
 
 import astral  # type: ignore
@@ -26,7 +27,7 @@ cfg = config.add_commandline_args(
 cfg.add_argument(
     '--weather_forecast_cachefile',
     type=str,
-    default='/home/scott/.weather_forecast_cache',
+    default=f'{os.environ["HOME"]}/.weather_forecast_cache',
     metavar='FILENAME',
     help='File in which to cache weather data'
 )
@@ -79,6 +80,7 @@ class CachedDetailedWeatherForecast(object):
         forecast = soup.find(id='detailed-forecast-body')
         parser = dp.DateParser()
 
+        said_temp = False
         last_dt = now
         dt = now
         for (day, txt) in zip(
@@ -100,8 +102,9 @@ class CachedDetailedWeatherForecast(object):
             sunrise = s['sunrise']
             sunset = s['sunset']
 
-            if dt.date == now.date:
+            if dt.date == now.date and not said_temp:
                 blurb = f'{day.get_text()}: The current outside tempterature is {current_temp}.  ' + txt.get_text()
+                said_temp = True
             else:
                 blurb = f'{day.get_text()}: {txt.get_text()}'
             blurb = text_utils.wrap_string(blurb, 80)