[core] Add parser for configuration
This commit is contained in:
parent
5c458ccd41
commit
c05d8cadad
24
kibicara/config.py
Normal file
24
kibicara/config.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Copyright (C) 2020 by Thomas Lindner <tom@dl6tom.de>
|
||||
# Copyright (C) 2020 by Cathy Hu <cathy.hu@fau.de>
|
||||
#
|
||||
# SPDX-License-Identifier: 0BSD
|
||||
|
||||
from optparse import OptionParser
|
||||
from pytoml import load
|
||||
|
||||
|
||||
config = {
|
||||
'database_connection': 'sqlite:////tmp/kibicara.sqlite',
|
||||
'frontend_path': None,
|
||||
}
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('-f', dest='configfile', default='/etc/kibicara.conf')
|
||||
(option, args) = parser.parse_args()
|
||||
|
||||
try:
|
||||
with open(option.configfile) as configfile:
|
||||
config.update(load(configfile))
|
||||
except FileNotFoundError:
|
||||
# run with default config
|
||||
pass
|
Loading…
Reference in a new issue