@@ -37,44 +37,39 @@ def getTreeBuilder(treeType, implementation=None, **kwargs):
3737 treeType - the name of the tree type required (case-insensitive). Supported
3838 values are:
3939
40- "dom" - A generic builder for DOM implementations, defaulting to
41- a xml.dom.minidom based implementation for the sake of
42- backwards compatibility (as releases up until 0.10 had a
43- builder called "dom" that was a minidom implemenation).
44- "etree" - A generic builder for tree implementations exposing an
45- elementtree-like interface (known to work with
46- ElementTree, cElementTree and lxml.etree).
40+ "dom" - A generic builder for DOM implementations, defaulting to
41+ a xml.dom.minidom based implementation.
42+ "etree" - A generic builder for tree implementations exposing an
43+ ElementTree-like interface, defaulting to
44+ xml.etree.cElementTree if available and
45+ xml.etree.ElementTree if not.
46+ "lxml" - A etree-based builder for lxml.etree, handling
47+ limitations of lxml's implementation.
4748
4849 implementation - (Currently applies to the "etree" and "dom" tree types). A
4950 module implementing the tree type e.g.
50- xml.etree.ElementTree or lxml .etree."""
51+ xml.etree.ElementTree or xml .etree.cElementTree ."""
5152
5253 treeType = treeType .lower ()
5354 if treeType not in treeBuilderCache :
5455 if treeType == "dom" :
5556 from . import dom
56- # XXX: Keep backwards compatibility by using minidom if no implementation is given
57+ # Come up with a sane default (pref. from the stdlib)
5758 if implementation is None :
5859 from xml .dom import minidom
5960 implementation = minidom
60- # XXX: NEVER cache here, caching is done in the dom submodule
61+ # NEVER cache here, caching is done in the dom submodule
6162 return dom .getDomModule (implementation , ** kwargs ).TreeBuilder
6263 elif treeType == "lxml" :
6364 from . import etree_lxml
6465 treeBuilderCache [treeType ] = etree_lxml .TreeBuilder
6566 elif treeType == "etree" :
66- # Come up with a sane default
67+ # Come up with a sane default (pref. from the stdlib)
6768 if implementation is None :
6869 try :
6970 import xml .etree .cElementTree as ET
7071 except ImportError :
71- try :
72- import xml .etree .ElementTree as ET
73- except ImportError :
74- try :
75- import cElementTree as ET
76- except ImportError :
77- import elementtree .ElementTree as ET
72+ import xml .etree .ElementTree as ET
7873 implementation = ET
7974 from . import etree
8075 # NEVER cache here, caching is done in the etree submodule
0 commit comments