diff --git a/doorlockd b/doorlockd index 601d872..9fcfb28 100755 --- a/doorlockd +++ b/doorlockd @@ -26,6 +26,7 @@ from os.path import abspath, join from pydoorlock.Authenticator import Authenticator from pydoorlock.WebApp import webapp_run, emit_doorstate from pydoorlock.Doorlock import DoorlockResponse, DoorHandler +from pydoorlock.Config import Config SYSCONFDIR = '.' PREFIX = '.' @@ -43,22 +44,6 @@ date_fmt = '%Y-%m-%d %H:%M:%S' log_fmt = '%(asctime)-15s %(levelname)-8s %(message)s' log = logging.getLogger() - -class Config: - config_topic = 'doorlock' - - def __init__(self, sysconfdir): - self.config = ConfigParser() - self.config.read([join(sysconfdir, 'doorlockd.default.cfg'), - join(sysconfdir, 'doorlockd.cfg')]) - - def boolean(self, key): - return self.config.getboolean(self.config_topic, key) - - def str(self, key): - return self.config.get(self.config_topic, key) - - cfg = Config(SYSCONFDIR) diff --git a/pydoorlock/Config.py b/pydoorlock/Config.py new file mode 100644 index 0000000..ecb129a --- /dev/null +++ b/pydoorlock/Config.py @@ -0,0 +1,37 @@ +""" +Doorlockd -- Binary Kitchen's smart door opener + +Copyright (c) Binary Kitchen e.V., 2018 + +Author: + Ralf Ramsauer + Thomas Schmid + +This work is licensed under the terms of the GNU GPL, version 2. See +the LICENSE file in the top-level directory. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. +""" + +from configparser import ConfigParser +from os.path import join + +class Config: + config_topic = 'doorlock' + + def __init__(self, sysconfdir): + self.config = ConfigParser() + self.config.read([join(sysconfdir, 'doorlockd.default.cfg'), + join(sysconfdir, 'doorlockd.cfg')]) + + def boolean(self, key): + return self.config.getboolean(self.config_topic, key) + + def str(self, key): + return self.config.get(self.config_topic, key) + + def int(self,key): + return self.config.getint(self.config_topic, key) \ No newline at end of file