aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/tests/utils/config.py
blob: 30c8ea4fe80f6f103f1ed955bdf803055907d9e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import yaml


def get_config_data(filename="moon.conf"):
    data_config = None
    for _file in (
            filename,
            "conf/moon.conf",
            "../moon.conf",
            "../conf/moon.conf",
            "/etc/moon/moon.conf",
    ):
        try:
            data_config = yaml.safe_load(open(_file))
        except FileNotFoundError:
            data_config = None
            continue
        else:
            break
    if not data_config:
        raise Exception("Configuration file not found...")
    return data_config