1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/config/__init__.py
2016-10-02 12:43:45 +01:00

30 lines
755 B
Python

import yaml
import os.path
class DotDictionary(dict):
def __getattr__(self, attr):
value = self[attr]
if type(value) == dict:
value = DotDictionary(value)
return value
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
class WrappedSettings:
def __init__(self):
self.settings_dir = os.path.join(os.path.dirname(__file__), 'config.yml')
settings = open(self.settings_dir)
self.settings = yaml.safe_load(settings)
def __getattr__(self, name):
value = self.settings[name]
if type(value) == dict:
value = DotDictionary(value)
return value
def __str__(self):
return str(self.settings)
settings = WrappedSettings()