agenda/update_bank_holiday_list.py

27 lines
640 B
Python
Executable file

#!/usr/bin/python3
"""Update cached copy of UK Bank holidays."""
import asyncio
import sys
from time import time
import agenda.types
import agenda.uk_holiday
from agenda.types import StrDict
config = __import__("config.default", fromlist=[""])
async def get_bank_holidays() -> list[StrDict]:
"""Call space launch API and cache results."""
return await agenda.uk_holiday.get_holiday_list(config.DATA_DIR)
t0 = time()
events: list[StrDict] = asyncio.run(get_bank_holidays())
time_taken = time() - t0
if not sys.stdin.isatty():
sys.exit(0)
print(len(events), "bank holidays in list")
print(f"took {time_taken:.1f} seconds")