<commit_before># coding: utf-8

from django.conf.urls import patterns, url
from django.contrib import admin
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django_clear_memcache.clear import ClearMemcacheController, ClearMemcacheNoCacheFoundError
from django_clear_memcache.models import ClearMemcache
import json


########################################################################
class ClearMemcacheAdmin(admin.ModelAdmin):
    model = ClearMemcache
    change_list_template = 'admin/clear_memcache.html'

    #----------------------------------------------------------------------
    def get_queryset(self, request):
        """Override queryset to return a simple empty queryset
           as we do not really have a real model anyway"""
        return ClearMemcache.objects.none()

    queryset = get_queryset

    #----------------------------------------------------------------------
    def has_add_permission(self, request):
        """A fake model should not be added"""
        return False

    #----------------------------------------------------------------------
    def has_delete_permission(self, request, obj=None):
        """A fake model should not be added"""
        return False

    #----------------------------------------------------------------------
    def get_urls(self):
        urls = admin.ModelAdmin.get_urls(self)
        my_urls = patterns(
            '',
            url(r'^clear/$', self.admin_site.admin_view(self.clear), name='clear_cache'),
            url(r'^list/$', self.admin_site.admin_view(self.list_cache_items), name='cache_list_keys'),
        )
        return my_urls + urls

    #----------------------------------------------------------------------
    def clear(self, request):
        # clear the cache
        use_prefix = 'clear_prefix' in request.POST<commit_msg>Drop  deprecated django.conf.urls.patterns<commit_after># coding: utf-8

from django.conf.urls import url
from django.contrib import admin
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django_clear_memcache.clear import ClearMemcacheController, ClearMemcacheNoCacheFoundError
from django_clear_memcache.models import ClearMemcache
import json


########################################################################
class ClearMemcacheAdmin(admin.ModelAdmin):
    model = ClearMemcache
    change_list_template = 'admin/clear_memcache.html'

    #----------------------------------------------------------------------
    def get_queryset(self, request):
        """Override queryset to return a simple empty queryset
           as we do not really have a real model anyway"""
        return ClearMemcache.objects.none()

    queryset = get_queryset

    #----------------------------------------------------------------------
    def has_add_permission(self, request):
        """A fake model should not be added"""
        return False

    #----------------------------------------------------------------------
    def has_delete_permission(self, request, obj=None):
        """A fake model should not be added"""
        return False

    #----------------------------------------------------------------------
    def get_urls(self):
        urls = admin.ModelAdmin.get_urls(self)
        my_urls = [
            url(r'^clear/$', self.admin_site.admin_view(self.clear), name='clear_cache'),
            url(r'^list/$', self.admin_site.admin_view(self.list_cache_items), name='cache_list_keys'),
        ]
        return my_urls + urls

    #----------------------------------------------------------------------
    def clear(self, request):
        # clear the cache
        use_prefix = 'clear_prefix' in request.POST
{'fraction_non_alphanumeric': 0.2794154698916604, 'fraction_numerical': 0.0005039052658100278, 'mean_word_length': 1.7665505226480835, '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': '2950427', 'n_tokens_mistral': 916, 'n_tokens_neox': 905, 'n_words': 243}