<commit_before>from django import template
from django.template import Node, NodeList, Variable, VariableDoesNotExist

register = template.Library()


@register.filter(name='split')
def split(value):
    return value.replace('\r', '').strip('\n').split('\n')


def do_startswith(parser, token, negate):
    try:
        # split_contents() knows not to split quoted strings.
        tag_name, string, start_string = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError, "%r tag requires two arguments" % token.contents.split()[0]
    if not (start_string[0] == start_string[-1] and start_string[0] in ('"', "'")):
        raise template.TemplateSyntaxError, "%r start strings argument should be in quotes" % tag_name

    end_tag = 'end' + tag_name
    nodelist_true = parser.parse(('else', end_tag))
    token = parser.next_token()
    if token.contents == 'else':
        nodelist_false = parser.parse((end_tag,))
        parser.delete_first_token()
    else:
        nodelist_false = NodeList()
    return IfStartsWithNode(string, start_string, nodelist_true, nodelist_false, negate)


class IfStartsWithNode(Node):
    def __init__(self, string, start_string, nodelist_true, nodelist_false, negate):
        self.start_string, self.string = Variable(start_string), Variable(string)
        self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false<commit_msg>Let's just not strip newlines<commit_after>from django import template
from django.template import Node, NodeList, Variable, VariableDoesNotExist

register = template.Library()


@register.filter(name='split')
def split(value):
    return value.split('\n')


def do_startswith(parser, token, negate):
    try:
        # split_contents() knows not to split quoted strings.
        tag_name, string, start_string = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError, "%r tag requires two arguments" % token.contents.split()[0]
    if not (start_string[0] == start_string[-1] and start_string[0] in ('"', "'")):
        raise template.TemplateSyntaxError, "%r start strings argument should be in quotes" % tag_name

    end_tag = 'end' + tag_name
    nodelist_true = parser.parse(('else', end_tag))
    token = parser.next_token()
    if token.contents == 'else':
        nodelist_false = parser.parse((end_tag,))
        parser.delete_first_token()
    else:
        nodelist_false = NodeList()
    return IfStartsWithNode(string, start_string, nodelist_true, nodelist_false, negate)


class IfStartsWithNode(Node):
    def __init__(self, string, start_string, nodelist_true, nodelist_false, negate):
        self.start_string, self.string = Variable(start_string), Variable(string)
        self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false
{'fraction_non_alphanumeric': 0.11316725978647686, 'fraction_numerical': 0.0028469750889679717, 'mean_word_length': 4.244402985074627, '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': '1658299', 'n_tokens_mistral': 862, 'n_tokens_neox': 832, 'n_words': 208}