RSS: use the original FeedParserDict for substitution

instead of building a new keyword arguments dict by iteration.

'description' is a field in FeedParserDict, but is not present when iterating,
which made it unavailable as a substitution variable.
This commit is contained in:
Valentin Lorentz 2016-09-08 21:42:31 +02:00
parent 2d30b40a80
commit 4f280599e1
2 changed files with 14 additions and 3 deletions

View File

@ -406,10 +406,10 @@ class RSS(callbacks.Plugin):
template = self.registryValue(key_name, channel)
date = entry.get('published_parsed')
date = utils.str.timestamp(date)
s = string.Template(template).safe_substitute(
s = string.Template(template).substitute(
entry,
feed_name=feed.name,
date=date,
**entry)
date=date)
return self._normalize_entry(s)
def announce_entry(self, irc, channel, feed, entry):

View File

@ -210,6 +210,16 @@ class RSSTestCase(ChannelPluginTestCase):
self._feedMsg('rss remove xkcd2')
feedparser._open_resource = old_open
def testDescription(self):
with conf.supybot.plugins.RSS.format.context('$description'):
old_open = feedparser._open_resource
feedparser._open_resource = constant(xkcd_new)
try:
self.assertRegexp('rss http://xkcd.com/rss.xml',
'Although the oral exam for the doctorate was')
finally:
feedparser._open_resource = old_open
if network:
def testRssinfo(self):
self.assertNotError('rss info %s' % url)
@ -248,4 +258,5 @@ class RSSTestCase(ChannelPluginTestCase):
self.assertNotError('rss info http://br-linux.org/main/index.xml')
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: