forked from adamm/git-importer
Move modules into lib subdir
This commit is contained in:
21
lib/config.py
Normal file
21
lib/config.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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(
|
||||
"Section {0} not found in the {1} file".format(section, filename)
|
||||
)
|
||||
|
||||
return db
|
||||
Reference in New Issue
Block a user