-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcompat.py
executable file
·28 lines (24 loc) · 899 Bytes
/
compat.py
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
27
import sys
import logging
import setup
log = logging.getLogger(setup.app_name + "." + __name__)
log.debug(_("Using Python %s.%s.%s"), *sys.version_info[:3])
# See http://lxml.de/tutorial.html for the source of the includes
try:
from lxml import etree
log.debug(_("Running with lxml.etree"))
except ImportError: # pragma: no cover
try:
import xml.etree.ElementTree as etree
log.debug(_("Running with ElementTree on Python 2.5+"))
except ImportError:
try:
import cElementTree as etree
log.debug(_("Running with cElementTree"))
except ImportError:
try:
import elementtree.ElementTree as etree
log.debug(_("Running with ElementTree"))
except ImportError:
msg = _("Failed to import ElementTree from any known place")
raise ImportError(msg)