<commit_before># -*- coding: utf-8 -*-
from urlparse import urljoin

from django.contrib.syndication.views import Feed

from wagtail.wagtailcore.models import Site

from .models import BlogPage


class BlogPageFeed(Feed):

    def __call__(self, request, *args, **kwargs):
        self.blog_page = BlogPage.objects.get(slug=kwargs['blog_slug'])
        self.request = request
        return super(BlogPageFeed, self).__call__(request, *args, **kwargs)

    def title(self):
        return self.blog_page.title

    def description(self):
        return self.blog_page.description

    def link(self):
        return self.blog_page.slug

    def items(self):
        return self.blog_page.get_entries()[:20]

    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return item.body

    def item_pubdate(self, item):
        return item.date

    def item_enclosure_url(self, item):
        if item.header_image:
            site = Site.find_for_request(self.request)
            return urljoin(site.root_url, item.header_image.file.url)
        return None<commit_msg>Feeds file adapted to Python3<commit_after># -*- coding: utf-8 -*-
from urllib.parse import urlparse

from django.contrib.syndication.views import Feed

from wagtail.wagtailcore.models import Site

from .models import BlogPage


class BlogPageFeed(Feed):

    def __call__(self, request, *args, **kwargs):
        self.blog_page = BlogPage.objects.get(slug=kwargs['blog_slug'])
        self.request = request
        return super(BlogPageFeed, self).__call__(request, *args, **kwargs)

    def title(self):
        return self.blog_page.title

    def description(self):
        return self.blog_page.description

    def link(self):
        return self.blog_page.slug

    def items(self):
        return self.blog_page.get_entries()[:20]

    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return item.body

    def item_pubdate(self, item):
        return item.date

    def item_enclosure_url(self, item):
        if item.header_image:
            site = Site.find_for_request(self.request)
            return urlparse(site.root_url, item.header_image.file.url)
        return None
{'fraction_non_alphanumeric': 0.09973404255319149, 'fraction_numerical': 0.0031028368794326243, 'mean_word_length': 2.9048442906574397, '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': '862961', 'n_tokens_mistral': 692, 'n_tokens_neox': 671, 'n_words': 159}