summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Client/XML.py21
-rw-r--r--src/lib/Client/__init__.py2
2 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/Client/XML.py b/src/lib/Client/XML.py
new file mode 100644
index 000000000..356886558
--- /dev/null
+++ b/src/lib/Client/XML.py
@@ -0,0 +1,21 @@
+'''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, tostring
+ from lxml.etree import XMLSyntaxError as ParseError
+except ImportError:
+ # lxml not available
+ try:
+ from xml.etree.ElementTree import Element, XML, tostring
+ from xml.parsers.expat import ExpatError as ParseError
+ except ImportError:
+ try:
+ from elementtree.ElementTree import Element, XML, tostring
+ from xml.parsers.expat import ExpatError as ParseError
+ except ImportError:
+ print "Failed to load lxml, xml.etree and elementtree.ElementTree"
+ print "Cannot continue"
+ raise SystemExit, 1
diff --git a/src/lib/Client/__init__.py b/src/lib/Client/__init__.py
index bfdbc0e98..f7ba1a537 100644
--- a/src/lib/Client/__init__.py
+++ b/src/lib/Client/__init__.py
@@ -1,4 +1,4 @@
'''This contains all Bcfg2 Client modules'''
__revision__ = '$Revision$'
-__all__ = ["Proxy", "Toolset", "Debian", "Solaris", "Redhat", "Gentoo"]
+__all__ = ["Proxy", "Toolset", "Debian", "Solaris", "Redhat", "Gentoo", "XML"]