<commit_before>"""
Django settings for modelreg project.

Generated by 'django-admin startproject' using Django 1.11.

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

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

import os
import random
import string

from django.core.exceptions import ImproperlyConfigured

from modelreg.settings import *


def _make_key(length):
   letters = string.ascii_letters + string.punctuation + string.digits
   return ''.join(random.choice(letters) for _ in range(length))

SECRET_KEY    = os.getenv('SECRET_KEY', _make_key(50))
DEBUG         = os.getenv('DEBUG', 'false').lower() == 'true'
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '*').split(',')



_db_configs = {
    'sqlite3': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
    'mysql': {
        'ENGINE':  'django.db.backends.mysql',
        'NAME':     os.getenv('DB_NAME', None),
        'USER':     os.getenv('DB_USER', None),
        'PASSWORD': os.getenv('DB_PASSWORD', None),
        'HOST':     os.getenv('DB_HOST', '127.0.0.1'),
        'PORT':     '3306',
    },
    'postgresql': {
        'ENGINE':   'django.db.backends.postgresql',
        'NAME':     os.getenv('DB_NAME', None),
        'USER':     os.getenv('DB_USER', None),
        'PASSWORD': os.getenv('DB_PASSWORD', None),
        'HOST':     os.getenv('DB_HOST', '127.0.0.1'),
        'PORT':     '5432',
    }
}

DB_TYPE = os.getenv('DB_TYPE', 'sqlite3')

if DB_TYPE not in _db_configs:
    raise ImproperlyConfigured("You have configured an incompatible DB_TYPE")

DATABASES = {
    'default': _db_configs[DB_TYPE]
}

STATIC_ROOT = '/usr/src/app/static'

def bool_from_str(val):
    return val.lower() in ('true', '1', 'ok', 'yes')

def set_from_env(varname, convert=str):
    """Set given (global) settings variable from env, if it is set

    You can pass a convert function, for example if the required
    settings value needs to be an integer:

    >>> set_from_env('EMAIL_PORT', int)
    """
    value = os.getenv(varname, False)
    if value is not False:
        globals()[varname] = convert(value)

if os.getenv('EMAIL_HOST', False):
    # If we have SMTP config, use SMTP backend. Default is "console",
    # which is only useful for testing / development and will NOT
    # send out email.
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    set_from_env('EMAIL_HOST')
    set_from_env('EMAIL_PORT', int)
    set_from_env('EMAIL_HOST_USER')
    set_from_env('EMAIL_HOST_PASSWORD')
    set_from_env('EMAIL_USE_TLS', bool_from_str)
    set_from_env('EMAIL_USE_SSL', bool_from_str)

SYSTEM_EMAIL    = os.getenv('SYSTEM_EMAIL',    '<EMAIL>')
SYSTEM_OPERATOR = os.getenv('SYSTEM_OPERATOR', 'ModelReg Team')<commit_msg>Django 2.0 - SERVER_EMAIL, DEFAULT_FROM_EMAIL<commit_after>"""
Django settings for modelreg project.

Generated by 'django-admin startproject' using Django 1.11.

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

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

import os
import random
import string

from django.core.exceptions import ImproperlyConfigured

from modelreg.settings import *


def _make_key(length):
   letters = string.ascii_letters + string.punctuation + string.digits
   return ''.join(random.choice(letters) for _ in range(length))

SECRET_KEY    = os.getenv('SECRET_KEY', _make_key(50))
DEBUG         = os.getenv('DEBUG', 'false').lower() == 'true'
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '*').split(',')



_db_configs = {
    'sqlite3': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
    'mysql': {
        'ENGINE':  'django.db.backends.mysql',
        'NAME':     os.getenv('DB_NAME', None),
        'USER':     os.getenv('DB_USER', None),
        'PASSWORD': os.getenv('DB_PASSWORD', None),
        'HOST':     os.getenv('DB_HOST', '127.0.0.1'),
        'PORT':     '3306',
    },
    'postgresql': {
        'ENGINE':   'django.db.backends.postgresql',
        'NAME':     os.getenv('DB_NAME', None),
        'USER':     os.getenv('DB_USER', None),
        'PASSWORD': os.getenv('DB_PASSWORD', None),
        'HOST':     os.getenv('DB_HOST', '127.0.0.1'),
        'PORT':     '5432',
    }
}

DB_TYPE = os.getenv('DB_TYPE', 'sqlite3')

if DB_TYPE not in _db_configs:
    raise ImproperlyConfigured("You have configured an incompatible DB_TYPE")

DATABASES = {
    'default': _db_configs[DB_TYPE]
}

STATIC_ROOT = '/usr/src/app/static'

def bool_from_str(val):
    return val.lower() in ('true', '1', 'ok', 'yes')

def set_from_env(varname, convert=str):
    """Set given (global) settings variable from env, if it is set

    You can pass a convert function, for example if the required
    settings value needs to be an integer:

    >>> set_from_env('EMAIL_PORT', int)
    """
    value = os.getenv(varname, False)
    if value is not False:
        globals()[varname] = convert(value)

if os.getenv('EMAIL_HOST', False):
    # If we have SMTP config, use SMTP backend. Default is "console",
    # which is only useful for testing / development and will NOT
    # send out email.
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    set_from_env('EMAIL_HOST')
    set_from_env('EMAIL_PORT', int)
    set_from_env('EMAIL_HOST_USER')
    set_from_env('EMAIL_HOST_PASSWORD')
    set_from_env('EMAIL_USE_TLS', bool_from_str)
    set_from_env('EMAIL_USE_SSL', bool_from_str)

SYSTEM_EMAIL    = os.getenv('SYSTEM_EMAIL',    '<EMAIL>')
SYSTEM_OPERATOR = os.getenv('SYSTEM_OPERATOR', 'ModelReg Team')
DEFAULT_FROM_EMAIL = SYSTEM_EMAIL
SERVER_EMAIL = SYSTEM_EMAIL
{'fraction_non_alphanumeric': 0.14473684210526316, 'fraction_numerical': 0.012645249487354751, 'mean_word_length': 3.498847040737894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '4411137', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2071, 'n_words': 456}