More support for offline_mode

This commit is contained in:
Edward Betts 2024-11-04 09:59:55 +00:00
parent 3c3939c525
commit 67b1adf956
4 changed files with 23 additions and 13 deletions

View file

@ -62,20 +62,21 @@ def timezone_transition(
async def n_somerset_waste_collection_events(
data_dir: str, postcode: str, uprn: str
data_dir: str, postcode: str, uprn: str, force_cache: bool = False
) -> list[Event]:
"""Waste colllection events."""
html = await n_somerset_waste.get_html(data_dir, postcode, uprn)
html = await n_somerset_waste.get_html(data_dir, postcode, uprn, force_cache)
root = lxml.html.fromstring(html)
events = n_somerset_waste.parse(root)
return events
async def bristol_waste_collection_events(
data_dir: str, start_date: date, uprn: str
data_dir: str, start_date: date, uprn: str, force_cache: bool = False
) -> list[Event]:
"""Waste colllection events."""
return await bristol_waste.get(start_date, data_dir, uprn)
cache = "force" if force_cache else "recent"
return await bristol_waste.get(start_date, data_dir, uprn, cache)
def find_events_during_stay(
@ -193,6 +194,7 @@ async def get_data(now: datetime, config: flask.config.Config) -> AgendaData:
data_dir,
config["BACKWELL_POSTCODE"],
config["BACKWELL_UPRN"],
offline_mode,
),
time_function(
"bristol_bins",
@ -200,6 +202,7 @@ async def get_data(now: datetime, config: flask.config.Config) -> AgendaData:
data_dir,
today,
config["BRISTOL_UPRN"],
offline_mode,
),
)
rockets = thespacedevs.read_cached_launches(rocket_dir)