Project

General

Profile

« Previous | Next » 

Revision 4330

xml_dom.py: Moved only_child() near related method has_one_child()

View differences:

lib/xml_dom.py
63 63
def has_one_child(node):
64 64
    return node.firstChild != None and node.firstChild.nextSibling == None
65 65

  
66
def only_child(node):
67
    if not has_one_child(node):
68
        raise Exception('Must contain only one child:\n'+str(node))
69
    return node.firstChild
70

  
66 71
def is_simple(node):
67 72
    '''Whether every child recursively has no more than one child'''
68 73
    return (not is_elem(node) or is_completely_empty(node)
......
139 144

  
140 145
def last_elem(node): return NodeElemReverseIter(node).next()
141 146

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

  
147 147
class NodeEntryIter:
148 148
    def __init__(self, node): self.iter_ = NodeElemIter(node)
149 149
    

Also available in: Unified diff