<commit_before># django imports
from django.conf import settings
from django.core.cache import cache
from django.template import Library, Node, TemplateSyntaxError
from django.utils.translation import ugettext as _

# portlets imports
import portlets.utils
from portlets.models import Slot

register = Library()

class SlotsInformationNode(Node):
    """
    """
    def render(self, context):
        obj = context.get("lfc_context")
        request = context.get("request")

        if obj:
            cache_key = "%s-slots-information-%s-%s-%s" % \
                (settings.CACHE_MIDDLEWARE_KEY_PREFIX, obj.content_type, obj.id, request.user.id)
        else:
            cache_key = "%s-slots-information-portal-%s" % \
                (settings.CACHE_MIDDLEWARE_KEY_PREFIX, request.user.id)

        info = cache.get(cache_key)
        if info:
            context["content_class"] = info["content_class"]
            context["SlotLeft"] = info["SlotLeft"]
            context["SlotRight"] = info["SlotRight"]
            return ''

        if obj:
            obj = obj.get_content_object()

        for slot in Slot.objects.all():
            context["Slot%s" % slot.name] = portlets.utils.has_portlets(slot, obj)

        if context["SlotLeft"] and context["SlotRight"]:
            content_class = "span-13 append-1"
        elif context["SlotLeft"]:
            content_class = "span-18 last"
        elif context["SlotRight"]:
            content_class = "span-18 append-1"
        else:
            content_class = "span-24 last"

        cache.set(cache_key, {
            "content_class" : content_class,
            "SlotLeft" : context["SlotLeft"],
            "SlotRight" : context["SlotRight"],
        })
<commit_msg>Take care of the new portlets API<commit_after># django imports
from django.conf import settings
from django.core.cache import cache
from django.template import Library, Node, TemplateSyntaxError
from django.utils.translation import ugettext as _

# portlets imports
import portlets.utils
from portlets.models import Slot

register = Library()

class SlotsInformationNode(Node):
    """
    """
    def render(self, context):
        obj = context.get("lfc_context")
        request = context.get("request")

        if obj:
            cache_key = "%s-slots-information-%s-%s-%s" % \
                (settings.CACHE_MIDDLEWARE_KEY_PREFIX, obj.content_type, obj.id, request.user.id)
        else:
            cache_key = "%s-slots-information-portal-%s" % \
                (settings.CACHE_MIDDLEWARE_KEY_PREFIX, request.user.id)

        info = cache.get(cache_key)
        if info:
            context["content_class"] = info["content_class"]
            context["SlotLeft"] = info["SlotLeft"]
            context["SlotRight"] = info["SlotRight"]
            return ''

        if obj:
            obj = obj.get_content_object()

        for slot in Slot.objects.all():
            context["Slot%s" % slot.name] = portlets.utils.has_portlets(obj, slot)

        if context["SlotLeft"] and context["SlotRight"]:
            content_class = "span-13 append-1"
        elif context["SlotLeft"]:
            content_class = "span-18 last"
        elif context["SlotRight"]:
            content_class = "span-18 append-1"
        else:
            content_class = "span-24 last"

        cache.set(cache_key, {
            "content_class" : content_class,
            "SlotLeft" : context["SlotLeft"],
            "SlotRight" : context["SlotRight"],
        })

{'fraction_non_alphanumeric': 0.11842105263157894, 'fraction_numerical': 0.005720823798627002, 'mean_word_length': 2.3209876543209877, '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': '2220949', 'n_tokens_mistral': 1020, 'n_tokens_neox': 997, 'n_words': 216}