fieldpoc/fieldpoc/config.py

46 lines
992 B
Python

#!/usr/bin/env python3
class ConfigBase:
def __init__(self, c):
self._c = c
def __getattr__(self, name):
if name in self._c.keys():
return self._c.get(name)
else:
raise AttributeError()
class ControllerConfig(ConfigBase):
def __init__(self, c):
self._c = c
class DatabaseConfig(ConfigBase):
pass
class DectConfig(ConfigBase):
def __init__(self, c):
self._c = c
def check(self):
return True
class ExtensionsConfig(ConfigBase):
pass
class YateConfig(ConfigBase):
pass
class Config:
def __init__(self, c):
self.controller = ControllerConfig(c.get("controller", {}))
self.database = DatabaseConfig(c.get("database", {}))
self.dect = DectConfig(c.get("dect", {}))
self.extensions = ExtensionsConfig(c.get("extensions", {}))
self.yate = YateConfig(c.get("yate", {}))
def check(self):
return self.dect.check()