mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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>
This commit is contained in:
parent
547d8e3a86
commit
fca27ca2bb
@ -25,32 +25,27 @@ else:
|
|||||||
#
|
#
|
||||||
#######################################################################
|
#######################################################################
|
||||||
import os
|
import os
|
||||||
import xmllib
|
import xml.sax
|
||||||
|
|
||||||
debug = 0
|
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():
|
def getparser():
|
||||||
# Attach parser to an unmarshalling object. return both objects.
|
# Attach parser to an unmarshalling object. return both objects.
|
||||||
target = docParser()
|
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):
|
def __init__(self):
|
||||||
self._methodname = None
|
self._methodname = None
|
||||||
self._data = []
|
self._data = []
|
||||||
self.in_function = 0
|
self.in_function = 0
|
||||||
|
|
||||||
|
self.startElement = self.start
|
||||||
|
self.endElement = self.end
|
||||||
|
self.characters = self.data
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if debug:
|
if debug:
|
||||||
print "close"
|
print "close"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user