agenda/update_bristol_bins.py

32 lines
737 B
Python
Executable file

#!/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")