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

Commit51b2223

Browse files
author
James Graham
committed
Fix some problems with etree and new python version
--HG--extra : transplant_source : %8Ab%974%D2%9Bu%3D%F5%FC%BBy%9B%DF9%00%AF_1R
1 parent7460e1a commit51b2223

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎html5lib/treebuilders/etree.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importnew
22
importre
3+
importtypes
34

45
import_base
56
fromhtml5libimportihatexml
@@ -91,15 +92,15 @@ def _setChildNodes(self, value):
9192

9293
defhasContent(self):
9394
"""Return true if the node has children or text"""
94-
returnbool(self._element.textorself._element.getchildren())
95+
returnbool(self._element.textorlen(self._element))
9596

9697
defappendChild(self,node):
9798
self._childNodes.append(node)
9899
self._element.append(node._element)
99100
node.parent=self
100101

101102
definsertBefore(self,node,refNode):
102-
index=self._element.getchildren().index(refNode._element)
103+
index=list(self._element).index(refNode._element)
103104
self._element.insert(index,node._element)
104105
node.parent=self
105106

@@ -119,7 +120,7 @@ def insertText(self, data, insertBefore=None):
119120
self._element[-1].tail+=data
120121
else:
121122
#Insert the text before the specified node
122-
children=self._element.getchildren()
123+
children=list(self._element)
123124
index=children.index(insertBefore._element)
124125
ifindex>0:
125126
ifnotself._element[index-1].tail:
@@ -217,9 +218,10 @@ def serializeElement(element, indent=0):
217218
rv.append("|%s\"%s\""%(' '*(indent+2),element.text))
218219
ifelement.tail:
219220
finalText=element.tail
220-
eliftype(element.tag)==type(ElementTree.Comment):
221+
elifelement.tag==ElementTree.Comment:
221222
rv.append("|%s<!-- %s -->"%(' '*indent,element.text))
222223
else:
224+
asserttype(element.tag)intypes.StringTypes,"Expected unicode, got %s"%type(element.tag)
223225
nsmatch=tag_regexp.match(element.tag)
224226

225227
ifnsmatchisNone:
@@ -247,7 +249,7 @@ def serializeElement(element, indent=0):
247249
ifelement.text:
248250
rv.append("|%s\"%s\""%(' '*(indent+2),element.text))
249251
indent+=2
250-
forchildinelement.getchildren():
252+
forchildinelement:
251253
serializeElement(child,indent)
252254
ifelement.tail:
253255
rv.append("|%s\"%s\""%(' '*(indent-2),element.tail))
@@ -281,7 +283,7 @@ def serializeElement(element):
281283
ifelement.tail:
282284
finalText=element.tail
283285

284-
forchildinelement.getchildren():
286+
forchildinelement:
285287
serializeElement(child)
286288

287289
eliftype(element.tag)==type(ElementTree.Comment):
@@ -298,7 +300,7 @@ def serializeElement(element):
298300
ifelement.text:
299301
rv.append(element.text)
300302

301-
forchildinelement.getchildren():
303+
forchildinelement:
302304
serializeElement(child)
303305

304306
rv.append("</%s>"%(element.tag,))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp