<commit_before>from django.http import HttpResponse, HttpResponseServerError
from django.template import RequestContext, loader
from django.conf import settings

from maintenancemode.http import HttpResponseTemporaryUnavailable

import logging
logger = logging.getLogger('comrade.views.simple')

def status(request):
    logger.info("Responding to status check")
    return HttpResponse()

def server_error(request, template_name='500.html'):
    t = loader.get_template(template_name) 
    return HttpResponseServerError(t.render(RequestContext(request)))

def maintenance_mode(request, template_name='503.html'):
    t = loader.get_template(template_name)
    return HttpResponseTemporaryUnavailable(t.render(RequestContext(request)))

def direct_to_template(request, template, extra_context=None, status=None,
        mimetype=None, **kwargs):
    '''
    Duplicates behavior of django.views.generic.simple.direct_to_template
    but accepts a status
    '''
    if extra_context is None:
        extra_context = {}

    dictionary = {'params': kwargs}
    for key, value in extra_context.items():
        if callable(value):
            dictionary[key] = value()
        else:
            dictionary[key] = value

    c = RequestContext(request, dictionary)
    t = loader.get_template(template)
<commit_msg>Make status the last optional arg.<commit_after>from django.http import HttpResponse, HttpResponseServerError
from django.template import RequestContext, loader
from django.conf import settings

from maintenancemode.http import HttpResponseTemporaryUnavailable

import logging
logger = logging.getLogger('comrade.views.simple')

def status(request):
    logger.info("Responding to status check")
    return HttpResponse()

def server_error(request, template_name='500.html'):
    t = loader.get_template(template_name) 
    return HttpResponseServerError(t.render(RequestContext(request)))

def maintenance_mode(request, template_name='503.html'):
    t = loader.get_template(template_name)
    return HttpResponseTemporaryUnavailable(t.render(RequestContext(request)))

def direct_to_template(request, template, extra_context=None, mimetype=None,
        status=None, **kwargs):
    '''
    Duplicates behavior of django.views.generic.simple.direct_to_template
    but accepts a status argument.
    '''
    if extra_context is None:
        extra_context = {}

    dictionary = {'params': kwargs}
    for key, value in extra_context.items():
        if callable(value):
            dictionary[key] = value()
        else:
            dictionary[key] = value

    c = RequestContext(request, dictionary)
    t = loader.get_template(template)

{'fraction_non_alphanumeric': 0.09340866290018833, 'fraction_numerical': 0.004519774011299435, 'mean_word_length': 4.409368635437882, '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': '2607018', 'n_tokens_mistral': 724, 'n_tokens_neox': 708, 'n_words': 174}