예제 #1
0
def _doNodes(xml):
    cablenode = CableNode(xml.tag)

    for prop in xml.keys():
        cablenode.values[prop] = xml.attrib[prop]

    if _isws(xml.text) == False:
        cablenode.values["__text_"] = xml.text

    for child in xml:
        cablenode.addChild(_doNodes(child))

    return cablenode
예제 #2
0
 def _parse(self):
     """Parses the array of tokens and builds the tree.
     """
     if self._current().tokentype != CableToken.Type.Word:
         pass
         #throw CableException("invalid node identifier")
     
     node = CableNode(self._current().value)
     self.next+= 1
     
     while self._current().tokentype == CableToken.Type.Word:
         name = self._current().value
         self.next+= 1
         if self._current().tokentype != CableToken.Type.Set:
             print "FATAL ERROR: PROPERTY/VALUE MISMATCH; = MISSING"
         
         self.next+= 1
         _currenttype = self._current().tokentype
         if _currenttype == CableToken.Type.true:
             node.values[name] = "true"
             
         elif _currenttype == CableToken.Type.false:
             node.values[name] = "false"
             
         else:# _currenttype == CableToken.Type.String or _currenttype == CableToken.Type.Numeric:
             node.values[name] = self._current().value
             
         self.next+= 1
             
     if(self._current().tokentype == CableToken.Type.End):
         self.next+= 1
         return node
         
     if(self._current().tokentype == CableToken.Type.OpenBracket):
         self.next+= 1
         while self._current().tokentype != CableToken.Type.CloseBracket:
             node.addChild(self._parse())
         
         self.next+= 1
         
     return node