<commit_before>"""
Registry for Djax integrations.
"""
from django.conf import settings
import inspect
from django.db.models import Model
import logging

log = logging.getLogger('djax')

content_registry = {}

class MalformedRegistry(Exception):
    """
    Indicates the Djax registry has been corrupted.
    """

def get_module(module_name):
    """
    Imports and returns the named module.
    """
    module = __import__(module_name)
    components = module_name.split('.')
    for comp in components[1:]:
        module = getattr(module,comp)
    return module

def build_registry():
    """
    Builds the registry.
    """
    from djax.content import AxilentContent
    
    for app_path in settings.INSTALLED_APPS:
        if not ('djax' in app_path):
            try:
                app_module = get_module(app_path)
                if hasattr(app_module,'models'):
                    module = getattr(app_module,'models')
                    for name, attribute in inspect.getmembers(module):
                        if inspect.isclass(attribute) and issubclass(attribute,Model) and issubclass(attribute,AxilentContent):
                            # this is a content model, add to registry
                            try:
                                content_registry[attribute.Axilent.content_type] = attribute
                            except AttributeError:<commit_msg>Adding logging to content registry.<commit_after>"""
Registry for Djax integrations.
"""
from django.conf import settings
import inspect
from django.db.models import Model
import logging

log = logging.getLogger('djax')

content_registry = {}

class MalformedRegistry(Exception):
    """
    Indicates the Djax registry has been corrupted.
    """

def get_module(module_name):
    """
    Imports and returns the named module.
    """
    module = __import__(module_name)
    components = module_name.split('.')
    for comp in components[1:]:
        module = getattr(module,comp)
    return module

def build_registry():
    """
    Builds the registry.
    """
    from djax.content import AxilentContent
    
    for app_path in settings.INSTALLED_APPS:
        if not ('djax' in app_path):
            try:
                log.info('Examining app %s' % app_path)
                app_module = get_module(app_path)
                if hasattr(app_module,'models'):
                    module = getattr(app_module,'models')
                    for name, attribute in inspect.getmembers(module):
                        log.debug('content registry examing module member %s.' % name)
                        if inspect.isclass(attribute) and issubclass(attribute,Model) and issubclass(attribute,AxilentContent):
                            # this is a content model, add to registry
                            try:
                                log.info('Adding model %s to content registry.' % name)
                                content_registry[attribute.Axilent.content_type] = attribute
                            except AttributeError:
{'fraction_non_alphanumeric': 0.08549819138441302, 'fraction_numerical': 0.0006576783952647156, 'mean_word_length': 2.091463414634146, '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': '60302', 'n_tokens_mistral': 794, 'n_tokens_neox': 764, 'n_words': 217}