From 26aa8a8ad848df13600e1c14d2a73741a808156e Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 19 Nov 2023 08:42:39 -0300 Subject: [PATCH] Split config loading into separate function --- agenda/data.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agenda/data.py b/agenda/data.py index e9b2b28..36f1ad4 100644 --- a/agenda/data.py +++ b/agenda/data.py @@ -184,8 +184,8 @@ def read_events_yaml(data_dir: str, start: date, end: date) -> list[Event]: return events -async def get_data(now: datetime) -> typing.Mapping[str, str | object]: - """Get data to display on agenda dashboard.""" +def get_config() -> configparser.ConfigParser: + """Load config file.""" config_filename = os.path.join(os.path.dirname(__file__), "..", "config") assert os.path.exists(config_filename) @@ -193,6 +193,13 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]: config = configparser.ConfigParser() config.read(config_filename) + return config + + +async def get_data(now: datetime) -> typing.Mapping[str, str | object]: + """Get data to display on agenda dashboard.""" + config = get_config() + data_dir = config.get("data", "dir") rocket_dir = os.path.join(data_dir, "thespacedevs")