<commit_before>import re
import pkg_resources
import os.path

from urllib import unquote_plus

from webob import Request

from lxml import etree, html

from repoze.xmliter.serializer import XMLSerializer
from repoze.xmliter.utils import getHTMLSerializer

from diazo.compiler import compile_theme
from diazo.utils import pkg_parse
from diazo.utils import quote_param

DIAZO_OFF_HEADER = 'X-Diazo-Off'

def asbool(value):
    if isinstance(value, basestring):
        value = value.strip().lower()
        if value in ('true', 'yes', 'on', 'y', 't', '1',):
            return True
        elif value in ('false', 'no', 'off', 'n', 'f', '0'):
            return False
        else:
            raise ValueError("String is not true/false: %r" % value)
    else:
        return bool(value)

class DeferStartResponse(object):
    def __init__(self, start_response):
        self.original_start_response = start_response
        self.called = False

    def start_response(self, status, response_headers, exc_info=None):
        assert not self.called
        if exc_info is not None:
            # See http://www.python.org/dev/peps/pep-0333/#the-start-response-callable
            try:
                self.original_start_response(status, response_headers, exc_info)
            finally:
                exc_info = None
                self.called = True
        else:
            self.status = status
            self.response_headers = response_headers

    def finalize(self):
        assert not self.called
        self.original_start_response(status, response_headers)
<commit_msg>DeferStartResponse not needed in the end.<commit_after>import re
import pkg_resources
import os.path

from urllib import unquote_plus

from webob import Request

from lxml import etree, html

from repoze.xmliter.serializer import XMLSerializer
from repoze.xmliter.utils import getHTMLSerializer

from diazo.compiler import compile_theme
from diazo.utils import pkg_parse
from diazo.utils import quote_param

DIAZO_OFF_HEADER = 'X-Diazo-Off'

def asbool(value):
    if isinstance(value, basestring):
        value = value.strip().lower()
        if value in ('true', 'yes', 'on', 'y', 't', '1',):
            return True
        elif value in ('false', 'no', 'off', 'n', 'f', '0'):
            return False
        else:
            raise ValueError("String is not true/false: %r" % value)
    else:
        return bool(value)

{'fraction_non_alphanumeric': 0.0942299709422997, 'fraction_numerical': 0.0033208800332088003, 'mean_word_length': 2.795275590551181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 6}, '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': '1308246', 'n_tokens_mistral': 714, 'n_tokens_neox': 703, 'n_words': 212}