Skip to content

Commit 7e08100

Browse files
committed
Port Anne's unice patch to the branch
--HG-- branch : 0.2_branch extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/branches/0.2_branch%40434
1 parent 35d49ae commit 7e08100

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/treebuilders/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, name):
3939
self.childNodes = []
4040
self._flags = []
4141

42-
def __str__(self):
42+
def __unicode__(self):
4343
attributesStr = " ".join(["%s=\"%s\""%(name, value)
4444
for name, value in
4545
self.attributes.iteritems()])

src/treebuilders/simpletree.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ def __init__(self, name):
99
self.childNodes = []
1010
self._flags = []
1111

12-
def __str__(self):
12+
def __unicode__(self):
1313
return self.name
1414

1515
def __repr__(self):
1616
return "<%s %s>" % (self.__class__, self.name)
1717

1818
def printTree(self, indent=0):
19-
tree = '\n|%s%s' % (' '* indent, str(self))
19+
tree = '\n|%s%s' % (' '* indent, unicode(self))
2020
for child in self.childNodes:
2121
tree += child.printTree(indent + 2)
2222
return tree
@@ -67,11 +67,11 @@ class Document(Node):
6767
def __init__(self):
6868
Node.__init__(self, None)
6969

70-
def __str__(self):
70+
def __unicode__(self):
7171
return "#document"
7272

7373
def printTree(self):
74-
tree = str(self)
74+
tree = unicode(self)
7575
for child in self.childNodes:
7676
tree += child.printTree(2)
7777
return tree
@@ -80,27 +80,27 @@ class DocumentType(Node):
8080
def __init__(self, name):
8181
Node.__init__(self, name)
8282

83-
def __str__(self):
83+
def __unicode__(self):
8484
return "<!DOCTYPE %s>" % self.name
8585

8686
class TextNode(Node):
8787
def __init__(self, value):
8888
Node.__init__(self, None)
8989
self.value = value
9090

91-
def __str__(self):
91+
def __unicode__(self):
9292
return "\"%s\"" % self.value
9393

9494
class Element(Node):
9595
def __init__(self, name):
9696
Node.__init__(self, name)
9797
self.attributes = {}
9898

99-
def __str__(self):
99+
def __unicode__(self):
100100
return "<%s>" % self.name
101101

102102
def printTree(self, indent):
103-
tree = '\n|%s%s' % (' '*indent, str(self))
103+
tree = '\n|%s%s' % (' '*indent, unicode(self))
104104
indent += 2
105105
if self.attributes:
106106
for name, value in self.attributes.iteritems():
@@ -114,7 +114,7 @@ def __init__(self, data):
114114
Node.__init__(self, None)
115115
self.data = data
116116

117-
def __str__(self):
117+
def __unicode__(self):
118118
return "<!-- %s -->" % self.data
119119

120120
class TreeBuilder(_base.TreeBuilder):

0 commit comments

Comments
 (0)