You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
441 B
Python

"""
Config related tools.
"""
import dataclasses
import yaml
from typing import Optional
@dataclasses.dataclass
class Config:
username: str
homeserver: str
password: str
rooms: list[str]
def load_config(file:str)->Config:
"""
Load the config from the config file.
"""
with open(file, 'r') as f:
data = yaml.load(f, Loader=yaml.loader.SafeLoader)
config = Config(**data)
return config