<commit_before># -*- coding: utf-8 -*-
# Django settings for addons-server project.

import environ
import logging
import os
import socket
import json

from django.urls import reverse_lazy
from django.utils.functional import lazy

import raven
from kombu import Queue

import olympia.core.logger


env = environ.Env()

ENVIRON_SETTINGS_FILE_PATH = '/etc/olympia/settings.env'

if os.path.exists(ENVIRON_SETTINGS_FILE_PATH):
    env.read_env(env_file=ENVIRON_SETTINGS_FILE_PATH)


ALLOWED_HOSTS = [
    '.allizom.org',
    '.mozilla.org',
    '.mozilla.com',
    '.mozilla.net',
    '.mozaws.net',
]

# jingo-minify settings
CACHEBUST_IMGS = True
try:
    # If we have build ids available, we'll grab them here and add them to our
    # CACHE_PREFIX.  This will let us not have to flush memcache during updates
    # and it will let us preload data into it before a production push.
    from build import BUILD_ID_CSS, BUILD_ID_JS
    build_id = "%s%s" % (BUILD_ID_CSS[:2], BUILD_ID_JS[:2])
except ImportError:
    build_id = ""

# jingo-minify: Style sheet media attribute default
CSS_MEDIA_DEFAULT = 'all'

# Make filepaths relative to the root of olympia.
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ROOT = os.path.join(BASE_DIR, '..', '..')


def path(*folders):
    return os.path.join(ROOT, *folders)


DEBUG = False

# Ensure that exceptions aren't re-raised.
DEBUG_PROPAGATE_EXCEPTIONS = False
SILENCED_SYSTEM_CHECKS = (
    # Recommendation to use OneToOneField instead of ForeignKey(unique=True)
    # but our translations are the way they are...
    'fields.W342',
)

# LESS CSS OPTIONS (Debug only).
LESS_PREPROCESS = True  # Compile LESS with Node, rather than client-side JS?
LESS_LIVE_REFRESH = False  # Refresh the CSS on save?
LESS_BIN = 'lessc'

# Path to cleancss (our CSS minifier).
CLEANCSS_BIN = 'cleancss'

# Path to uglifyjs (our JS minifier).
UGLIFY_BIN = 'uglifyjs'  # Set as None to use YUI instead (at your risk).

# rsvg-convert is used to save our svg static theme previews to png
RSVG_CONVERT_BIN = 'rsvg-convert'

# Path to pngcrush (to optimize the PNGs uploaded by developers).
PNGCRUSH_BIN = 'pngcrush'

FLIGTAR = '<EMAIL>'
THEMES_EMAIL = '<EMAIL>'
ABUSE_EMAIL = '<EMAIL>'

DRF_API_VERSIONS = ['v3', 'v4']
DRF_API_REGEX = r'^/?api/(?:v3|v4)/'

# Add Access-Control-Allow-Origin: * header for the new API with
# django-cors-headers.
CORS_ORIGIN_ALLOW_ALL = True
CORS_URLS_REGEX = DRF_API_REGEX


# Sadly the term WHITELIST is used by the library
# https://pypi.python.org/pypi/django-cors-headers-multi/1.2.0
def cors_endpoint_overrides(whitelist_endpoints):
    return [
        ('%saccounts/login/?$' % DRF_API_REGEX, {
            'CORS_ORIGIN_ALLOW_ALL': False,
            'CORS_ORIGIN_WHITELIST': whitelist_endpoints,
            'CORS_ALLOW_CREDENTIALS': True,
        }),
    ]


CORS_ENDPOINT_OVERRIDES = []


def get_db_config(environ_var):
    values = env.db(
        var=environ_var,
        default='mysql://root:@localhost/olympia')

    values.update({
        # Run all views in a transaction unless they are decorated not to.
        'ATOMIC_REQUESTS': True,
        # Pool our database connections up for 300 seconds
        'CONN_MAX_AGE': 300,
        'OPTIONS': {
            'sql_mode': 'STRICT_ALL_TABLES',
            'isolation_level': 'read committed'
        },
        'TEST': {
            'CHARSET': 'utf8',
            'COLLATION': 'utf8_general_ci'
        },
    })

    return values


DATABASES = {
    'default': get_db_config('DATABASES_DEFAULT_URL'),
}

# A database to be used by the services scripts, which does not use Django.
# Please note that this is not a full Django database connection
# so the amount of values supported are limited. By default we are using
# the same connection as 'default' but that changes in prod/dev/stage.
SERVICES_DATABASE = get_db_config('DATABASES_DEFAULT_URL')

DATABASE_ROUTERS = ('multidb.PinningMasterSlaveRouter',)

# Put the aliases for your slave databases in this list.
SLAVE_DATABASES = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-US'

# Accepted locales.
AMO_LANGUAGES = (
    'af',  # Afrikaans
    'ar',  # Arabic
    'ast',  # Asturian
    'az',  # Azerbaijani
    'bg',  # Bulgarian
    'bn-BD',  # Bengali (Bangladesh)
    'bs',  # Bosnian
    'ca',  # Catalan
    'cak',  # Kaqchikel
    'cs',  # Czech
    'da',  # Danish
    'de',  # German
    'dsb',  # Lower Sorbian
    'el',  # Greek
    'en-CA',  # English (Canada)
    'en-GB',  # English (British)
    'en-US',  # English (US)
    'es',  # Spanish
    'eu',  # Basque
    'fa',  # Persian
    'fi',  # Finnish
    'fr',  # French
    'fy-NL',  # Frisian
    'ga-IE',  # Irish
    'gu',  # Gujarati
    'he',  # Hebrew
    'hsb',  # Upper Sorbian
    'hu',  # Hungarian
    'ia',  # Interlingua
    'id',  # Indonesian
    'it',  # Italian
    'ja',  # Japanese
    'ka',  # Georgian
    'kab',  # Kabyle
    'ko',  # Korean
    'mk',  # Macedonian
    'mn',  # Mongolian
    'ms',  # Malay
    'nb-NO',  # Norwegian (Bokmål)
    'nl',  # Dutch
    'nn-NO',  # Norwegian (Nynorsk)
    'pl',  # Polish
    'pt-BR',  # Portuguese (Brazilian)
    'pt-PT',  # Portuguese (Portugal)
    'ro',  # Romanian<commit_msg>Disable 'ia' locale as it's not in product_details yet<commit_after># -*- coding: utf-8 -*-
# Django settings for addons-server project.

import environ
import logging
import os
import socket
import json

from django.urls import reverse_lazy
from django.utils.functional import lazy

import raven
from kombu import Queue

import olympia.core.logger


env = environ.Env()

ENVIRON_SETTINGS_FILE_PATH = '/etc/olympia/settings.env'

if os.path.exists(ENVIRON_SETTINGS_FILE_PATH):
    env.read_env(env_file=ENVIRON_SETTINGS_FILE_PATH)


ALLOWED_HOSTS = [
    '.allizom.org',
    '.mozilla.org',
    '.mozilla.com',
    '.mozilla.net',
    '.mozaws.net',
]

# jingo-minify settings
CACHEBUST_IMGS = True
try:
    # If we have build ids available, we'll grab them here and add them to our
    # CACHE_PREFIX.  This will let us not have to flush memcache during updates
    # and it will let us preload data into it before a production push.
    from build import BUILD_ID_CSS, BUILD_ID_JS
    build_id = "%s%s" % (BUILD_ID_CSS[:2], BUILD_ID_JS[:2])
except ImportError:
    build_id = ""

# jingo-minify: Style sheet media attribute default
CSS_MEDIA_DEFAULT = 'all'

# Make filepaths relative to the root of olympia.
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ROOT = os.path.join(BASE_DIR, '..', '..')


def path(*folders):
    return os.path.join(ROOT, *folders)


DEBUG = False

# Ensure that exceptions aren't re-raised.
DEBUG_PROPAGATE_EXCEPTIONS = False
SILENCED_SYSTEM_CHECKS = (
    # Recommendation to use OneToOneField instead of ForeignKey(unique=True)
    # but our translations are the way they are...
    'fields.W342',
)

# LESS CSS OPTIONS (Debug only).
LESS_PREPROCESS = True  # Compile LESS with Node, rather than client-side JS?
LESS_LIVE_REFRESH = False  # Refresh the CSS on save?
LESS_BIN = 'lessc'

# Path to cleancss (our CSS minifier).
CLEANCSS_BIN = 'cleancss'

# Path to uglifyjs (our JS minifier).
UGLIFY_BIN = 'uglifyjs'  # Set as None to use YUI instead (at your risk).

# rsvg-convert is used to save our svg static theme previews to png
RSVG_CONVERT_BIN = 'rsvg-convert'

# Path to pngcrush (to optimize the PNGs uploaded by developers).
PNGCRUSH_BIN = 'pngcrush'

FLIGTAR = '<EMAIL>'
THEMES_EMAIL = '<EMAIL>'
ABUSE_EMAIL = '<EMAIL>'

DRF_API_VERSIONS = ['v3', 'v4']
DRF_API_REGEX = r'^/?api/(?:v3|v4)/'

# Add Access-Control-Allow-Origin: * header for the new API with
# django-cors-headers.
CORS_ORIGIN_ALLOW_ALL = True
CORS_URLS_REGEX = DRF_API_REGEX


# Sadly the term WHITELIST is used by the library
# https://pypi.python.org/pypi/django-cors-headers-multi/1.2.0
def cors_endpoint_overrides(whitelist_endpoints):
    return [
        ('%saccounts/login/?$' % DRF_API_REGEX, {
            'CORS_ORIGIN_ALLOW_ALL': False,
            'CORS_ORIGIN_WHITELIST': whitelist_endpoints,
            'CORS_ALLOW_CREDENTIALS': True,
        }),
    ]


CORS_ENDPOINT_OVERRIDES = []


def get_db_config(environ_var):
    values = env.db(
        var=environ_var,
        default='mysql://root:@localhost/olympia')

    values.update({
        # Run all views in a transaction unless they are decorated not to.
        'ATOMIC_REQUESTS': True,
        # Pool our database connections up for 300 seconds
        'CONN_MAX_AGE': 300,
        'OPTIONS': {
            'sql_mode': 'STRICT_ALL_TABLES',
            'isolation_level': 'read committed'
        },
        'TEST': {
            'CHARSET': 'utf8',
            'COLLATION': 'utf8_general_ci'
        },
    })

    return values


DATABASES = {
    'default': get_db_config('DATABASES_DEFAULT_URL'),
}

# A database to be used by the services scripts, which does not use Django.
# Please note that this is not a full Django database connection
# so the amount of values supported are limited. By default we are using
# the same connection as 'default' but that changes in prod/dev/stage.
SERVICES_DATABASE = get_db_config('DATABASES_DEFAULT_URL')

DATABASE_ROUTERS = ('multidb.PinningMasterSlaveRouter',)

# Put the aliases for your slave databases in this list.
SLAVE_DATABASES = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-US'

# Accepted locales.
AMO_LANGUAGES = (
    'af',  # Afrikaans
    'ar',  # Arabic
    'ast',  # Asturian
    'az',  # Azerbaijani
    'bg',  # Bulgarian
    'bn-BD',  # Bengali (Bangladesh)
    'bs',  # Bosnian
    'ca',  # Catalan
    'cak',  # Kaqchikel
    'cs',  # Czech
    'da',  # Danish
    'de',  # German
    'dsb',  # Lower Sorbian
    'el',  # Greek
    'en-CA',  # English (Canada)
    'en-GB',  # English (British)
    'en-US',  # English (US)
    'es',  # Spanish
    'eu',  # Basque
    'fa',  # Persian
    'fi',  # Finnish
    'fr',  # French
    'fy-NL',  # Frisian
    'ga-IE',  # Irish
    'gu',  # Gujarati
    'he',  # Hebrew
    'hsb',  # Upper Sorbian
    'hu',  # Hungarian
    # 'ia',  # Interlingua - doesn't exist in product_details yet.
    'id',  # Indonesian
    'it',  # Italian
    'ja',  # Japanese
    'ka',  # Georgian
    'kab',  # Kabyle
    'ko',  # Korean
    'mk',  # Macedonian
    'mn',  # Mongolian
    'ms',  # Malay
    'nb-NO',  # Norwegian (Bokmål)
    'nl',  # Dutch
    'nn-NO',  # Norwegian (Nynorsk)
    'pl',  # Polish
    'pt-BR',  # Portuguese (Brazilian)
    'pt-PT',  # Portuguese (Portugal)
    'ro',  # Romanian
{'fraction_non_alphanumeric': 0.11701845800582884, 'fraction_numerical': 0.004062527598692926, 'mean_word_length': 3.138888888888889, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6938308', 'n_tokens_mistral': 4143, 'n_tokens_neox': 4014, 'n_words': 1106}