<commit_before>from django import template
from django.template.defaultfilters import stringfilter
from opensubmit.models import Submission
import os
import opensubmit

register = template.Library()

@register.filter(name='basename')
@stringfilter
def basename(value):
    return os.path.basename(value)

@register.filter(name='state_label_css')
def state_label_css(subm):
    green_label = "badge label label-success"
    red_label = "badge label label-important"
    grey_label = "badge label label-info"
    # We expect a submission as input
    if subm.is_closed() and subm.grading:
        if subm.grading.means_passed:
            return green_label
        else:
            return red_label
    if subm.state in [subm.SUBMITTED_TESTED, subm.SUBMITTED, subm.TEST_FULL_PENDING, subm.GRADED, subm.TEST_FULL_FAILED]:
        return green_label
    if subm.state = subm.TEST_VALIDITY_FAILED:
        return red_label
    return grey_label

@register.assignment_tag
def setting(name):
    return getattr(opensubmit.settings, name, "")

@register.inclusion_tag('inclusion_tags/details_table.html')
def details_table(submission):
    return {'submission': submission}
<commit_msg>PEP-8<commit_after>from django import template
from django.template.defaultfilters import stringfilter
import os
import opensubmit

register = template.Library()


@register.filter(name='basename')
@stringfilter
def basename(value):
    return os.path.basename(value)


@register.filter(name='state_label_css')
def state_label_css(subm):
    green_label = "badge label label-success"
    red_label = "badge label label-important"
    grey_label = "badge label label-info"
    # We expect a submission as input
    if subm.is_closed() and subm.grading:
        if subm.grading.means_passed:
            return green_label
        else:
            return red_label
    if subm.state in [subm.SUBMITTED_TESTED,
                      subm.SUBMITTED,
                      subm.TEST_FULL_PENDING,
                      subm.GRADED,
                      subm.TEST_FULL_FAILED]:
        return green_label
    if subm.state == subm.TEST_VALIDITY_FAILED:
        return red_label
    return grey_label


@register.assignment_tag
def setting(name):
    return getattr(opensubmit.settings, name, "")


@register.inclusion_tag('inclusion_tags/details_table.html')
def details_table(submission):
    return {'submission': submission}
{'fraction_non_alphanumeric': 0.08531002913025384, 'fraction_numerical': 0.0004161464835622139, 'mean_word_length': 3.4684014869888475, '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': '5617940', 'n_tokens_mistral': 731, 'n_tokens_neox': 740, 'n_words': 166}