add seperate settings file
This commit is contained in:
parent
523cd966d2
commit
feb438eaa2
3 changed files with 33 additions and 0 deletions
30
config/__init__.py
Normal file
30
config/__init__.py
Normal file
|
@ -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()
|
1
config/config.yml
Normal file
1
config/config.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
foo: bar
|
|
@ -4,6 +4,8 @@ from git import Repo
|
||||||
import sys, os
|
import sys, os
|
||||||
sys.path.insert(0, os.path.realpath('./'))
|
sys.path.insert(0, os.path.realpath('./'))
|
||||||
|
|
||||||
|
from config import settings
|
||||||
|
|
||||||
# Global core settings
|
# Global core settings
|
||||||
AUTHOR = 'Jake Howard'
|
AUTHOR = 'Jake Howard'
|
||||||
SITENAME = 'TheOrangeOne'
|
SITENAME = 'TheOrangeOne'
|
||||||
|
|
Reference in a new issue