<commit_before>from __future__ import unicode_literals

from django.conf import settings

from rest_framework import viewsets

from .models import (
    People,
    Planet,
    Film,
    Species,
    Vehicle,
    Starship
)

from .serializers import (
    PeopleSerializer,
    PlanetSerializer,
    FilmSerializer,
    SpeciesSerializer,
    VehicleSerializer,
    StarshipSerializer
)

import dkeen as keen


def keen_hit(type, resource, request):
    if not settings.KEEN_DEBUG:
        ip = request.META['REMOTE_ADDR'] if request.META['REMOTE_ADDR'] else ''
        if request.META['HTTP_USER_AGENT']:
            user_agent = request.META['HTTP_USER_AGENT']
        else:
            user_agent = ''<commit_msg>fix dict lookup<commit_after>from __future__ import unicode_literals

from django.conf import settings

from rest_framework import viewsets

from .models import (
    People,
    Planet,
    Film,
    Species,
    Vehicle,
    Starship
)

from .serializers import (
    PeopleSerializer,
    PlanetSerializer,
    FilmSerializer,
    SpeciesSerializer,
    VehicleSerializer,
    StarshipSerializer
)

import dkeen as keen


def keen_hit(type, resource, request):
    if not settings.KEEN_DEBUG:
        ip = request.META['REMOTE_ADDR'] if 'REMOTE_ADDR' in request.META else 'none'
        if 'HTTP_USER_AGENT' in request.META:
            user_agent = request.META['HTTP_USER_AGENT']
        else:
            user_agent = 'none'
{'fraction_non_alphanumeric': 0.07468879668049792, 'fraction_numerical': 0.0, 'mean_word_length': 3.053221288515406, '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': '7204583', 'n_tokens_mistral': 455, 'n_tokens_neox': 450, 'n_words': 112}