def makeStack(element):
 layers = []
 for child in element.childNodes:
  if (child.nodeType == child.ELEMENT_NODE):
   if (child.tagName == 'stack'):
    stack = makeStack(child)
    layers.append(stack)
   elif (child.tagName == 'layer'):
    layer = makeLayer(child)
    layers.append(layer)
   else:
    raise Exception(('Unknown element "%s"' % child.tagName))
 print >>sys.stderr, ('Making a stack with %d layers' % len(layers))
 return Stack(layers)

def makeStack ( element ) : layers = [ ] for child in element . childNodes : if ( child . nodeType == child . ELEMENT_NODE ) : if ( child . tagName == 'stack' ) : stack = makeStack ( child ) layers . append ( stack ) elif ( child . tagName == 'layer' ) : layer = makeLayer ( child ) layers . append ( layer ) else : raise Exception ( ( 'Unknown element "%s"' % child . tagName ) ) print >> sys . stderr , ( 'Making a stack with %d layers' % len ( layers ) ) return Stack ( layers )
build a stack object from an xml element .