Created
May 22, 2014 18:57
-
-
Save carsongee/19aab0c01430f000e6fb to your computer and use it in GitHub Desktop.
Load yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import yaml | |
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | |
# Setup variables for loading yaml settings | |
CONFIG_DEFAULT = os.path.abspath(os.path.join(BASE_DIR, '../etc')) | |
CONFIG_ROOT = os.environ.get('CONFIG_ROOT', CONFIG_DEFAULT) | |
# This takes any setting it can find in a yaml | |
# configuration file and loads it. This is useful | |
# for keeping settings that you don't want checked in | |
# like private keys and database connection information | |
config_path = '{0}/cas.yml'.format(CONFIG_ROOT) | |
if os.path.isfile(config_path): | |
with open(config_path) as conf_file: | |
conf = yaml.load(conf_file) | |
try: | |
globals().update(conf) | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment