Project

General

Profile

« Previous | Next » 

Revision 453

xml_dom.py: Changed is_empty() to consider nodes with only comments to be empty

View differences:

xml_dom.py
18 18

  
19 19
def set_id(node, id_): node.setAttribute('id', id_)
20 20

  
21
def is_empty(node): return node.firstChild == None
21
def is_completely_empty(node): return node.firstChild == None
22 22

  
23 23
def has_one_child(node):
24 24
    return node.firstChild != None and node.firstChild.nextSibling == None
......
37 37
        self.child = self.child.nextSibling
38 38
        return child
39 39

  
40
def is_comment(node): return node.nodeType == Node.COMMENT_NODE
41

  
40 42
def is_elem(node): return node.nodeType == Node.ELEMENT_NODE
41 43

  
44
def is_empty(node):
45
    for child in NodeIter(node):
46
        if not is_comment(child): return False
47
    return True
48

  
42 49
class NodeElemIter:
43 50
    def __init__(self, node): self.child = node.firstChild
44 51
    

Also available in: Unified diff