Compare commits

..

No commits in common. "bcdc8e69b4538ce7cfc751ff24aab46e1eed3603" and "6a82e3d8f4555fa3f8b879df3e57b1a691b30c05" have entirely different histories.

View file

@ -10,7 +10,6 @@ from datetime import date, datetime, timedelta
import dateutil.rrule
import dateutil.tz
import holidays # type: ignore
import isodate
import lxml
import pytz
import yaml
@ -23,6 +22,7 @@ from . import (
economist,
fx,
gwr,
markets,
stock_market,
subscription,
sun,
@ -144,22 +144,10 @@ def get_yaml_event_date_field(item: dict[str, str]) -> str:
)
def get_yaml_event_end_date_field(item: dict[str, str]) -> str:
"""Event date field name."""
return (
"end_date"
if item["name"] == "travel_insurance"
else ("start_date" if "start_date" in item else "date")
)
def read_events_yaml(data_dir: str, start: date, end: date) -> list[Event]:
"""Read eventes from YAML file."""
events: list[Event] = []
for item in yaml.safe_load(open(os.path.join(data_dir, "events.yaml"))):
duration = (
isodate.parse_duration(item["duration"]) if "duration" in item else None
)
dates = (
dates_from_rrule(item["rrule"], start, end)
if "rrule" in item
@ -170,13 +158,7 @@ def read_events_yaml(data_dir: str, start: date, end: date) -> list[Event]:
name=item["name"],
date=dt,
end_date=(
dt + duration
if duration
else (
item.get("end_date")
if item["name"] != "travel_insurance"
else None
)
item.get("end_date") if item["name"] != "travel_insurance" else None
),
title=item.get("title"),
url=item.get("url"),
@ -235,7 +217,13 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
minus_365, plus_365, "us_clock_change", "America/New_York"
),
"mothers_day": uk_holiday.get_mothers_day(today),
# "fathers_day": uk_holiday.get_fathers_day(today),
"gwr_advance_tickets": gwr_advance_tickets,
"market": (
markets.windmill_hill(last_year, next_year)
+ markets.tobacco_factory(last_year, next_year)
+ markets.nailsea_farmers(last_year, next_year)
),
"rockets": rockets,
}