<commit_before># -*- coding: utf-8 -*-
import os

from .constants import SPECIAL_SETTINGS_KEY


def required_settings(settings_dict):
    required_settings = (
        settings_dict[SPECIAL_SETTINGS_KEY]['REQUIRED_SETTINGS']
    )
    invalid_settings_list = [
        i for i in required_settings if i not in settings_dict
    ]
    if invalid_settings_list:
        raise ValueError(
            'The following settings are required: {}'.format(
                ', '.join(invalid_settings_list)
            )
        )


def override_settings_by_env(settings_dict):
    if not settings_dict[SPECIAL_SETTINGS_KEY]['OVERRIDE_BY_ENV']:
        return
    for key, value in settings_dict.items():
        settings_dict[key] = os.environ.get(key, value)


SPECIAL_SETTINGS_MAPPING = {
    'OVERRIDE_BY_ENV': override_settings_by_env,
    'REQUIRED_SETTINGS': required_settings
}


def process_special_settings(settings_dict):
    special_settings = settings_dict.get(SPECIAL_SETTINGS_KEY)
    if not special_settings:
        return
<commit_msg>Refs #31 - Do not update special settings key from ENV<commit_after># -*- coding: utf-8 -*-
import os

from .constants import SPECIAL_SETTINGS_KEY


def required_settings(settings_dict):
    required_settings = (
        settings_dict[SPECIAL_SETTINGS_KEY]['REQUIRED_SETTINGS']
    )
    invalid_settings_list = [
        i for i in required_settings if i not in settings_dict
    ]
    if invalid_settings_list:
        raise ValueError(
            'The following settings are required: {}'.format(
                ', '.join(invalid_settings_list)
            )
        )


def override_settings_by_env(settings_dict):
    if not settings_dict[SPECIAL_SETTINGS_KEY]['OVERRIDE_BY_ENV']:
        return
    for key, value in settings_dict.items():
        if key != SPECIAL_SETTINGS_KEY:
            settings_dict[key] = os.environ.get(key, value)


SPECIAL_SETTINGS_MAPPING = {
    'OVERRIDE_BY_ENV': override_settings_by_env,
    'REQUIRED_SETTINGS': required_settings
}


def process_special_settings(settings_dict):
    special_settings = settings_dict.get(SPECIAL_SETTINGS_KEY)
    if not special_settings:
        return

{'fraction_non_alphanumeric': 0.08160442600276625, 'fraction_numerical': 0.0018441678192715537, 'mean_word_length': 3.2885375494071147, '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': '6701359', 'n_tokens_mistral': 666, 'n_tokens_neox': 670, 'n_words': 136}