Project

General

Profile

« Previous | Next » 

Revision 1176

xml_dom.py: NodeTextEntryIter: Filter out empty entries (instead of producing an entry with an explicit None value, which causes problems with XML funcs that can't handle Nones)

View differences:

lib/xml_dom.py
145 145
    
146 146
    def __iter__(self): return self
147 147
    
148
    def curr(self):
149
        entry = self.iter_.curr()
148
    def next(self):
149
        util.skip(self.iter_, is_empty)
150
        entry = self.iter_.next()
150 151
        if is_text(entry): value_ = value(entry)
151
        elif is_empty(entry): value_ = None
152 152
        else:
153 153
            assert has_one_child(entry) # TODO: convert to an exception
154 154
            value_ = entry.firstChild
155 155
        return (entry.tagName, value_)
156
    
157
    def next(self):
158
        entry = self.curr()
159
        self.iter_.next()
160
        return entry
161 156

  
162 157
def is_text_node_entry(val): return util.is_str(val[1])
163 158

  

Also available in: Unified diff