]> granicus.if.org Git - python/commitdiff
Improvements to doco strings.
authorLars Gustäbel <lars@gustaebel.de>
Sun, 24 Sep 2000 20:38:18 +0000 (20:38 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Sun, 24 Sep 2000 20:38:18 +0000 (20:38 +0000)
Tiny bug fix to expatreader.py (endDocument was only called after errors).

Lib/xml/sax/__init__.py
Lib/xml/sax/expatreader.py
Lib/xml/sax/handler.py
Lib/xml/sax/xmlreader.py

index 24b7d24c102a04109a6fbf2a75b31631a3fddcca..7c62ea1cd7e001c3b3e611f41e17866c7421c18d 100644 (file)
@@ -16,9 +16,7 @@ saxutils -- Implementation of the convenience classes commonly used to
 xmlreader -- Base classes and constants which define the SAX 2 API for
              the parsers used with SAX for Python.
 
-expatreader -- Driver that allows use of the Expat parser with the
-               classes defined in saxlib.
-
+expatreader -- Driver that allows use of the Expat parser with SAX.
 """
 
 from xmlreader import InputSource
index e3b3ad0d40647bfff30e965a43fe04b3303a6ea6..1d93542af9a818b5f6be85c52a7b5b57decb3aaf 100644 (file)
@@ -1,6 +1,6 @@
 """
 SAX driver for the Pyexpat C module.  This driver works with
-pyexpat.__version__ == '1.5'.
+pyexpat.__version__ == '2.22'.
 """
 
 version = "0.20"
@@ -28,7 +28,7 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
     # XMLReader methods
 
     def parse(self, source):
-        "Parse an XML document from a URL."
+        "Parse an XML document from a URL or an InputSource."
         source = saxutils.prepare_input_source(source)
 
         self._source = source
@@ -40,7 +40,7 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
             error_code = self._parser.ErrorCode
             raise SAXParseException(expat.ErrorString(error_code), None, self)
             
-            self._cont_handler.endDocument()
+        self._cont_handler.endDocument()
 
     def prepareParser(self, source):
         if source.getSystemId() != None:
@@ -108,7 +108,10 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
 #         self._parser.DefaultHandlerExpand = 
 #         self._parser.NotStandaloneHandler = 
         self._parser.ExternalEntityRefHandler = self.external_entity_ref
-    
+
+        self._parsing = 0
+        self._entity_stack = []
+        
     # Locator methods
 
     def getColumnNumber(self):
index c80457c6e594682ab601fc5f32b2a0e6b0c97e2f..0931014cd3c3dcda1cb71c57270c34db6e8a2cce 100644 (file)
@@ -20,13 +20,14 @@ version = '2.0beta'
 # ===== ERRORHANDLER =====
 
 class ErrorHandler:
-    """Basic interface for SAX error handlers. If you create an object
-    that implements this interface, then register the object with your
-    Parser, the parser will call the methods in your object to report
-    all warnings and errors. There are three levels of errors
-    available: warnings, (possibly) recoverable errors, and
-    unrecoverable errors. All methods take a SAXParseException as the
-    only parameter."""
+    """Basic interface for SAX error handlers.
+
+    If you create an object that implements this interface, then
+    register the object with your XMLReader, the parser will call the
+    methods in your object to report all warnings and errors. There
+    are three levels of errors available: warnings, (possibly)
+    recoverable errors, and unrecoverable errors. All methods take a
+    SAXParseException as the only parameter."""
 
     def error(self, exception):
         "Handle a recoverable error."
index 04e7bc1aee952fa7ec8d179c8f061ee77860ad6b..c381fd48931fffa36cb9bcb90f402cade14f19e4 100644 (file)
@@ -6,6 +6,17 @@ import handler
 # ===== XMLREADER =====
 
 class XMLReader:
+    """Interface for reading an XML document using callbacks. 
+
+    XMLReader is the interface that an XML parser's SAX2 driver must
+    implement. This interface allows an application to set and query
+    features and properties in the parser, to register event handlers
+    for document processing, and to initiate a document parse.
+
+    All SAX interfaces are assumed to be synchronous: the parse
+    methods must not return until parsing is complete, and readers
+    must wait for an event-handler callback to return before reporting
+    the next event."""
     
     def __init__(self):
         self._cont_handler = handler.ContentHandler()