mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-10-31 22:47:05 +01:00
move Config class to pydoorlock module
Signed-off-by: Thomas Schmid <tom@binary-kitchen.de>
This commit is contained in:
parent
263fc0c687
commit
bdfcf29075
17
doorlockd
17
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)
|
||||
|
||||
|
||||
|
37
pydoorlock/Config.py
Normal file
37
pydoorlock/Config.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""
|
||||
Doorlockd -- Binary Kitchen's smart door opener
|
||||
|
||||
Copyright (c) Binary Kitchen e.V., 2018
|
||||
|
||||
Author:
|
||||
Ralf Ramsauer <ralf@binary-kitchen.de>
|
||||
Thomas Schmid <tom@binary-kitchen.de>
|
||||
|
||||
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)
|
Loading…
Reference in New Issue
Block a user