summaryrefslogtreecommitdiff
path: root/wikifolio/rss.py
blob: e56c1437e55b6b9bcb07da1fc6ccdb0cd5d82b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time

from . import model

from ll.xist import xsc
from ll.xist.ns import xml, rss20


def dump(cert, comments):
    """
    :type cert: model.Certificate
    :type comments: list[model.Comment]
    """
    title = "Kommentare zu {.name} / {.isin}".format(cert, cert)
    items = []
    for comment in comments:
        items.append(rss20.item(
                rss20.title(title),
                rss20.author(comment.author),
                rss20.pubDate(time.strftime("%a, %d %b %Y %T %z",
                                            comment.pubDate)),
                rss20.guid(comment.guid),
                rss20.link(comment.link),
                rss20.description(comment.description)
        ))
    return xsc.Frag(xml.XML(),
                    rss20.rss(rss20.channel(
                            rss20.title(title),
                            *items
                    ))).string('utf-8')