comparison emeraldtree/ElementTree.py @ 21:7b33b90de8be

some minor coding style cleanups
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Jun 2008 20:40:02 +0200
parents 56cb25aba1e6
children 0aa00b020bc1
comparison
equal deleted inserted replaced
20:56cb25aba1e6 21:7b33b90de8be
1222 # @return An Element instance. 1222 # @return An Element instance.
1223 # @defreturn Element 1223 # @defreturn Element
1224 1224
1225 def close(self): 1225 def close(self):
1226 assert len(self._elem) == 0, "missing end tags" 1226 assert len(self._elem) == 0, "missing end tags"
1227 assert self._last != None, "missing toplevel element" 1227 assert self._last is not None, "missing toplevel element"
1228 return self._last 1228 return self._last
1229 1229
1230 def _flush(self): 1230 def _flush(self):
1231 if self._data: 1231 if self._data:
1232 text = "".join(self._data) 1232 text = "".join(self._data)
1291 def __init__(self, html=0, target=None, encoding=None): 1291 def __init__(self, html=0, target=None, encoding=None):
1292 try: 1292 try:
1293 from xml.parsers import expat 1293 from xml.parsers import expat
1294 except ImportError: 1294 except ImportError:
1295 try: 1295 try:
1296 import pyexpat; expat = pyexpat 1296 import pyexpat
1297 expat = pyexpat
1297 except ImportError: 1298 except ImportError:
1298 raise ImportError( 1299 raise ImportError(
1299 "No module named expat; use SimpleXMLTreeBuilder instead" 1300 "No module named expat; use SimpleXMLTreeBuilder instead"
1300 ) 1301 )
1301 parser = expat.ParserCreate(encoding, "}") 1302 parser = expat.ParserCreate(encoding, "}")