introduce a configuration module

This commit is contained in:
Sven Czarnian
2021-08-15 08:59:32 +02:00
parent a3f4f8f41b
commit 7b26e27c9d
4 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python
import configparser
import sys
from aman.config.Server import Server
class Configuration:
def __init__(self, filepath : str):
config = configparser.ConfigParser()
config.read(filepath)
# search the required sections
serverSectionAvailable = False
for key in config:
if 'SERVER' == key:
serverSectionAvailable = True
if not serverSectionAvailable:
sys.stderr.write('No server-configuration section found!')
sys.exit(-1)
self.Server = Server(config['SERVER'])