import json
import logging
import os
-from typing import List
+from typing import Any, List
import urllib.request
+from overrides import overrides
+
import argparse_utils
import config
import datetime_utils
cfg.add_argument(
'--weather_data_cachefile',
type=str,
- default=f'{os.environ["HOME"]}/.weather_summary_cache',
+ default=f'{os.environ["HOME"]}/cache/.weather_summary_cache',
metavar='FILENAME',
help='File in which to cache weather data'
)
):
self.weather_data[today].high = high
continue
- most_common_condition = list_utils.most_common_item(conditions[dt])
+ most_common_condition = list_utils.most_common(conditions[dt])
icon = icon_by_condition.get(most_common_condition, '?')
if dt == now.date() and now.hour > 18 and condition == 'Clear':
icon = '🌙'
)
@classmethod
- def load(cls):
+ @overrides
+ def load(cls) -> Any:
if persistent.was_file_written_within_n_seconds(
config.config['weather_data_cachefile'],
config.config['weather_data_stalest_acceptable'].total_seconds(),
return cls(weather_data)
return None
- def save(self):
+ @overrides
+ def save(self) -> bool:
import pickle
with open(config.config['weather_data_cachefile'], 'wb') as wf:
pickle.dump(
wf,
pickle.HIGHEST_PROTOCOL,
)
+ return True