<commit_before>from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
from jingo.helpers import datetime

from tower import ugettext as _

import amo
from amo.urlresolvers import reverse
from amo.helpers import absolutify, url

from addons.models import Addon

import urllib


class VersionsRss(Feed):

    addon = None

    def get_object(self, request, addon_id):
        """Get the Addon for which we are about to output
           the RSS feed of it Versions"""
        self.addon = get_object_or_404(Addon.objects.valid(), pk=addon_id)
        return self.addon

    def title(self, addon):
        """Title for the feed"""
        return _('%s Version History') % addon.name

    def link(self, addon):
        """Link for the feed"""
        return absolutify(url('home'))

    def description(self, addon):
        """Description for the feed"""
        return _('Version History with Changelogs')

    def items(self, obj):
        """Return the Versions for this Addon to be output as RSS <item>'s"""
        qs = (obj.versions.filter(files__status__in=amo.VALID_STATUSES)
              .distinct().order_by('-created'))
        return qs.all()[:30]

    def item_link(self, version):
        """Link for a particular version (<item><link>)"""
        return reverse('addons.versions', args=[version.addon_id, version.version])

    def item_title(self, version):
        """Title for particular version (<item><title>)"""
        # L10n: This is the Title for this Version of the Addon
        return '{name} {version} - {created}'.format(
            name=self.addon.name, version=version.version,
                 created=datetime(version.created))

    def item_description(self, version):
        """Description for particular version (<item><description>)"""
        return version.releasenotes

    def item_guid(self, version):
        """Guid for a particuar version  (<item><guid>)"""
        url = absolutify(reverse('addons.versions', args=[version.addon_id]))
        return "%s#version-%s" % (url, version.version)

    def item_author_name(self, version):<commit_msg>fixing unicode error when formatting title<commit_after>from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
from jingo.helpers import datetime

from tower import ugettext as _

import amo
from amo.urlresolvers import reverse
from amo.helpers import absolutify, url

from addons.models import Addon

import urllib


class VersionsRss(Feed):

    addon = None

    def get_object(self, request, addon_id):
        """Get the Addon for which we are about to output
           the RSS feed of it Versions"""
        self.addon = get_object_or_404(Addon.objects.valid(), pk=addon_id)
        return self.addon

    def title(self, addon):
        """Title for the feed"""
        return _('%s Version History') % addon.name

    def link(self, addon):
        """Link for the feed"""
        return absolutify(url('home'))

    def description(self, addon):
        """Description for the feed"""
        return _('Version History with Changelogs')

    def items(self, obj):
        """Return the Versions for this Addon to be output as RSS <item>'s"""
        qs = (obj.versions.filter(files__status__in=amo.VALID_STATUSES)
              .distinct().order_by('-created'))
        return qs.all()[:30]

    def item_link(self, version):
        """Link for a particular version (<item><link>)"""
        return reverse('addons.versions', args=[version.addon_id, version.version])

    def item_title(self, version):
        """Title for particular version (<item><title>)"""
        # L10n: This is the Title for this Version of the Addon
        return u'{name} {version} - {created}'.format(
            name=self.addon.name, version=version.version,
                 created=datetime(version.created))

    def item_description(self, version):
        """Description for particular version (<item><description>)"""
        return version.releasenotes

    def item_guid(self, version):
        """Guid for a particuar version  (<item><guid>)"""
        url = absolutify(reverse('addons.versions', args=[version.addon_id]))
        return "%s#version-%s" % (url, version.version)

    def item_author_name(self, version):
{'fraction_non_alphanumeric': 0.11726384364820847, 'fraction_numerical': 0.004653327128897162, 'mean_word_length': 3.1257197696737045, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4501814', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1234, 'n_words': 372}