<commit_before>from django.contrib.sites.models import Site
from django.core.urlresolvers import NoReverseMatch, reverse
from django.views.decorators.cache import cache_page
from django.views.generic import ListView

from robots import settings
from robots.models import Rule


class RuleList(ListView):
    """
    Returns a generated robots.txt file with correct mimetype (text/plain),
    status code (200 or 404), sitemap url (automatically).
    """
    model = Rule
    context_object_name = 'rules'
    cache_timeout = settings.CACHE_TIMEOUT

    def get_current_site(self, request):
        if settings.SITE_BY_REQUEST:
            return Site.objects.get(domain=request.get_host())
        else:
            return Site.objects.get_current()

    def reverse_sitemap_url(self):
        try:
            return reverse('django.contrib.sitemaps.views.index')
        except NoReverseMatch:
            try:
                return reverse('django.contrib.sitemaps.views.sitemap')
            except NoReverseMatch:
                pass
<commit_msg>Fix deprecated reverse<commit_after>from django.contrib.sites.models import Site
from django.core.urlresolvers import NoReverseMatch, reverse
from django.views.decorators.cache import cache_page
from django.views.generic import ListView
from django.contrib.sitemaps import views as sitemap_views

from robots import settings
from robots.models import Rule


class RuleList(ListView):
    """
    Returns a generated robots.txt file with correct mimetype (text/plain),
    status code (200 or 404), sitemap url (automatically).
    """
    model = Rule
    context_object_name = 'rules'
    cache_timeout = settings.CACHE_TIMEOUT

    def get_current_site(self, request):
        if settings.SITE_BY_REQUEST:
            return Site.objects.get(domain=request.get_host())
        else:
            return Site.objects.get_current()

    def reverse_sitemap_url(self):
        try:
            return reverse(sitemap_views.index)
        except NoReverseMatch:
            try:
                return reverse(sitemap_views.sitemap)
            except NoReverseMatch:
                pass

{'fraction_non_alphanumeric': 0.07383177570093458, 'fraction_numerical': 0.005607476635514018, 'mean_word_length': 2.8998178506375227, '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': '5647842', 'n_tokens_mistral': 615, 'n_tokens_neox': 577, 'n_words': 154}