diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2008-07-29 15:00:22 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2008-07-29 15:00:22 +0000 |
commit | f65abe0247b7c23dee8bb0b0b317b55feb8123be (patch) | |
tree | 4e9e4594aecbf6e15e41e1802509fb1f6f6a976f | |
parent | 3d29375196c124405db4d256dc8368f39e9160d1 (diff) | |
download | bcfg2-f65abe0247b7c23dee8bb0b0b317b55feb8123be.tar.gz bcfg2-f65abe0247b7c23dee8bb0b0b317b55feb8123be.tar.bz2 bcfg2-f65abe0247b7c23dee8bb0b0b317b55feb8123be.zip |
make elementtree function mappings ignore certain tostring keyword arguments when they aren't available (Resolves Ticket #582)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4834 ce84e21b-d406-0410-9b95-82705330c041
-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" |