<commit_before>import inspect
import importlib

from django import apps

from mirrors import components


class MirrorsConfig(apps.AppConfig):
    name = 'mirrors'
    verbose_name = 'Mirrors'

    def ready(self):
        """
        TODO
        This is where we will load all of the components into
        ComponentSchemaCache and adding them to be validated.
        """
        for app in apps.apps.get_app_configs():
            try:
                comps = importlib.import_module(
                    '%s.components' % app.module.__name__)
            except ImportError:
                pass
            else:
                add_components(comps)


def add_components(comps):
    for component_name in dir(comps):
        component = getattr(comps, component_name)
        if inspect.isclass(component) and \
                issubclass(component, components.Component):
            if component.id not in components.ComponentSchemaCache:
                components.ComponentSchemaCache[component.id] = component
                """
                TODO: Add these to the validator here.
                """<commit_msg>hotfix for twice evaluated schemas<commit_after>import inspect
import importlib

from django import apps

from mirrors import components


class MirrorsConfig(apps.AppConfig):
    name = 'mirrors'
    verbose_name = 'Mirrors'

    def ready(self):
        """
        TODO
        This is where we will load all of the components into
        ComponentSchemaCache and adding them to be validated.
        """
        for app in apps.apps.get_app_configs():
            try:
                comps = importlib.import_module(
                    '%s.components' % app.module.__name__)
            except ImportError:
                pass
            else:
                add_components(comps)


def add_components(comps):
    for component_name in dir(comps):
        component = getattr(comps, component_name)
        if inspect.isclass(component) and \
                issubclass(component, components.Component):
            if component.id not in components.ComponentSchemaCache:
                components.ComponentSchemaCache[component.id] = component()
                """
                TODO: Add these to the validator here.
                """
{'fraction_non_alphanumeric': 0.07014467338886453, 'fraction_numerical': 0.0, 'mean_word_length': 1.9070063694267516, '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': '1303583', 'n_tokens_mistral': 580, 'n_tokens_neox': 555, 'n_words': 166}