Beispiel #1
0
    def format_generator(self, gen):
        """Format the information contained in this message's <generator> tag"""
        name = XML.digValue(gen, str, "name")
        url = XML.digValue(gen, str, "url")
        version = XML.digValue(gen, str, "version")

        if url:
            name = tag('a', href=url)[ name ]
        items = ["Generated by ", Template.value[ name ]]
        if version:
            items.extend([" version ", version])
        return items
Beispiel #2
0
    def joinMessage(self, message, packages):
        content = []

        branch = XML.digValue(message.xml, str, "message", "source", "branch")
        if branch:
            content.append(Nouvelle.tag('strong')[ self.format_branch(branch.strip()) ])

        for package in packages:
            if content:
                content.append(Nouvelle.tag('br'))
            content.append(package)

        return content
Beispiel #3
0
    def joinMessage(self, message, packages):
        """Join the results for each package into a final result"""
        content = "builder"

        branch = XML.digValue(message.xml, str, "message", "source", "branch")
        if branch:
            content += " " + self.format_branch(branch.strip())

        # If we have only one package, put it on the same line as the heading
        if len(packages) <= 1:
            content += ": " + packages[0]
        else:
            content += "\n" + "\n".join(packages)
        return content
Beispiel #4
0
    def render_item(self, context, id, content):
        url = Link.MessageLink(self.target, id).getURL(context)
        m = Message.Message(content)
        tags = [
            tag('link')[ url ],
            tag('dc:date')[ TimeUtil.formatDateISO8601(XML.digValue(m.xml, int, "message", "timestamp")) ],
            tag('description')[ quote(self.formatMessage(m)) ],
            ]

        # Generate a title if we can, but if we can't don't worry too much
        try:
            tags.append(tag('title')[ Formatters.getFactory().findMedium('title', m).formatMessage(m) ])
        except Message.NoFormatterError:
            pass

        return tag('item', **{'rdf:about': url})[tags]
Beispiel #5
0
    def messageToItemContent(self, context, m, id):
        """Render an XML message as the content of an RSS <item>"""
        url = Link.MessageLink(self.target, id).getURL(context)
        tags = [
            tag('pubDate')[ TimeUtil.formatDateRFC822(XML.digValue(m.xml, int, "message", "timestamp")) ],
            tag('guid')[url],
            tag('link')[url],
            tag('description')[ quote(self.formatMessage(m)) ],
            ]

        # Generate a title if we can, but if we can't don't worry too much
        try:
            tags.append(tag('title')[ Formatters.getFactory().findMedium('title', m).formatMessage(m) ])
        except Message.NoFormatterError:
            pass

        return tags
Beispiel #6
0
    def getValue(self, message):
	try:
            return XML.digValue(message.xml, int, "message", "timestamp")
        except ValueError:
            return None