summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2009-10-02 11:20:47 -0400
committerCole Robinson <crobinso@redhat.com>2009-10-05 13:31:37 -0400
commit3740a5e4c701281ac76a55e3f02b1d4221f1f9f0 (patch)
treeb1d0736e5e650afae1c78afcac0d813273de6152
parente4fc56ea6973f3c431ab30a4e658cb9db302457d (diff)
downloadlibvirt-python-v6-3740a5e4c701281ac76a55e3f02b1d4221f1f9f0.tar.gz
libvirt-python-v6-3740a5e4c701281ac76a55e3f02b1d4221f1f9f0.tar.xz
libvirt-python-v6-3740a5e4c701281ac76a55e3f02b1d4221f1f9f0.zip
python: Remove use of xmllib in generator.py
xmllib has been deprecated since python 2.0, and running the generator throws a warning. Move to using xml.sax Signed-off-by: Cole Robinson <crobinso@redhat.com>
-rwxr-xr-xgenerator.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/generator.py b/generator.py
index 3d142e9..9ec91d8 100755
--- a/generator.py
+++ b/generator.py
@@ -25,32 +25,27 @@ else:
#
#######################################################################
import os
-import xmllib
+import xml.sax
debug = 0
-class SlowParser(xmllib.XMLParser):
- """slow but safe standard parser, based on the XML parser in
- Python's standard library."""
-
- def __init__(self, target):
- self.unknown_starttag = target.start
- self.handle_data = target.data
- self.handle_cdata = target.cdata
- self.unknown_endtag = target.end
- xmllib.XMLParser.__init__(self)
-
def getparser():
# Attach parser to an unmarshalling object. return both objects.
target = docParser()
- return SlowParser(target), target
+ parser = xml.sax.make_parser()
+ parser.setContentHandler(target)
+ return parser, target
-class docParser:
+class docParser(xml.sax.handler.ContentHandler):
def __init__(self):
self._methodname = None
self._data = []
self.in_function = 0
+ self.startElement = self.start
+ self.endElement = self.end
+ self.characters = self.data
+
def close(self):
if debug:
print "close"