parent
8cf0b982f0
commit
9ff61c3af8
3 changed files with 15 additions and 28 deletions
|
|
@ -1,13 +1,13 @@
|
|||
"""Agenda data."""
|
||||
|
||||
import asyncio
|
||||
import configparser
|
||||
import os
|
||||
import typing
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
import dateutil.rrule
|
||||
import dateutil.tz
|
||||
import flask
|
||||
import holidays # type: ignore
|
||||
import isodate # type: ignore
|
||||
import lxml
|
||||
|
|
@ -185,23 +185,11 @@ def read_events_yaml(data_dir: str, start: date, end: date) -> list[Event]:
|
|||
return events
|
||||
|
||||
|
||||
def get_config() -> configparser.ConfigParser:
|
||||
"""Load config file."""
|
||||
config_filename = os.path.join(os.path.dirname(__file__), "..", "config")
|
||||
|
||||
assert os.path.exists(config_filename)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_filename)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
|
||||
async def get_data(
|
||||
now: datetime, config: flask.config.Config
|
||||
) -> typing.Mapping[str, str | object]:
|
||||
"""Get data to display on agenda dashboard."""
|
||||
config = get_config()
|
||||
|
||||
data_dir = config.get("data", "dir")
|
||||
data_dir = config["DATA_DIR"]
|
||||
|
||||
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
||||
today = now.date()
|
||||
|
|
@ -237,7 +225,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
|
|||
"gwr_advance_tickets": gwr_advance_tickets,
|
||||
}
|
||||
|
||||
my_data = config["data"]["personal-data"]
|
||||
my_data = config["PERSONAL_DATA"]
|
||||
events = (
|
||||
[
|
||||
Event(name="mothers_day", date=uk_holiday.get_mothers_day(today)),
|
||||
|
|
@ -254,7 +242,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
|
|||
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 += accommodation.get_events(os.path.join(my_data, "accommodation.yaml"))
|
||||
events += travel.all_events(config["data"]["personal-data"])
|
||||
events += travel.all_events(my_data)
|
||||
events += conference.get_list(os.path.join(my_data, "conferences.yaml"))
|
||||
events += backwell_bins + bristol_bins
|
||||
events += read_events_yaml(my_data, last_year, next_year)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
"""Currency exchange rates."""
|
||||
|
||||
import configparser
|
||||
import json
|
||||
import os
|
||||
import typing
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
import flask
|
||||
import httpx
|
||||
|
||||
|
||||
async def get_gbpusd(config: configparser.ConfigParser) -> Decimal:
|
||||
async def get_gbpusd(config: flask.config.Config) -> Decimal:
|
||||
"""Get the current value for GBPUSD, with caching."""
|
||||
access_key = config.get("exchangerate", "access_key")
|
||||
data_dir = config.get("data", "dir")
|
||||
access_key = config["EXCHANGERATE_ACCESS_KEY"]
|
||||
data_dir = config["DATA_DIR"]
|
||||
|
||||
now = datetime.now()
|
||||
now_str = now.strftime("%Y-%m-%d_%H:%M")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue