From 7456f7232534ddbb206743dd0760a6e8d00da52a Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 8 Jan 2024 15:43:31 +0000 Subject: [PATCH] Update Bristol bins from cron to save time Closes: #96 --- update_bristol_bins.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 update_bristol_bins.py diff --git a/update_bristol_bins.py b/update_bristol_bins.py new file mode 100755 index 0000000..9b489e9 --- /dev/null +++ b/update_bristol_bins.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 +"""Update waste schedule from Bristol City Council.""" + +import asyncio +import sys +from datetime import date +from time import time + +import agenda.types +import agenda.waste_schedule + +config = __import__("config.default", fromlist=[""]) + + +async def bristol_waste_collection_events() -> list[agenda.types.Event]: + """Waste colllection events.""" + uprn = "358335" + + return await agenda.waste_schedule.get_bristol_gov_uk( + date.today(), config.DATA_DIR, uprn, refresh=True + ) + + +today = date.today() +t0 = time() +events = asyncio.run(bristol_waste_collection_events()) +time_taken = time() - t0 +if sys.stdin.isatty(): + for event in events: + print(event) + print(f"took {time_taken:.1f} seconds")