<commit_before>from pygments import highlight
from pygments.lexers import guess_lexer_for_filename
from pygments.formatters import HtmlFormatter

from django.http import HttpResponse
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext

from django_git.utils import *

def index(request, template_name='django_git/index.html'):
    return render_to_response(template_name, {'repos': get_repos()}, context_instance=RequestContext(request))

def repo(request, repo, template_name='django_git/repo.html'):
    return render_to_response(template_name, {'repo': get_repo(repo)}, context_instance=RequestContext(request))

def commit(request, repo, commit, template_name='django_git/commit.html'):
    return render_to_response(template_name, {'diffs': get_commit(repo, commit).diffs, 'repo': get_repo(repo), 'commit': commit }, context_instance=RequestContext(request))

def blob(request, repo, commit):
    file = request.GET.get('file', '')
    blob = get_blob(repo, commit, file)
    lexer = guess_lexer_for_filename(blob.basename, blob.data)
    return HttpResponse(highlight(blob.data, lexer, HtmlFormatter(cssclass="pygment_highlight", linenos='inline')))<commit_msg>Add newline to end of file<commit_after>from pygments import highlight
from pygments.lexers import guess_lexer_for_filename
from pygments.formatters import HtmlFormatter

from django.http import HttpResponse
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext

from django_git.utils import *

def index(request, template_name='django_git/index.html'):
    return render_to_response(template_name, {'repos': get_repos()}, context_instance=RequestContext(request))

def repo(request, repo, template_name='django_git/repo.html'):
    return render_to_response(template_name, {'repo': get_repo(repo)}, context_instance=RequestContext(request))

def commit(request, repo, commit, template_name='django_git/commit.html'):
    print repo, commit
    return render_to_response(template_name, {'diffs': get_commit(repo, commit).diffs, 'repo': get_repo(repo), 'commit': commit }, context_instance=RequestContext(request))

def blob(request, repo, commit):
    file = request.GET.get('file', '')
    blob = get_blob(repo, commit, file)
    lexer = guess_lexer_for_filename(blob.basename, blob.data)
    return HttpResponse(highlight(blob.data, lexer, HtmlFormatter(cssclass="pygment_highlight", linenos='inline')))
{'fraction_non_alphanumeric': 0.10992063492063492, 'fraction_numerical': 0.004761904761904762, 'mean_word_length': 7.84561403508772, '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': '2441739', 'n_tokens_mistral': 773, 'n_tokens_neox': 740, 'n_words': 165}