summaryrefslogtreecommitdiff
path: root/cached/weather_forecast.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-09-26 08:28:01 -0700
committerScott Gasch <[email protected]>2021-09-26 08:28:01 -0700
commita8da0e2eca96cedaf582bc41ab82ec4ff87e443c (patch)
tree57b3733784ea129697926e794a9a99a77368b3e7 /cached/weather_forecast.py
parentd2730e42f1160d45ab6c7780987b16ae83c616f6 (diff)
Cached weather data.
Diffstat (limited to 'cached/weather_forecast.py')
-rw-r--r--cached/weather_forecast.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/cached/weather_forecast.py b/cached/weather_forecast.py
index ce4725d..4be53c8 100644
--- a/cached/weather_forecast.py
+++ b/cached/weather_forecast.py
@@ -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)