<commit_before>from django.utils.functional import SimpleLazyObject

from .utils import get_user_agent


class UserAgentMiddleware(object):
    # A middleware that adds a "user_agent" object to request
    def process_request(self, request):
        request.user_agent = SimpleLazyObject(lambda: get_user_agent(request))<commit_msg>Update middleware to be django1.10-compatible<commit_after>from django.utils.functional import SimpleLazyObject
from django.utils.deprecation import MiddlewareMixin

from .utils import get_user_agent


class UserAgentMiddleware(MiddlewareMixin):
    # A middleware that adds a "user_agent" object to request
    def process_request(self, request):
        request.user_agent = SimpleLazyObject(lambda: get_user_agent(request))
{'fraction_non_alphanumeric': 0.06596306068601583, 'fraction_numerical': 0.00395778364116095, 'mean_word_length': 5.837837837837838, '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': '1985598', 'n_tokens_mistral': 212, 'n_tokens_neox': 209, 'n_words': 57}