<commit_before>"""
Applications are great.  Lets have more of them.
"""
import sys
import weakref

from functools import wraps

from werkzeug.routing import Map, Rule

from twisted.python import log
from twisted.python.components import registerAdapter

from twisted.web.server import Site, Request
from twisted.internet import reactor

from zope.interface import implements

from klein.resource import KleinResource
from klein.interfaces import IKleinRequest

__all__ = ['Klein', 'run', 'route', 'resource']


def _call(instance, f, *args, **kwargs):
    if instance is None:
        return f(*args, **kwargs)

    return f(instance, *args, **kwargs)


class KleinRequest(object):
    implements(IKleinRequest)

    def __init__(self, request):
        self.branch_segments = ['']
        self.mapper = None

    def url_for(self, *args, **kwargs):
        return self.mapper.build(*args, **kwargs)


registerAdapter(KleinRequest, Request, IKleinRequest)


class Klein(object):
    """
    L{Klein} is an object which is responsible for maintaining the routing<commit_msg>Use @implementer instead of @implements<commit_after>"""
Applications are great.  Lets have more of them.
"""
import sys
import weakref

from functools import wraps

from werkzeug.routing import Map, Rule

from twisted.python import log
from twisted.python.components import registerAdapter

from twisted.web.server import Site, Request
from twisted.internet import reactor

from zope.interface import implementer

from klein.resource import KleinResource
from klein.interfaces import IKleinRequest

__all__ = ['Klein', 'run', 'route', 'resource']


def _call(instance, f, *args, **kwargs):
    if instance is None:
        return f(*args, **kwargs)

    return f(instance, *args, **kwargs)


@implementer(IKleinRequest)
class KleinRequest(object):

    def __init__(self, request):
        self.branch_segments = ['']
        self.mapper = None

    def url_for(self, *args, **kwargs):
        return self.mapper.build(*args, **kwargs)


registerAdapter(KleinRequest, Request, IKleinRequest)


class Klein(object):
    """
    L{Klein} is an object which is responsible for maintaining the routing
{'fraction_non_alphanumeric': 0.0981114693689544, 'fraction_numerical': 0.0, 'mean_word_length': 4.310513447432763, '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': '1141447', 'n_tokens_mistral': 653, 'n_tokens_neox': 623, 'n_words': 211}