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
 | 
					    return events
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
 | 
					def get_config() -> configparser.ConfigParser:
 | 
				
			||||||
    """Get data to display on agenda dashboard."""
 | 
					    """Load config file."""
 | 
				
			||||||
    config_filename = os.path.join(os.path.dirname(__file__), "..", "config")
 | 
					    config_filename = os.path.join(os.path.dirname(__file__), "..", "config")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert os.path.exists(config_filename)
 | 
					    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 = configparser.ConfigParser()
 | 
				
			||||||
    config.read(config_filename)
 | 
					    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")
 | 
					    data_dir = config.get("data", "dir")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    rocket_dir = os.path.join(data_dir, "thespacedevs")
 | 
					    rocket_dir = os.path.join(data_dir, "thespacedevs")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue