summaryrefslogtreecommitdiff
path: root/rdflib/compat.py
diff options
context:
space:
mode:
authorGunnar Aastrand Grimnes <gromgull@gmail.com>2017-01-12 12:35:28 +0100
committerGunnar Aastrand Grimnes <gromgull@gmail.com>2017-01-12 14:57:50 +0100
commit10e45e5767e280d728fd14b3d0bd62978903ea63 (patch)
treeda8149f20d74d64720edabc27b79d124097ed7e7 /rdflib/compat.py
parentf469bb04e9e75d407f047f081ae5003feb712a34 (diff)
downloadrdflib-fixElementTreeImports.tar.gz
be more compatible when importing elementtree, and only in one placefixElementTreeImports
fixes #606
Diffstat (limited to 'rdflib/compat.py')
-rw-r--r--rdflib/compat.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/rdflib/compat.py b/rdflib/compat.py
index 6c714894..f7ca4063 100644
--- a/rdflib/compat.py
+++ b/rdflib/compat.py
@@ -23,3 +23,30 @@ else:
def numeric_greater(a, b):
return a > b
+
+
+try:
+ from lxml import etree
+ print("running with lxml.etree")
+except ImportError:
+ try:
+ # Python 2.5
+ import xml.etree.cElementTree as etree
+ print("running with cElementTree on Python 2.5+")
+ except ImportError:
+ try:
+ # Python 2.5
+ import xml.etree.ElementTree as etree
+ print("running with ElementTree on Python 2.5+")
+ except ImportError:
+ try:
+ # normal cElementTree install
+ import cElementTree as etree
+ print("running with cElementTree")
+ except ImportError:
+ try:
+ # normal ElementTree install
+ import elementtree.ElementTree as etree
+ print("running with ElementTree")
+ except ImportError:
+ print("Failed to import ElementTree from any known place")