Changeset 4265

Show
Ignore:
Timestamp:
07/06/07 16:59:13 (6 years ago)
Author:
jgaeddert
Message:

removing Amara dependency from importNode.py

Location:
WaveDev/branches/WaveDevNoAmara/wavedev
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • WaveDev/branches/WaveDevNoAmara/wavedev/MainFrame.py

    r4258 r4265  
    14811481         
    14821482        nodeList = [] 
    1483         if os.path.isdir(self.installPath + 'nodes'): 
    1484             nodeList = os.listdir(self.installPath + 'nodes') 
     1483        if os.path.isdir(self.installPath + 'dev/nodes'): 
     1484            nodeList = os.listdir(self.installPath + 'dev/nodes') 
    14851485        else: 
    14861486            errorMsg(self, "No nodes could be found in: " + self.installPath) 
    1487                  
    1488         # find the scd 
    1489         for node_name in nodeList:           
    1490             tmpNode = importNode.getNode(self.installPath+'nodes/'+node_name,node_name,self) 
     1487         
     1488        # find the scd files for each node 
     1489        for node_name in nodeList: 
     1490            # check for .xml extension (case independent) 
     1491            xmlext = os.path.splitext(node_name) 
     1492            if xmlext[1].lower() != ".xml": 
     1493                continue 
     1494 
     1495            # check for .scd extension 
     1496            scdext = os.path.splitext(xmlext[0]) 
     1497            if scdext[1].lower() != ".scd": 
     1498                continue 
     1499 
     1500            nodeName = scdext[0] 
     1501            nodePath = self.installPath + 'dev/nodes/' 
     1502             
     1503            tmpNode = importNode.getNode(nodePath,nodeName,self) 
    14911504            if tmpNode == None: 
     1505                print "WARNING: possibly an error reading node " + nodePath + "/" + nodeName 
    14921506                continue 
    14931507            self.Available_Nodes.append(tmpNode) 
  • WaveDev/branches/WaveDevNoAmara/wavedev/importNode.py

    r4262 r4265  
    1818 
    1919import os, sys 
    20 import amara 
    21 from amara import binderytools 
    2220 
    2321import xml.dom.minidom 
    2422from xml.dom.minidom import Node 
     23from importResource import getSimpleProperty, getSimpleSequenceProperty 
    2524 
    2625import ComponentClass as CC 
     
    3534def getNode(inpath,Nname,parent): 
    3635     
    37     scdPath = inpath+"/DeviceManager.scd.xml" 
    38     spdPath = inpath+"/DeviceManager.spd.xml" 
    39     prfPath = inpath+"/DeviceManager.prf.xml" 
    40     dcdPath = inpath+"/DeviceManager.dcd.xml" 
     36    scdPath = inpath + "/" + Nname + ".scd.xml" 
     37    spdPath = inpath + "/" + Nname + ".spd.xml" 
     38    prfPath = inpath + "/" + Nname + ".prf.xml" 
     39    dcdPath = inpath + "/" + Nname + ".dcd.xml" 
     40 
    4141     
    4242    newNode = CC.Node(Nname, inpath, generate=False) 
     
    5151        return None 
    5252     
    53     deviceconfigurationNodeList = doc_dcd.getElementsByTagName('deviceconfiguration') 
    54     if len(deviceconfigurationNodeList) != 1: 
     53    try: 
     54        deviceconfigurationNode = doc_dcd.getElementsByTagName('deviceconfiguration')[0] 
     55    except: 
    5556        errorMsg(parent,"Invalid file: " + dcdPath + " (deviceconfiguration)") 
    5657        return None 
    57     newNode.id = deviceconfigurationNodeList[0].getAttributes("id") 
     58    newNode.id = deviceconfigurationNode.getAttribute("id") 
    5859     
    5960    # xxx 
     
    8081                del localfileNodeList 
    8182                break 
    82         pathSPD = parent.installPath + local_SPD 
     83        pathSPD = parent.installPath + "dev/" + local_SPD 
    8384 
    8485        doc_spd = xml.dom.minidom.parse(pathSPD) 
     
    8788        #pathSCD = "/sdr/sca/xml/"+newComp.baseName+"/"+doc_spd.softpkg.descriptor.localfile.name 
    8889        localfileNode = softpkgNode.getElementsByTagName("localfile")[0] 
    89         pathSCD = parent.installPath + localfileNode.getAttribute("name") 
     90        pathSCD = os.path.dirname(pathSPD) + "/" + localfileNode.getAttribute("name") 
    9091 
    9192        doc_scd = xml.dom.minidom.parse(pathSCD) 
    9293 
    9394        # Get the Ports 
    94         # Why is this done twice?  Wasn't this already accomplished in importResource.py? -JDG 
    95         if hasattr(doc_scd.softwarecomponent.componentfeatures,'ports'): 
    96             ports = doc_scd.softwarecomponent.componentfeatures.ports 
    97             if hasattr(ports,'provides'): 
    98                 for p in ports.provides: 
    99                     tmpName = p.providesname 
    100                     tmpInt = getInterface(p.repid,tmpName) 
    101                     if tmpInt == None: 
    102                         return None 
    103                     tmpType = p.porttype.type 
    104                     newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType) 
    105                     newComp.ports.append(newPort) 
    106                  
    107             if hasattr(ports,'uses'): 
    108                 for p in ports.uses: 
    109                     tmpName = p.usesname 
    110                     tmpInt = getInterface(p.repid,tmpName) 
    111                     if tmpInt == None: 
    112                         return None 
    113                     tmpType = p.porttype.type 
    114                     newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType) 
    115                     newComp.ports.append(newPort) 
     95        portsNodes = doc_scd.getElementsByTagName("ports") 
     96        for node in portsNodes: 
     97            providesPortsNodes = node.getElementsByTagName("provides") 
     98            usesPortsNodes = node.getElementsByTagName("uses") 
     99 
     100        # Provides ports 
     101        for node in providesPortsNodes: 
     102            tmpName = node.getAttribute("providesname") 
     103            tmpInt = getInterface( node.getAttribute("repid"), tmpName ) 
     104            if tmpInt == None: 
     105                return None 
     106            portTypeNodeList = node.getElementsByTagName("porttype") 
     107            tmpType = portTypeNodeList[0].getAttribute("type") 
     108            newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType) 
     109            newComp.ports.append(newPort) 
     110 
     111        # Uses ports 
     112        for node in usesPortsNodes: 
     113            tmpName = node.getAttribute("usesname") 
     114            tmpInt = getInterface( node.getAttribute("repid"), tmpName ) 
     115            if tmpInt == None: 
     116                return None 
     117            portTypeNodeList = node.getElementsByTagName("porttype") 
     118            tmpType = portTypeNodeList[0].getAttribute("type") 
     119            newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType) 
     120            newComp.ports.append(newPort) 
    116121                     
    117122        # Make sure that xml and code are not generated for this resource 
     
    119124         
    120125        # Store the name of the file without the suffix (.scd.xml) 
    121         i = pathSCD.rfind("/") 
    122         if i != -1: 
    123             newComp.xmlName = pathSCD[i+1:-8] 
    124         else: 
    125             newComp.xmlName = pathSCD[:-8] 
     126        newComp.xmlName =  os.path.splitext(os.path.splitext(os.path.basename(pathSCD))[0])[0] 
    126127        
    127128        newNode.Devices.append(newComp) 
     
    205206 
    206207    return xml 
    207                                                                      
    208  
    209 def getSimpleProperty(s):    
    210     if not hasattr(s,"name"): 
    211         return None 
    212     tmpName = s.name 
    213     if not hasattr(s,"id"): 
    214         return None 
    215     tmpId = s.id 
    216     if not hasattr(s,"type"): 
    217         return None 
    218     tmpType = s.type     
    219     if not hasattr(s,"mode"): 
    220         return None 
    221     tmpMode = s.mode     
    222     if hasattr(s,"description"): 
    223         tmpDes = str(s.description) 
    224     else: 
    225         tmpDes = '' 
    226      
    227     if tmpMode not in availableModes: 
    228         return None 
    229     if tmpType not in availableTypes: 
    230         return None 
    231      
    232     newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,description=tmpDes) 
    233      
    234     if hasattr(s,"value"): 
    235         newProp.value = newProp.defaultValue = str(s.value) 
    236      
    237     if hasattr(s,"units"): 
    238         newProp.units = str(s.units) 
    239          
    240     if hasattr(s,"range"): 
    241         newProp.range = (str(s.range.min),str(s.range.max)) 
    242          
    243     if hasattr(s,"enum"): 
    244         newProp.enum = str(s.enum.label) 
    245          
    246     if not hasattr(s, "kind"): 
    247         return None     
    248     newProp.kind = str(s.kind.kindtype) 
    249      
    250     if hasattr(s,"action"): 
    251         newProp.action = str(s.action.type) 
    252          
    253     return newProp 
    254      
    255 def getSimpleSequenceProperty(s):    
    256     if not hasattr(s,"name"): 
    257         return None 
    258     tmpName = s.name 
    259     if not hasattr(s,"id"): 
    260         return None 
    261     tmpId = s.id 
    262     if not hasattr(s,"type"): 
    263         return None 
    264     tmpType = s.type     
    265     if not hasattr(s,"mode"): 
    266         return None 
    267     tmpMode = s.mode     
    268     if hasattr(s,"description"): 
    269         tmpDes = str(s.description) 
    270     else: 
    271         tmpDes = '' 
    272      
    273     if tmpMode not in availableModes: 
    274         return None 
    275     if tmpType not in availableTypes: 
    276         return None 
    277      
    278     newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,description=tmpDes,values=[]) 
    279      
    280     if hasattr(s,"value"): 
    281         for val in s.value: 
    282             newProp.values.append((str(val), str(val))) 
    283      
    284     if hasattr(s,"units"): 
    285         newProp.units = str(s.units) 
    286          
    287     if hasattr(s,"range"): 
    288         newProp.range = (str(s.range.min),str(s.range.max)) 
    289          
    290     if not hasattr(s, "kind"): 
    291         return None     
    292     newProp.kind = str(s.kind.kindtype) 
    293      
    294     if hasattr(s,"action"): 
    295         newProp.action = str(s.action.type) 
    296          
    297     return newProp 
     208