Patch by Alberto Piai to address new integration of (c)elementtree into core python.

This commit is contained in:
Cas Cremers 2007-10-08 13:59:16 +02:00
parent b013440c8b
commit 59d061c47f

View File

@ -28,19 +28,27 @@
# Things will be a lot faster and consume less memory if you install the # Things will be a lot faster and consume less memory if you install the
# cElementTree module # cElementTree module
# #
# In python 2.5 cElementTree is in the core, so you don't need to install
# extra packages
#
import sys import sys
# Check for cElementTree presence. Otherwise use ElementTree. # Check for cElementTree presence. Otherwise use ElementTree.
useiter = True useiter = True
try: try:
import cElementTree # python 2.5 has cElementTree in the core
except ImportError: import xml.etree.cElementTree as cElementTree
useiter = False except:
# try the old way
try: try:
from elementtree import ElementTree import cElementTree
except ImportError: except ImportError:
print """ useiter = False
try:
from elementtree import ElementTree
except ImportError:
print """
ERROR: ERROR:
Could not locate either the [elementtree] or the [cElementTree] package. Could not locate either the [elementtree] or the [cElementTree] package.
@ -49,7 +57,7 @@ The [cElementTree] packages can be found at http://effbot.org/zone/celementtree.
Note that you can still use the Scyther binaries in the 'Bin' directory. Note that you can still use the Scyther binaries in the 'Bin' directory.
""" """
sys.exit(1) sys.exit(1)
## Simply pick cElementTree ## Simply pick cElementTree
#import cElementTree #import cElementTree