Project

General

Profile

« Previous | Next » 

Revision 792

xml_dom.py: Added TextEntryOnlyIter to check that values returned by NodeTextEntryIter are strings from text nodes

View differences:

lib/xml_dom.py
143 143
        self.iter_.next()
144 144
        return entry
145 145

  
146
def is_text_node_entry(val): return util.is_str(val[1])
147

  
148
class TextEntryOnlyIter(util.CheckedIter):
149
    def __init__(self, iterable):
150
        util.CheckedIter.__init__(self, is_text_node_entry, iterable)
151

  
146 152
#####
147 153

  
148 154
def set_child(node, name, value):
......
157 163
    old_node.parentNode.replaceChild(new_node, old_node) # note order reversed
158 164

  
159 165
def replace_with_text(node, new):
160
    if isinstance(new, basestring): new = node.ownerDocument.createTextNode(new)
166
    if util.is_str(new): new = node.ownerDocument.createTextNode(new)
161 167
    replace(node, new)
162 168

  
163 169
#####

Also available in: Unified diff