<commit_before># -*- coding: utf-8 -*-
from django.conf import settings


class SwaggerConfig(object):
    DEFAULT_SWAGGER_SETTINGS = {
        'exclude_namespaces': [],
        'exclude_module_paths': [],
        'exclude_url_patterns': [],
        'include_module_paths': [],
        'is_authenticated': False,
        'is_superuser': False,
        'base_path': ''
    }

    def __init__(self):
        super(SwaggerConfig, self).__init__()
        self.global_settings = self.DEFAULT_SWAGGER_SETTINGS.copy()
        self.global_settings.update(settings.SWAGGER_GLOBAL_SETTINGS)

    def get_config(self, config_name=None):
        config_name = config_name or "default"
        if config_name not in settings.SWAGGER_LOCAL_SETTINGS:
            raise Exception("{} swagger settings not defined".format(config_name))
        current_config = self.global_settings.copy()
        current_config.update(settings.SWAGGER_LOCAL_SETTINGS[config_name])<commit_msg>Make swagger config errors more obvious.<commit_after># -*- coding: utf-8 -*-
from django.conf import settings


class SwaggerConfig(object):
    DEFAULT_SWAGGER_SETTINGS = {
        'exclude_namespaces': [],
        'exclude_module_paths': [],
        'exclude_url_patterns': [],
        'include_module_paths': [],
        'is_authenticated': False,
        'is_superuser': False,
        'base_path': ''
    }

    def __init__(self):
        super(SwaggerConfig, self).__init__()
        self.global_settings = self.DEFAULT_SWAGGER_SETTINGS.copy()
        self.global_settings.update(getattr(settings, 'SWAGGER_GLOBAL_SETTINGS', {}))

    def get_config(self, config_name=None):
        config_name = config_name or "default"
        if not hasattr(settings, 'SWAGGER_LOCAL_SETTINGS'):
            raise Exception("SWAGGER_LOCAL_SETTINGS not configured in settings")
        if config_name not in settings.SWAGGER_LOCAL_SETTINGS:
            raise Exception("{} swagger settings not defined in SWAGGER_LOCAL_SETTINGS".format(config_name))

        current_config = self.global_settings.copy()
        current_config.update(settings.SWAGGER_LOCAL_SETTINGS[config_name])
{'fraction_non_alphanumeric': 0.10782934833567745, 'fraction_numerical': 0.0009376465072667605, 'mean_word_length': 3.4, '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': '6179617', 'n_tokens_mistral': 636, 'n_tokens_neox': 635, 'n_words': 111}