[Python-checkins] python/dist/src/Lib htmllib.py,1.21,1.22

fdrake at users.sourceforge.net fdrake at users.sourceforge.net
Thu Sep 9 04:24:15 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5948

Modified Files:
	htmllib.py 
Log Message:
clean up the API a little; exceptions are defined by this module
(needs documentation)


Index: htmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/htmllib.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- htmllib.py	27 Oct 2003 15:47:48 -0000	1.21
+++ htmllib.py	9 Sep 2004 02:24:13 -0000	1.22
@@ -4,13 +4,18 @@
 http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
 """
 
+import sgmllib
 
-from sgmllib import SGMLParser
 from formatter import AS_IS
 
-__all__ = ["HTMLParser"]
+__all__ = ["HTMLParser", "HTMLParseError"]
 
-class HTMLParser(SGMLParser):
+
+class HTMLParseError(sgmllib.SGMLParseError):
+    """Error raised when an HTML document can't be parsed."""
+
+
+class HTMLParser(sgmllib.SGMLParser):
     """This is the basic HTML parser class.
 
     It supports all entity names required by the XHTML 1.0 Recommendation.
@@ -28,11 +33,14 @@
         the parser.
 
         """
-        SGMLParser.__init__(self, verbose)
+        sgmllib.SGMLParser.__init__(self, verbose)
         self.formatter = formatter
 
+    def error(self, message):
+        raise HTMLParseError(message)
+
     def reset(self):
-        SGMLParser.reset(self)
+        sgmllib.SGMLParser.reset(self)
         self.savedata = None
         self.isindex = 0
         self.title = None



More information about the Python-checkins mailing list