summaryrefslogtreecommitdiff
path: root/wikifolio/rss.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikifolio/rss.py')
-rw-r--r--wikifolio/rss.py52
1 files changed, 36 insertions, 16 deletions
diff --git a/wikifolio/rss.py b/wikifolio/rss.py
index a00191c..81e6122 100644
--- a/wikifolio/rss.py
+++ b/wikifolio/rss.py
@@ -1,30 +1,50 @@
-import time
-
from . import model
+import time
+import typing
+
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]
- """
+def dump_comments(cert: model.Certificate, comments: typing.Iterable[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)
+ 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')
+
+
+def dump_trades(cert: model.Certificate, trades: typing.Iterable[model.Trade]):
+ title = "{.name} / {.isin}".format(cert, cert)
+ items = []
+ for trade in trades:
+ trade_title = trade.typ + " " + str(trade.volume) + "@" + str(trade.quote) + " " + trade.share_name
+ description = trade.typ + " " + str(trade.volume) + "@" + str(trade.quote) + " " + trade.share_name
+ description += " ( " + trade.share_isin + " ) "
+
+ items.append(rss20.item(
+ rss20.title(trade_title),
+ rss20.author(cert.name),
+ rss20.pubDate(trade.timestamp.strftime("%a, %d %b %Y %T %z")),
+ rss20.guid(trade.timestamp.strftime("%a, %d %b %Y %T %z")),
+ rss20.link(cert.make_url()),
+ rss20.description(description)
))
return xsc.Frag(xml.XML(),
rss20.rss(rss20.channel(
- rss20.title(title),
- *items
+ rss20.title(title),
+ *items
))).string('utf-8')