diff options
Diffstat (limited to 'src/lib/Client/XML.py')
-rw-r--r-- | src/lib/Client/XML.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/Client/XML.py b/src/lib/Client/XML.py index adca4079a..baf533a02 100644 --- a/src/lib/Client/XML.py +++ b/src/lib/Client/XML.py @@ -8,16 +8,27 @@ try: from lxml.etree import XMLSyntaxError as ParseError driver = 'lxml' except ImportError: - # lxml not available + # lxml not available + from xml.parsers.expat import ExpatError as ParseError try: - from xml.etree.ElementTree import Element, SubElement, XML, tostring - from xml.parsers.expat import ExpatError as ParseError + import xml.etree.ElementTree + Element = xml.etree.ElementTree.Element + SubElement = xml.etree.ElementTree.SubElement + XML = xml.etree.ElementTree.XML + def tostring(e, encoding=None, xml_declaration=None): + return xml.etree.ElementTree.tostring(e) driver = 'etree-py' except ImportError: try: from elementtree.ElementTree import Element, SubElement, XML, tostring - from xml.parsers.expat import ExpatError as ParseError driver = 'etree' + import elementtree.ElementTree + Element = elementtree.ElementTree.Element + SubElement = elementtree.ElementTree.SubElement + XML = elementtree.ElementTree.XML + def tostring(e, encoding=None, xml_declaration=None): + return elementtree.ElementTree.tostring(e) + except ImportError: print "Failed to load lxml, xml.etree and elementtree.ElementTree" print "Cannot continue" |