git-importer/lib/config.py
Dirk Müller b0ffb01c59
cleanups
2024-05-16 11:49:14 +02:00

22 lines
518 B
Python

from configparser import ConfigParser
def config(filename="database.ini", section="production"):
# create a parser
parser = ConfigParser()
# read config file
parser.read(filename)
# get section, default to postgresql
db = {}
if parser.has_section(section):
params = parser.items(section)
for param in params:
db[param[0]] = param[1]
else:
raise Exception(
f"Section {section} not found in the {filename} file"
)
return db