Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06faed8

Browse files
committed
Clean up getTreeBuilder, remove dom.TreeBuilder from 0.10 legacy.
1 parent54648ef commit06faed8

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

‎CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Released on XXX, 2013
2626
* Removed the ``XHTMLSerializer`` as it never actually guaranteed its
2727
output was well-formed XML, and hence provided little of use.
2828

29+
* Removed default DOM treebuilder, so ``html5lib.treebuilders.dom`` is no
30+
longer supported. ``html5lib.treebuilders.getTreeBuilder("dom")`` will
31+
return the default DOM treebuilder, which uses ``xml.dom.minidom``.
32+
2933
* Optional heuristic character encoding detection now based on
3034
``charade`` for Python 2.6 - 3.3 compatibility.
3135

‎html5lib/treebuilders/__init__.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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 orlxml.etree."""
51+
xml.etree.ElementTree orxml.etree.cElementTree."""
5152

5253
treeType=treeType.lower()
5354
iftreeTypenotintreeBuilderCache:
5455
iftreeType=="dom":
5556
from .importdom
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
ifimplementationisNone:
5859
fromxml.domimportminidom
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
returndom.getDomModule(implementation,**kwargs).TreeBuilder
6263
eliftreeType=="lxml":
6364
from .importetree_lxml
6465
treeBuilderCache[treeType]=etree_lxml.TreeBuilder
6566
eliftreeType=="etree":
66-
# Come up with a sane default
67+
# Come up with a sane default (pref. from the stdlib)
6768
ifimplementationisNone:
6869
try:
6970
importxml.etree.cElementTreeasET
7071
exceptImportError:
71-
try:
72-
importxml.etree.ElementTreeasET
73-
exceptImportError:
74-
try:
75-
importcElementTreeasET
76-
exceptImportError:
77-
importelementtree.ElementTreeasET
72+
importxml.etree.ElementTreeasET
7873
implementation=ET
7974
from .importetree
8075
# NEVER cache here, caching is done in the etree submodule

‎html5lib/treebuilders/dom.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,3 @@ def dom2sax(node, handler, nsmap={'xml': XML_NAMESPACE}):
288288

289289
# The actual means to get a module!
290290
getDomModule=moduleFactoryFactory(getDomBuilder)
291-
292-
293-
# Keep backwards compatibility with things that directly load
294-
# classes/functions from this module
295-
forkey,valueinlist(getDomModule(minidom).__dict__.items()):
296-
globals()[key]=value

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp