rascunho

ref: master

rascunho/config.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
from configparser import ConfigParser

config = ConfigParser()
paths = ["config.ini", "rascunho.ini", "/etc/rascunho.ini"]
for path in paths:
    try:
        with open(path) as file:
            config.read_file(file)
        break
    except FileNotFoundError:
        pass

if len(config.sections()) == 0:
    raise Exception("Configuration is empty or were not found")

env = config['meta']['env']

read_from_config = lambda key: config.get(env, key)