<commit_before>"""
Django settings for meetuppizza project on Heroku. Fore more info, see:
https://github.com/heroku/heroku-django-template

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""

import os
import psycopg2
import dj_database_url
from unipath import Path
import requests
from requests_oauthlib import OAuth1

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

BASE_DIR = Path(__file__).ancestor(3)
PROJECT_ROOT = BASE_DIR.child("meetuppizza")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'secret!'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

MEETUP_KEY = os.getenv("MEETUP_KEY")
YELP_OAUTH_OBJECT = OAuth1(
		os.getenv('YELP_CONSUMER_KEY'),
		os.getenv('YELP_CONSUMER_SECRET'),
		os.getenv('YELP_TOKEN'),
		os.getenv('YELP_TOKEN_SECRET')
		)


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'super_user',
    'meetup',
    'pizzaplace'
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'meetuppizza.urls'
<commit_msg>Change env variable access to handle KeyErrors<commit_after>"""
Django settings for meetuppizza project on Heroku. Fore more info, see:
https://github.com/heroku/heroku-django-template

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
from django.core.exceptions import ImproperlyConfigured
import os
import psycopg2
import dj_database_url
from unipath import Path
import requests
from requests_oauthlib import OAuth1

def get_env_variable(var_name):
    try:
        return os.getenv(var_name)
    except KeyError:
        error_msg = "Set the {} envifonment variable".format(var_name)
        raise ImproperlyConfigured(error_msg)

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

BASE_DIR = Path(__file__).ancestor(3)
PROJECT_ROOT = BASE_DIR.child("meetuppizza")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'secret!'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

MEETUP_KEY = get_env_variable("MEETUP_KEY")
YELP_OAUTH_OBJECT = OAuth1(
		get_env_variable('YELP_CONSUMER_KEY'),
		get_env_variable('YELP_CONSUMER_SECRET'),
		get_env_variable('YELP_TOKEN'),
		get_env_variable('YELP_TOKEN_SECRET')
		)


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'super_user',
    'meetup',
    'pizzaplace'
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'meetuppizza.urls'

{'fraction_non_alphanumeric': 0.11427939876215738, 'fraction_numerical': 0.004420866489832007, 'mean_word_length': 4.985449735449736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7221156', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1517, 'n_words': 278}