<commit_before>"""Splits query results list into multiple sublists for template display."""

from django.template import Library, Node, TemplateSyntaxError

register = Library()


class SplitListNode(Node):
    def __init__(self, results, cols, new_results):
        self.results, self.cols, self.new_results = results, cols, new_results

    def split_seq(self, results, cols=2):
        start = 0
        results = list(results)
        for i in xrange(cols):
            stop = start + len(results[i::cols])
            yield results[start:stop]
            start = stop

    def render(self, context):
        context[self.new_results] = self.split_seq(
            context[self.results], int(self.cols))
        return ''


def list_to_columns(parser, token):
    """Parse template tag: {% list_to_colums results as new_results 2 %}"""
    bits = token.contents.split()
    if len(bits) != 5:
        raise TemplateSyntaxError("list_to_columns results as new_results 2")
    if bits[2] != 'as':
        raise TemplateSyntaxError("second argument to the list_to_columns "
            "tag must be 'as'")
    return SplitListNode(bits[1], bits[4], bits[3])


list_to_columns = register.tag(list_to_columns)<commit_msg>Fix typo<commit_after>"""Splits query results list into multiple sublists for template display."""

from django.template import Library, Node, TemplateSyntaxError

register = Library()


class SplitListNode(Node):
    def __init__(self, results, cols, new_results):
        self.results, self.cols, self.new_results = results, cols, new_results

    def split_seq(self, results, cols=2):
        start = 0
        results = list(results)
        for i in xrange(cols):
            stop = start + len(results[i::cols])
            yield results[start:stop]
            start = stop

    def render(self, context):
        context[self.new_results] = self.split_seq(
            context[self.results], int(self.cols))
        return ''


def list_to_columns(parser, token):
    """Parse template tag: {% list_to_columns results as new_results 2 %}"""
    bits = token.contents.split()
    if len(bits) != 5:
        raise TemplateSyntaxError("list_to_columns results as new_results 2")
    if bits[2] != 'as':
        raise TemplateSyntaxError("second argument to the list_to_columns "
            "tag must be 'as'")
    return SplitListNode(bits[1], bits[4], bits[3])


list_to_columns = register.tag(list_to_columns)
{'fraction_non_alphanumeric': 0.11156685808039377, 'fraction_numerical': 0.007383100902378999, 'mean_word_length': 3.1621160409556315, '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': '3389633', 'n_tokens_mistral': 734, 'n_tokens_neox': 704, 'n_words': 198}