<commit_before>import datetime
from pyramid.view import view_config
from pyramid.url import resource_url
import colander
from deform import Form
from deform.exception import ValidationFailure
from rezoirclogs.resources import Directory, Chan, LogFile


@view_config(context=Directory, renderer='directory.jinja2')
def directory(context, request):
    return {'dir': context}


@view_config(context=Chan, renderer='chan.jinja2')
def chan(context, request):
    return {'chan': context}


@view_config(context=LogFile, renderer='logfile.jinja2')
def logfile(context, request):
    lines = list(context)
    for i, line in enumerate(lines):
        line.type # to force the computation
        if hasattr(line, 'time'):
            line.anchor = '%s' % i
            line.anchorlink = resource_url(context, request, anchor = line.anchor)

    for rang in request.GET.getall('range'):
        try:
            fro, to = map(int, rang.split('-'))
            for i in range(fro, to):
                lines[i].highlighted = True
        except ValueError:
            pass
        except IndexError:
            pass

    return {'lines': lines, 'context': context}


class Search(colander.MappingSchema):
    query = colander.SchemaNode(colander.String(), validator = colander.Length(min=3))
    after_date = colander.SchemaNode(colander.Date(), title='Search after the date',
                                     missing=None, default=(datetime.date.today() - datetime.timedelta(30)))

search_form = Form(Search(), action='search', buttons=('search',))


@view_config(name='search', renderer='search.jinja2')
def search(context, request):
    if 'search' in request.POST:
        try:<commit_msg>Correction d'un bug stupide, merci lucie.<commit_after>import datetime
from pyramid.view import view_config
from pyramid.url import resource_url
import colander
from deform import Form
from deform.exception import ValidationFailure
from rezoirclogs.resources import Directory, Chan, LogFile


@view_config(context=Directory, renderer='directory.jinja2')
def directory(context, request):
    return {'dir': context}


@view_config(context=Chan, renderer='chan.jinja2')
def chan(context, request):
    return {'chan': context}


@view_config(context=LogFile, renderer='logfile.jinja2')
def logfile(context, request):
    lines = list(context)
    for i, line in enumerate(lines):
        line.type # to force the computation
        if hasattr(line, 'time'):
            line.anchor = '%s' % i
            line.anchorlink = resource_url(context, request, anchor = line.anchor)

    for rang in request.GET.getall('range'):
        try:
            fro, to = map(int, rang.split('-'))
            for i in range(fro, to):
                lines[i].highlighted = True
        except ValueError:
            pass
        except IndexError:
            pass

    return {'lines': lines, 'context': context}


class Search(colander.MappingSchema):
    query = colander.SchemaNode(colander.String(), validator = colander.Length(min=3))
    after_date = colander.SchemaNode(colander.Date(), title='Search after the date',
                                     missing=None, default=(datetime.date.today() - datetime.timedelta(30)))


@view_config(name='search', renderer='search.jinja2')
def search(context, request):
    search_form = Form(Search(), action='search', buttons=('search',))
    if 'search' in request.POST:
        try:
{'fraction_non_alphanumeric': 0.11976573938506589, 'fraction_numerical': 0.004099560761346999, 'mean_word_length': 3.346055979643766, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7420695', 'n_tokens_mistral': 1012, 'n_tokens_neox': 955, 'n_words': 256}