mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Improvements to doco strings.
Tiny bug fix to expatreader.py (endDocument was only called after errors).
This commit is contained in:
		
							parent
							
								
									33315b180b
								
							
						
					
					
						commit
						bb757136b2
					
				
					 4 changed files with 27 additions and 14 deletions
				
			
		|  | @ -16,9 +16,7 @@ | |||
| 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 | ||||
|  |  | |||
|  | @ -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 @@ def __init__(self, namespaceHandling=0, bufsize=2**16-20): | |||
|     # 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 | ||||
|  | @ -109,6 +109,9 @@ def reset(self): | |||
| #         self._parser.NotStandaloneHandler =  | ||||
|         self._parser.ExternalEntityRefHandler = self.external_entity_ref | ||||
| 
 | ||||
|         self._parsing = 0 | ||||
|         self._entity_stack = [] | ||||
|          | ||||
|     # Locator methods | ||||
| 
 | ||||
|     def getColumnNumber(self): | ||||
|  |  | |||
|  | @ -20,13 +20,14 @@ | |||
| # ===== 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." | ||||
|  |  | |||
|  | @ -6,6 +6,17 @@ | |||
| # ===== 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() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lars Gustäbel
						Lars Gustäbel