Commit 6f6d51d0 authored by Fred Drake's avatar Fred Drake

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.
parent c40cdf72
......@@ -7,13 +7,17 @@ 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.
"""
......@@ -21,28 +25,24 @@ from handler import ContentHandler, ErrorHandler
from expatreader import ExpatParser
from _exceptions import SAXException, SAXNotRecognizedException, \
SAXParseException, SAXNotSupportedException
import xmlreader
import saxutils
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() ):
try:
import cStringIO
stringio=cStringIO.StringIO
except ImportError:
import StringIO
stringio=StringIO.StringIO
bufsize=len( string )
buf=stringio( string )
def parse(filename_or_stream, handler, errorHandler=ErrorHandler()):
parser = ExpatParser()
parser.setContentHandler(handler)
parser.setErrorHandler(errorHandler)
parser.parse(filename_or_stream)
parser=ExpatParser()
parser.setContentHandler( handler )
parser.setErrorHandler( errorHandler )
parser.parse( buf )
def parseString(string, handler, errorHandler=ErrorHandler()):
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
if errorHandler is None:
errorHandler = ErrorHandler()
parser = ExpatParser()
parser.setContentHandler(handler)
parser.setErrorHandler(errorHandler)
parser.parse(StringIO(string))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment