From c05d8cadadf68c47aef7c277867513d793502641 Mon Sep 17 00:00:00 2001 From: Cathy Hu Date: Wed, 1 Jul 2020 21:21:39 +0200 Subject: [PATCH] [core] Add parser for configuration --- kibicara/config.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 kibicara/config.py diff --git a/kibicara/config.py b/kibicara/config.py new file mode 100644 index 0000000..840aa2e --- /dev/null +++ b/kibicara/config.py @@ -0,0 +1,24 @@ +# Copyright (C) 2020 by Thomas Lindner +# Copyright (C) 2020 by Cathy Hu +# +# 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