Reorganise code
This commit is contained in:
parent
bcdc8e69b4
commit
e5e0fc624b
|
@ -36,8 +36,6 @@ from .types import Event
|
||||||
|
|
||||||
here = dateutil.tz.tzlocal()
|
here = dateutil.tz.tzlocal()
|
||||||
|
|
||||||
next_us_presidential_election = date(2024, 11, 5)
|
|
||||||
|
|
||||||
# deadline to file tax return
|
# deadline to file tax return
|
||||||
# credit card expiry dates
|
# credit card expiry dates
|
||||||
# morzine ski lifts
|
# morzine ski lifts
|
||||||
|
@ -225,33 +223,22 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
|
||||||
reply = {
|
reply = {
|
||||||
"now": now,
|
"now": now,
|
||||||
"gbpusd": gbpusd,
|
"gbpusd": gbpusd,
|
||||||
"economist": economist.publication_dates(last_year, next_year),
|
|
||||||
"next_us_presidential_election": next_us_presidential_election,
|
|
||||||
"stock_markets": stock_market.open_and_close(),
|
"stock_markets": stock_market.open_and_close(),
|
||||||
"uk_clock_change": timezone_transition(
|
|
||||||
minus_365, plus_365, "uk_clock_change", "Europe/London"
|
|
||||||
),
|
|
||||||
"us_clock_change": timezone_transition(
|
|
||||||
minus_365, plus_365, "us_clock_change", "America/New_York"
|
|
||||||
),
|
|
||||||
"mothers_day": uk_holiday.get_mothers_day(today),
|
|
||||||
"gwr_advance_tickets": gwr_advance_tickets,
|
|
||||||
"rockets": rockets,
|
"rockets": rockets,
|
||||||
}
|
}
|
||||||
|
|
||||||
skip = {"now", "gbpusd", "rockets", "stock_markets"}
|
|
||||||
events: list[Event] = []
|
|
||||||
for key, value in reply.items():
|
|
||||||
if key in skip:
|
|
||||||
continue
|
|
||||||
if isinstance(value, list):
|
|
||||||
events += value
|
|
||||||
else:
|
|
||||||
assert isinstance(value, date)
|
|
||||||
event = Event(name=key, date=value)
|
|
||||||
events.append(event)
|
|
||||||
|
|
||||||
my_data = config["data"]["personal-data"]
|
my_data = config["data"]["personal-data"]
|
||||||
|
events = (
|
||||||
|
[
|
||||||
|
Event(name="gwr_advance_tickets", date=gwr_advance_tickets),
|
||||||
|
Event(name="mothers_day", date=uk_holiday.get_mothers_day(today)),
|
||||||
|
]
|
||||||
|
+ timezone_transition(minus_365, plus_365, "uk_clock_change", "Europe/London")
|
||||||
|
+ timezone_transition(
|
||||||
|
minus_365, plus_365, "us_clock_change", "America/New_York"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
events += combine_holidays(bank_holiday + get_us_holidays(last_year, next_year))
|
events += combine_holidays(bank_holiday + get_us_holidays(last_year, next_year))
|
||||||
events += birthday.get_birthdays(last_year, os.path.join(my_data, "entities.yaml"))
|
events += birthday.get_birthdays(last_year, os.path.join(my_data, "entities.yaml"))
|
||||||
events += accommodation.get_events(os.path.join(my_data, "accommodation.yaml"))
|
events += accommodation.get_events(os.path.join(my_data, "accommodation.yaml"))
|
||||||
|
@ -260,6 +247,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
|
||||||
events += backwell_bins + bristol_bins
|
events += backwell_bins + bristol_bins
|
||||||
events += read_events_yaml(my_data, last_year, next_year)
|
events += read_events_yaml(my_data, last_year, next_year)
|
||||||
events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml"))
|
events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml"))
|
||||||
|
events += economist.publication_dates(last_week, next_year)
|
||||||
|
|
||||||
events.sort(key=operator.attrgetter("as_datetime"))
|
events.sort(key=operator.attrgetter("as_datetime"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue