[feedparser commit] r295 - in trunk/feedparser: . tests/wellformed/atom

3 views
Skip to first unread message

codesite...@google.com

unread,
Mar 9, 2009, 10:01:21 PM3/9/09
to feedparse...@googlegroups.com
Author: and...@google.com
Date: Mon Mar 9 18:11:18 2009
New Revision: 295

Added:
trunk/feedparser/tests/wellformed/atom/media_thumbnail.xml
Modified:
trunk/feedparser/feedparser.py

Log:
Apply patch provided by EpsilonP..., and added a test.


Modified: trunk/feedparser/feedparser.py
==============================================================================
--- trunk/feedparser/feedparser.py (original)
+++ trunk/feedparser/feedparser.py Mon Mar 9 18:11:18 2009
@@ -1532,6 +1532,24 @@
value = self.pop('itunes_explicit', 0)
self._getContext()['itunes_explicit'] = (value == 'yes') and 1 or 0

+ def _start_media_content(self, attrsD):
+ context = self._getContext()
+ context.setdefault('media_content', [])
+ context['media_content'].append(attrsD)
+
+ def _start_media_thumbnail(self, attrsD):
+ context = self._getContext()
+ context.setdefault('media_thumbnail', [])
+ self.push('url', 1) # new
+ context['media_thumbnail'].append(attrsD)
+
+ def _end_media_thumbnail(self):
+ url = self.pop('url')
+ context = self._getContext()
+ if url != None and len(url.strip()) != 0:
+ if not context['media_thumbnail'][-1].has_key('url'):
+ context['media_thumbnail'][-1]['url'] = url
+
if _XML_AVAILABLE:
class _StrictFeedParser(_FeedParserMixin,
xml.sax.handler.ContentHandler):
def __init__(self, baseuri, baselang, encoding):

Added: trunk/feedparser/tests/wellformed/atom/media_thumbnail.xml
==============================================================================
--- (empty file)
+++ trunk/feedparser/tests/wellformed/atom/media_thumbnail.xml Mon Mar 9
18:11:18 2009
@@ -0,0 +1,11 @@
+<!--
+Description: media_thumbnail
+Expect: entries[0]['media_thumbnail'][0]['url'] ==
u'http://example.com/thumbnail.jpg'
+-->
+<feed version="0.3" xmlns="http://purl.org/atom/ns#">
+<entry>
+ <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/"
+ url="http://example.com/thumbnail.jpg" height="72" width="72" />
+ <title>Example Atom</title>
+</entry>
+</feed>

Reply all
Reply to author
Forward
0 new messages