<commit_before>""" mail app views"""

from django.http import Http404
from django.http import HttpResponse

from mail.models import Receiver, Mail, generate_mail


def mail_demo_view(request, mail_id, receiver_id):
    """ final mail demo """
    mail = None
    receiver = None

    if mail_id:
        mail = Mail.objects.get(pk=mail_id)

    if receiver_id:
        receiver = Receiver.objects.get(pk=receiver_id)

    if mail and receiver:
        return HttpResponse(generate_mail(mail, receiver))
    else:
        return Http404("mail or receiver not exist")
<commit_msg>handle 404<commit_after>""" mail app views"""

from django.http import Http404
from django.http import HttpResponse

from mail.models import Receiver, Mail, generate_mail


def mail_demo_view(request, mail_id, receiver_id):
    """ final mail demo """
    if mail_id:
        try:
            mail = Mail.objects.get(pk=mail_id)
        except Mail.DoesNotExist:
            mail = None

    if receiver_id:
        try:
            receiver = Receiver.objects.get(pk=receiver_id)
        except Receiver.DoesNotExist:
            receiver = None

    if mail and receiver:
        return HttpResponse(generate_mail(mail, receiver))
    else:
        raise Http404("mail or receiver not exist")

{'fraction_non_alphanumeric': 0.08641005498821681, 'fraction_numerical': 0.01178318931657502, 'mean_word_length': 2.8960244648318043, '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': '2301864', 'n_tokens_mistral': 383, 'n_tokens_neox': 368, 'n_words': 109}