Split config loading into separate function
This commit is contained in:
parent
ce9ca7914d
commit
26aa8a8ad8
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue