summaryrefslogtreecommitdiff
path: root/wikifolio/rss.py
blob: a00191c96e85fbf66d424693f659f4bf55536610 (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 = "{.name} / {.isin}".format(cert, cert)
    items = []
    for comment in comments:
        items.append(rss20.item(
                rss20.title("Kommentar " + 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')