<commit_before>import json

from django import template
from django.utils.safestring import mark_safe

import pygments
from pygments.lexers import PythonLexer, JsonLexer
from pygments.formatters import HtmlFormatter

register = template.Library()


@register.filter
def truncate_string(string):
    max_size = 40
    if len(string) > max_size:
        string = string[:max_size/2] + "..." + string[-max_size/2:]
    else:
        pass

    return string


@register.filter
def code_status(code):
    if code.startswith("5"):
        return "error"
    else:<commit_msg>fix not existing error_code startswith bug<commit_after>import json

from django import template
from django.utils.safestring import mark_safe

import pygments
from pygments.lexers import PythonLexer, JsonLexer
from pygments.formatters import HtmlFormatter

register = template.Library()


@register.filter
def truncate_string(string):
    max_size = 40
    if len(string) > max_size:
        string = string[:max_size/2] + "..." + string[-max_size/2:]
    else:
        pass

    return string


@register.filter
def code_status(code=None):
    if code is None:
        code = ""
    else:
        code = str(code)

    if code.startswith("5"):
        return "error"
    else:
{'fraction_non_alphanumeric': 0.09382518043303929, 'fraction_numerical': 0.00801924619085806, 'mean_word_length': 3.3636363636363638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6874264', 'n_tokens_mistral': 405, 'n_tokens_neox': 383, 'n_words': 104}