<commit_before>__all__ = ('register_widget',)
from django.utils.translation import ugettext as _

class WidgetAlreadyRegistered(Exception):
    """
    An attempt was made to register a widget for Django page CMS more
    than once.
    """
    pass

class WidgetNotFound(Exception):
    """
    The requested widget was not found
    """
    pass

registry = []

def register_widget(widget):

    if widget in registry:
        raise AlreadyRegistered(
            _('The widget %s has already been registered.') % widget.__name__)
    registry.append(widget)

def get_widget(name):

    for widget in registry:
        if widget.__name__ == name:
            return widget
    raise WidgetNotFound(
        _('The widget %s has not been registered.') % name)<commit_msg>Fix widget registry exception handling code<commit_after>__all__ = ('register_widget',)
from django.utils.translation import ugettext as _

class WidgetAlreadyRegistered(Exception):
    """
    An attempt was made to register a widget for Django page CMS more
    than once.
    """
    pass

class WidgetNotFound(Exception):
    """
    The requested widget was not found
    """
    pass

registry = []

def register_widget(widget):

    if widget in registry:
        raise WidgetAlreadyRegistered(_('The widget %s has already been registered.') % widget.__name__)
    registry.append(widget)

def get_widget(name):

    for widget in registry:
        if widget.__name__ == name:
            return widget
    raise WidgetNotFound(
        _('The widget %s has not been registered.') % name)
{'fraction_non_alphanumeric': 0.08551372048500319, 'fraction_numerical': 0.0, 'mean_word_length': 3.030848329048843, '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': '2195649', 'n_tokens_mistral': 422, 'n_tokens_neox': 415, 'n_words': 149}