<commit_before>from urllib.parse import parse_qs, urlsplit, urlunsplit

from django.shortcuts import render, redirect
from django.urls import reverse, NoReverseMatch
from django.utils.http import is_safe_url, urlencode


def get_next(request):
    # This is not a view
    return request.GET.get("next", request.META.get("HTTP_REFERER", "/"))


def render_code(code, request, context={}):
    return render(request, "%d.html" % code, context,
            status=code)


def render_400(request):
    return render_code(400, request)


def render_405(request):
    return render_code(405, request)


def render_403(request, message=''):
    if not request.user.is_authenticated:
        return get_redirect(request, 'account-login', params={'next': request.get_full_path()})
    return render_code(403, request,
            context={"message": message})


def get_client_ip(request):
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
    if x_forwarded_for:
        ip = x_forwarded_for.split(',')[-1].strip()<commit_msg>Fix 403 render func<commit_after>from urllib.parse import parse_qs, urlsplit, urlunsplit

from django.shortcuts import render, redirect
from django.urls import reverse, NoReverseMatch
from django.utils.http import is_safe_url, urlencode


def get_next(request):
    # This is not a view
    return request.GET.get("next", request.META.get("HTTP_REFERER", "/"))


def render_code(code, request, context={}):
    return render(request, "%d.html" % code, context,
            status=code)


def render_400(request):
    return render_code(400, request)


def render_405(request):
    return render_code(405, request)


def render_403(request, message=''):
    if not request.user.is_authenticated:
        return get_redirect(request, default='account-login', params={'next': request.get_full_path()})
    return render_code(403, request,
            context={"message": message})


def get_client_ip(request):
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
    if x_forwarded_for:
        ip = x_forwarded_for.split(',')[-1].strip()
{'fraction_non_alphanumeric': 0.12078922040423484, 'fraction_numerical': 0.01973051010587103, 'mean_word_length': 4.471052631578948, 'pattern_counts': {'":': 2, '<': 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': '5794073', 'n_tokens_mistral': 698, 'n_tokens_neox': 658, 'n_words': 152}