Project

General

Profile

« Previous | Next » 

Revision 4329

xml_dom.py: only_child(): Raise exception instead of failing assertion. Include invalid node in exception message for easier debugging.

View differences:

lib/xml_dom.py
140 140
def last_elem(node): return NodeElemReverseIter(node).next()
141 141

  
142 142
def only_child(node):
143
    assert has_one_child(node) # TODO: convert to an exception
143
    if not has_one_child(node):
144
        raise Exception('Must contain only one child:\n'+str(node))
144 145
    return node.firstChild
145 146

  
146 147
class NodeEntryIter:

Also available in: Unified diff