<commit_before>"""
Password hashers for Modoboa.
"""
from modoboa.core.password_hashers.base import (
    PLAINHasher, CRYPTHasher, MD5Hasher, SHA256Hasher
)
from modoboa.core.password_hashers.advanced import (
    MD5CRYPTHasher, SHA256CRYPTHasher, SHA512CRYPTHasher
)


def get_password_hasher(scheme):
    """Retrieve the hasher corresponding to :keyword:`scheme`.

    If no class is found, `PLAINHasher` is returned.

    :param str scheme: a valid scheme name
    :rtype: PasswordHasher sub class
    :return: The hasher class
    """
    try:
        scheme = scheme.replace('-', '')
        hasher = globals()['%sHasher' % scheme]
    except AttributeError:
        hasher = PLAINHasher
    return hasher<commit_msg>Catch the proper exception and force the schem to upper case.<commit_after>"""
Password hashers for Modoboa.
"""
from modoboa.core.password_hashers.base import (
    PLAINHasher, CRYPTHasher, MD5Hasher, SHA256Hasher
)
from modoboa.core.password_hashers.advanced import (
    MD5CRYPTHasher, SHA256CRYPTHasher, SHA512CRYPTHasher
)


def get_password_hasher(scheme):
    """Retrieve the hasher corresponding to :keyword:`scheme`.

    If no class is found, `PLAINHasher` is returned.

    :param str scheme: a valid scheme name
    :rtype: PasswordHasher sub class
    :return: The hasher class
    """
    try:
        scheme = scheme.replace('-', '')
        hasher = globals()['%sHasher' % scheme.upper()]
    except KeyError:
        hasher = PLAINHasher
    return hasher
{'fraction_non_alphanumeric': 0.09746328437917223, 'fraction_numerical': 0.014686248331108143, 'mean_word_length': 3.6697819314641746, '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': '2127275', 'n_tokens_mistral': 507, 'n_tokens_neox': 480, 'n_words': 131}