summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/XML.py
blob: adca4079a16becbae61b90be752efe674c7b4a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'''XML lib compatibility layer for the Bcfg2 client'''
__revision__ = '$Revision$'

# library will use lxml, then builtin xml.etree, then ElementTree

try:
    from lxml.etree import Element, SubElement, XML, tostring
    from lxml.etree import XMLSyntaxError as ParseError
    driver = 'lxml'
except ImportError:
    # lxml not available 
    try:
        from xml.etree.ElementTree import Element, SubElement, XML, tostring
        from xml.parsers.expat import ExpatError as ParseError
        driver = 'etree-py'
    except ImportError:
        try:
            from elementtree.ElementTree import Element, SubElement, XML, tostring
            from xml.parsers.expat import ExpatError as ParseError
            driver = 'etree'
        except ImportError:
            print "Failed to load lxml, xml.etree and elementtree.ElementTree"
            print "Cannot continue"
            raise SystemExit, 1

len([Element, SubElement, XML, tostring, ParseError])