<commit_before># -*- coding: utf-8 -*-

import hashlib

from django.conf import settings
from django.core.cache import cache
from django.utils.encoding import smart_str
from django.contrib.sites.models import get_current_site

CACHE_PREFIX = getattr(settings, 'CRUMBS_CACHE_PREFIX', 'CRUMBS')
CACHE_TIMEOUT = getattr(settings, 'CRUMBS_CACHE_TIMEOUT', 3600)


def make_cache_key(domain, path, cache_prefix):
    return '%s:%s' % (cache_prefix, hashlib.md5(smart_str('%s%s' % (
        domain, path))).hexdigest())


class CrumbsMixin(object):

    def __init__(self, *args, **kwargs):
        super(CrumbsMixin, self).__init__(*args, **kwargs)
        if not hasattr(self, 'cache_prefix'):
            self.cache_prefix = CACHE_PREFIX
        if not hasattr(self, 'cache_timeout'):
            self.cache_timeout = CACHE_TIMEOUT

    def get_cache_key(self):
        current_site = get_current_site(self.request)

        return make_cache_key(<commit_msg>overrideble cache_prefix / cache_timeout<commit_after># -*- coding: utf-8 -*-

import hashlib

from django.conf import settings
from django.core.cache import cache
from django.utils.encoding import smart_str
from django.contrib.sites.models import get_current_site

CACHE_PREFIX = getattr(settings, 'CRUMBS_CACHE_PREFIX', 'CRUMBS')
CACHE_TIMEOUT = getattr(settings, 'CRUMBS_CACHE_TIMEOUT', 3600)


def make_cache_key(domain, path, cache_prefix):
    return '%s:%s' % (cache_prefix, hashlib.md5(smart_str('%s%s' % (
        domain, path))).hexdigest())


class CrumbsMixin(object):

    def __init__(self, *args, **kwargs):
        super(CrumbsMixin, self).__init__(*args, **kwargs)
        if not hasattr(self, 'cache_prefix'):
            self._cache_prefix = CACHE_PREFIX
        if not hasattr(self, 'cache_timeout'):
            self._cache_timeout = CACHE_TIMEOUT

    @property
    def cache_prefix(self):
        return self._cache_prefix

    @property
    def cache_timeout(self):
        return self._cache_timeout

    def get_cache_key(self):
        current_site = get_current_site(self.request)

        return make_cache_key(
{'fraction_non_alphanumeric': 0.11121718377088305, 'fraction_numerical': 0.005727923627684964, 'mean_word_length': 3.908665105386417, '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': '57503', 'n_tokens_mistral': 677, 'n_tokens_neox': 659, 'n_words': 143}