<commit_before>from twisted.application import service
from twisted.internet import defer
from twisted.python import log

from axiom import item, attributes

from ikdisplay.source import ISource

class Feed(item.Item):
    """
    A feed represents the aggregate stream of items of its sources.

    To pass notifications onto an aggregator, a Service named C{'aggregator'}
    must have been added as a subservice of the store the feed is stored in:

        >>> agg = LoggingAggregator()
        >>> agg.setName('aggregator')
        >>> agg.setServiceParent(service.IService(store))
    """

    typeName = 'Feed'

    handle = attributes.text(allowNone=False)
    title = attributes.text()
    language = attributes.text(default=u'en')

    def processNotifications(self, notifications):
        """
        Send on notifications to the aggregator.

        This finds the globally available aggregator service and passes it
        the notifications using this feed's handle.
        """
        aggregator = service.IService(self.store).getServiceNamed('aggregator')
        aggregator.processNotifications(self.handle, notifications)


    def getSources(self):
        """ The list of sources for this feed. """
        return list(self.powerupsFor(ISource))


    def getURI(self):
        aggregator = service.IService(self.store).getServiceNamed('aggregator')
        return "xmpp:%s?node=%s" % (aggregator.service.full(), self.handle)



class LoggingAggregator(service.Service):

    def __init__(self, service):
        self.service = service


    def processNotifications(self, feed, notifications):
        for notification in notifications:
            log.msg("%s: %s" % (feed, notification))



class PubSubAggregator(service.Service):
    pubsubService = None
<commit_msg>Fix error in XMPP URI<commit_after>from twisted.application import service
from twisted.internet import defer
from twisted.python import log

from axiom import item, attributes

from ikdisplay.source import ISource

class Feed(item.Item):
    """
    A feed represents the aggregate stream of items of its sources.

    To pass notifications onto an aggregator, a Service named C{'aggregator'}
    must have been added as a subservice of the store the feed is stored in:

        >>> agg = LoggingAggregator()
        >>> agg.setName('aggregator')
        >>> agg.setServiceParent(service.IService(store))
    """

    typeName = 'Feed'

    handle = attributes.text(allowNone=False)
    title = attributes.text()
    language = attributes.text(default=u'en')

    def processNotifications(self, notifications):
        """
        Send on notifications to the aggregator.

        This finds the globally available aggregator service and passes it
        the notifications using this feed's handle.
        """
        aggregator = service.IService(self.store).getServiceNamed('aggregator')
        aggregator.processNotifications(self.handle, notifications)


    def getSources(self):
        """ The list of sources for this feed. """
        return list(self.powerupsFor(ISource))


    def getURI(self):
        aggregator = service.IService(self.store).getServiceNamed('aggregator')
        return "xmpp:%s?;node=%s" % (aggregator.service.full(), self.handle)



class LoggingAggregator(service.Service):

    def __init__(self, service):
        self.service = service


    def processNotifications(self, feed, notifications):
        for notification in notifications:
            log.msg("%s: %s" % (feed, notification))



class PubSubAggregator(service.Service):
    pubsubService = None

{'fraction_non_alphanumeric': 0.09596662030598054, 'fraction_numerical': 0.0, 'mean_word_length': 3.3065868263473055, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5359917', 'n_tokens_mistral': 993, 'n_tokens_neox': 925, 'n_words': 288}