<commit_before>"""Base settings shared by all environments.
This is a reusable basic settings file.
"""
from configurations import Configuration
from . import mixins


class BaseConfiguration(Configuration):
    """Base configuration, intended for use with the configuration mixins.
    Implements a helpful method get_setting() for getting settings
    that we are not sure have been set.
    
    Usage:
    
        class MyConfiguration(BaseConfiguration):
    
            @classmethod
            def setup(cls):
                super(MyConfiguration, cls).setup()
                cls.FOO = cls.get_setting('BAR')
                
    """
    @classmethod
    def get_setting(cls, name):
        "Shortcut for attempting to get a particular setting on the class."
        try:
            return getattr(cls, name)
        except AttributeError:
            raise ValueError('You must define a %s setting.' % name)


class StandardConfiguration(mixins.UnifiedDebugMixin,
                        mixins.SecretSettingsMixin,
                        mixins.AllowedHostsMixin,
                        mixins.LoggingMixin,
                        mixins.DatabaseMixin,
                        mixins.StaticMediaAndTemplatesMixin,
                        BaseConfiguration):
    """A configuration that collects together lots of standard
    configuration patterns for use across projects."""

    TIME_ZONE = 'GB'
    USE_TZ = True
    USE_I18N = True
    USE_L10N = True
    LANGUAGE_CODE = 'en-GB'
    LANGUAGES = (
        ('en-GB', 'British English'),
    )

    SITE_ID = 1
    LOGIN_URL = '/login/'
    LOGOUT_URL = '/logout/'
    LOGIN_REDIRECT_URL = '/'

    STATIC_URL = '/static/'
    MEDIA_URL = '/uploads/'

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
        }
    }

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'standard': {
                'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
                'datefmt' : "%d/%b/%Y %H:%M:%S"
            },
        },
        'handlers': {
            'error': {
                'level':'ERROR',
                'class':'logging.handlers.RotatingFileHandler',
                'filename': '/var/log/django/buzzhire/error.log',  # - filled in by LoggingMixin
                'maxBytes': 50000,
                'backupCount': 2,
                'formatter': 'standard',
            },
            'debug': {
                'level':'DEBUG',
                'class':'logging.handlers.RotatingFileHandler',
                'filename': '/var/log/django/buzzhire/debug.log',  # filled in by LoggingMixin
                'maxBytes': 50000,
                'backupCount': 2,
                'formatter': 'standard',
            },
            'mail_admins': {
                'level': 'ERROR',
                'class': 'django.utils.log.AdminEmailHandler',
                'include_html': True,
            },
        },
        'loggers': {
            'django': {
                'handlers':['error'],
                'propagate': True,
                'level':'DEBUG',
            },
            'django.request': {
                'handlers': ['mail_admins', 'error'],
                'level': 'ERROR',
                'propagate': False,
            },
            'project': {
                'handlers':['debug'],
                'propagate': True,
                'level':'DEBUG',
            },
        }
    }

    TEMPLATE_CONTEXT_PROCESSORS = Configuration.TEMPLATE_CONTEXT_PROCESSORS + (
        'django.core.context_processors.request',
    )

    ROOT_URLCONF = 'urls'

    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
    )

    MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )
<commit_msg>Added email to mixins<commit_after>"""Base settings shared by all environments.
This is a reusable basic settings file.
"""
from configurations import Configuration
from . import mixins


class BaseConfiguration(Configuration):
    """Base configuration, intended for use with the configuration mixins.
    Implements a helpful method get_setting() for getting settings
    that we are not sure have been set.
    
    Usage:
    
        class MyConfiguration(BaseConfiguration):
    
            @classmethod
            def setup(cls):
                super(MyConfiguration, cls).setup()
                cls.FOO = cls.get_setting('BAR')
                
    """
    @classmethod
    def get_setting(cls, name):
        "Shortcut for attempting to get a particular setting on the class."
        try:
            return getattr(cls, name)
        except AttributeError:
            raise ValueError('You must define a %s setting.' % name)


class StandardConfiguration(mixins.UnifiedDebugMixin,
                        mixins.SecretSettingsMixin,
                        mixins.AllowedHostsMixin,
                        mixins.LoggingMixin,
                        mixins.DatabaseMixin,
                        mixins.StaticMediaAndTemplatesMixin,
                        mixins.EmailMixin,
                        BaseConfiguration):
    """A configuration that collects together lots of standard
    configuration patterns for use across projects."""

    TIME_ZONE = 'GB'
    USE_TZ = True
    USE_I18N = True
    USE_L10N = True
    LANGUAGE_CODE = 'en-GB'
    LANGUAGES = (
        ('en-GB', 'British English'),
    )

    SITE_ID = 1
    LOGIN_URL = '/login/'
    LOGOUT_URL = '/logout/'
    LOGIN_REDIRECT_URL = '/'

    STATIC_URL = '/static/'
    MEDIA_URL = '/uploads/'

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
        }
    }

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'standard': {
                'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
                'datefmt' : "%d/%b/%Y %H:%M:%S"
            },
        },
        'handlers': {
            'error': {
                'level':'ERROR',
                'class':'logging.handlers.RotatingFileHandler',
                'filename': '/var/log/django/buzzhire/error.log',  # - filled in by LoggingMixin
                'maxBytes': 50000,
                'backupCount': 2,
                'formatter': 'standard',
            },
            'debug': {
                'level':'DEBUG',
                'class':'logging.handlers.RotatingFileHandler',
                'filename': '/var/log/django/buzzhire/debug.log',  # filled in by LoggingMixin
                'maxBytes': 50000,
                'backupCount': 2,
                'formatter': 'standard',
            },
            'mail_admins': {
                'level': 'ERROR',
                'class': 'django.utils.log.AdminEmailHandler',
                'include_html': True,
            },
        },
        'loggers': {
            'django': {
                'handlers':['error'],
                'propagate': True,
                'level':'DEBUG',
            },
            'django.request': {
                'handlers': ['mail_admins', 'error'],
                'level': 'ERROR',
                'propagate': False,
            },
            'project': {
                'handlers':['debug'],
                'propagate': True,
                'level':'DEBUG',
            },
        }
    }

    TEMPLATE_CONTEXT_PROCESSORS = Configuration.TEMPLATE_CONTEXT_PROCESSORS + (
        'django.core.context_processors.request',
    )

    ROOT_URLCONF = 'urls'

    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
    )

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

{'fraction_non_alphanumeric': 0.1178072863466122, 'fraction_numerical': 0.004312790829644762, 'mean_word_length': 1.6997549019607843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3286565', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2393, 'n_words': 462}