From bc470d5023226dc1af3daa1c1bb5c221d9bba939 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 11 Oct 2009 15:56:06 +0000 Subject: Merged revisions 75358 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75358 | georg.brandl | 2009-10-11 17:06:44 +0200 (So, 11 Okt 2009) | 1 line Overhaul of Demo/xml. ........ --- Demo/xml/rss2html.py | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'Demo/xml/rss2html.py') diff --git a/Demo/xml/rss2html.py b/Demo/xml/rss2html.py index 15c9891952..49cd154ecd 100644 --- a/Demo/xml/rss2html.py +++ b/Demo/xml/rss2html.py @@ -1,45 +1,50 @@ +""" +A demo that reads in an RSS XML document and emits an HTML file containing +a list of the individual items in the feed. +""" + import sys +import codecs from xml.sax import make_parser, handler # --- Templates -top = \ -""" +top = """\ - - - %s - - - -

%s

+ + + %s + + + + +

%s

""" -bottom = \ -""" +bottom = """ -
-
-Converted to HTML by sax_rss2html.py. -
+
+
+Converted to HTML by rss2html.py. +
- - + + """ # --- The ContentHandler class RSSHandler(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) self._out = out self._text = "" self._parent = None - self._list_started = 0 + self._list_started = False self._title = None self._link = None self._descr = "" @@ -69,7 +74,7 @@ class RSSHandler(handler.ContentHandler): elif name == "item": if not self._list_started: self._out.write("