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

Commit951dc02

Browse files
author
Mark Pilgrim
committed
various fixes to make lxml treebuilder actually work in python 3
1 parent9dc584c commit951dc02

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

‎src/html5lib/treebuilders/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ def getTreeBuilder(treeType, implementation=None, **kwargs):
6767
from .importsimpletree
6868
treeBuilderCache[treeType]=simpletree.TreeBuilder
6969
eliftreeType=="beautifulsoup":
70-
importsoup
70+
from .importsoup
7171
treeBuilderCache[treeType]=soup.TreeBuilder
7272
eliftreeType=="lxml":
73-
importetree_lxml
73+
from .importetree_lxml
7474
treeBuilderCache[treeType]=etree_lxml.TreeBuilder
7575
eliftreeType=="etree":
7676
ifimplementationisNone:

‎src/html5lib/treebuilders/etree_lxml.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import_base
2-
importnew
1+
from .import_base
32
importwarnings
4-
fromhtml5lib.constantsimportDataLossWarning
5-
importetreeasetree_builders
6-
fromhtml5libimportihatexml
3+
from..constantsimportDataLossWarning
4+
from .importetreeasetree_builders
5+
from..importihatexml
76

87
try:
98
importlxml.etreeasetree
@@ -158,7 +157,7 @@ class Attributes(dict):
158157
def__init__(self,element,value={}):
159158
self._element=element
160159
dict.__init__(self,value)
161-
fork,vinself.iteritems():
160+
fork,vinself.items():
162161
self._element._element.attrib[filter.coerceAttribute(k)]=v
163162

164163
def__setitem__(self,key,value):
@@ -263,7 +262,7 @@ def insertRoot(self, token):
263262
"""Create the document root"""
264263
#Because of the way libxml2 works, it doesn't seem to be possible to
265264
#alter information like the doctype after the tree has been parsed.
266-
#Therefore we need to use the built-in parser to create ouriniial
265+
#Therefore we need to use the built-in parser to create ourinitial
267266
#tree, after which we can add elements like normal
268267
docStr=""
269268
ifself.doctypeandself.doctype.name:
@@ -278,7 +277,7 @@ def insertRoot(self, token):
278277
try:
279278
root=etree.fromstring(docStr)
280279
exceptetree.XMLSyntaxError:
281-
printdocStr
280+
print(docStr)
282281
raise
283282

284283
#Append the initial comments:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp