summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-09-18 16:31:08 (GMT)
committerFred Drake <fdrake@acm.org>2000-09-18 16:31:08 (GMT)
commit6f6d51d050115ad8e807472620586aa95a494148 (patch)
tree0a8547dbc76da703ad60389528381024b53507fd /Lib/xml
parentc40cdf7238b3ee019a2605ff1f0aaf1a6fcfd358 (diff)
downloadcpython-6f6d51d050115ad8e807472620586aa95a494148.zip
cpython-6f6d51d050115ad8e807472620586aa95a494148.tar.gz
cpython-6f6d51d050115ad8e807472620586aa95a494148.tar.bz2
Remove two unnecessary imports.
Update the module docstring to reflect the actual list of modules in the xml.sax package. Make the code better conform to the Python style guide.
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/sax/__init__.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/Lib/xml/sax/__init__.py b/Lib/xml/sax/__init__.py
index d0f0155..69c44ad 100644
--- a/Lib/xml/sax/__init__.py
+++ b/Lib/xml/sax/__init__.py
@@ -7,42 +7,42 @@ documented at <...>.
This package contains the following modules:
-saxutils -- Implementation of the convenience functions normally used
- to work with SAX.
+handler -- Base classes and constants which define the SAX 2 API for
+ the 'client-side' of SAX for Python.
-saxlib -- Implementation of the shared SAX 2 classes.
+saxutils -- Implementation of the convenience classes commonly used to
+ work with SAX.
-drv_pyexpat -- Driver that allows use of the Expat parser with the classes
- defined in saxlib.
+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.
"""
from handler import ContentHandler, ErrorHandler
from expatreader import ExpatParser
from _exceptions import SAXException, SAXNotRecognizedException, \
- SAXParseException, SAXNotSupportedException
-import xmlreader
-import saxutils
+ SAXParseException, SAXNotSupportedException
+
-def parse( filename_or_stream, handler, errorHandler=ErrorHandler() ):
- parser=ExpatParser()
- parser.setContentHandler( handler )
- parser.setErrorHandler( errorHandler )
- parser.parse( filename_or_stream )
+def parse(filename_or_stream, handler, errorHandler=ErrorHandler()):
+ parser = ExpatParser()
+ parser.setContentHandler(handler)
+ parser.setErrorHandler(errorHandler)
+ parser.parse(filename_or_stream)
-def parseString( string, handler, errorHandler=ErrorHandler() ):
+
+def parseString(string, handler, errorHandler=ErrorHandler()):
try:
- import cStringIO
- stringio=cStringIO.StringIO
+ from cStringIO import StringIO
except ImportError:
- import StringIO
- stringio=StringIO.StringIO
+ from StringIO import StringIO
- bufsize=len( string )
- buf=stringio( string )
-
- parser=ExpatParser()
- parser.setContentHandler( handler )
- parser.setErrorHandler( errorHandler )
- parser.parse( buf )
-
+ if errorHandler is None:
+ errorHandler = ErrorHandler()
+ parser = ExpatParser()
+ parser.setContentHandler(handler)
+ parser.setErrorHandler(errorHandler)
+ parser.parse(StringIO(string))