diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..dc1cd9b --- /dev/null +++ b/config/__init__.py @@ -0,0 +1,30 @@ +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.load(settings) + + def __getattr__(self, name): + value = getattr(self.settings, name) + if type(value) == dict: + value = DotDictionary(value) + return value + + def __str__(self): + return str(self.settings) + +settings = WrappedSettings() diff --git a/config/config.yml b/config/config.yml new file mode 100644 index 0000000..20e9ff3 --- /dev/null +++ b/config/config.yml @@ -0,0 +1 @@ +foo: bar diff --git a/config/pelicanconf.py b/config/pelicanconf.py index 96c046e..471a128 100644 --- a/config/pelicanconf.py +++ b/config/pelicanconf.py @@ -4,6 +4,8 @@ from git import Repo import sys, os sys.path.insert(0, os.path.realpath('./')) +from config import settings + # Global core settings AUTHOR = 'Jake Howard' SITENAME = 'TheOrangeOne'