Changeset 4260

Show
Ignore:
Timestamp:
07/05/07 15:02:54 (6 years ago)
Author:
jgaeddert
Message:

removing amara dependency completely from importResource.py

Files:
1 modified

Legend:

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

    r4258 r4260  
    1818 
    1919import os, sys 
    20 import amara 
    21 from amara import binderytools 
    2220 
    2321import xml.dom.minidom 
     
    4644    # Build the main component or device from the SCD file     
    4745    # 
    48     doc_scd = amara.parse(stripDoctype(scdPath)) 
    49     #doc_scd = binderytools.bind_file(scdPath) 
    50     if not hasattr(doc_scd.softwarecomponent,'componenttype'): 
     46    doc_scd = xml.dom.minidom.parse(scdPath) 
     47    try: 
     48        componenttypeNode = doc_scd.getElementsByTagName("componenttype") 
     49        componenttype = componenttypeNode[0].childNodes[0].data 
     50    except: 
    5151        errorMsg(parent,"Invalid file: " + scdPath) 
    5252        return None 
    5353     
    54     doc_spd = amara.parse(stripDoctype(spdPath)) 
    55     if not hasattr(doc_spd.softpkg.implementation, 'description'): 
    56         #errorMsg(parent,'No description found in ' + spdPath) 
     54    doc_spd = xml.dom.minidom.parse(spdPath) 
     55    descriptionNode = doc_spd.getElementsByTagName("description") 
     56    try: 
     57        Rdescription = descriptionNode[0].childNodes[0].data 
     58    except: 
    5759        Rdescription='No description found in ' + spdPath 
    58     else: 
    59         Rdescription=str(doc_spd.softpkg.implementation.description) 
    60         #errorMsg(parent,Rdescription) 
    61      
     60 
    6261    #Instantiate a new component of the appropriate type 
    63     if doc_scd.softwarecomponent.componenttype == u'resource': 
     62    if componenttype == u'resource': 
    6463        newComp = CC.Component(name=Rname,type='resource',description=Rdescription) 
    65     elif doc_scd.softwarecomponent.componenttype == u'executabledevice': 
     64    elif componenttype == u'executabledevice': 
    6665        newComp = CC.Component(name=Rname,type='executabledevice',description=Rdescription) 
    67     elif doc_scd.softwarecomponent.componenttype == u'loadabledevice': 
     66    elif componenttype == u'loadabledevice': 
    6867        newComp = CC.Component(name=Rname,type='loadabledevice',description=Rdescription) 
    69     elif doc_scd.softwarecomponent.componenttype == u'device': 
     68    elif componenttype == u'device': 
    7069        newComp = CC.Component(name=Rname,type='device',description=Rdescription) 
    7170    else: 
     
    7473         
    7574    # Get the Ports 
    76     if hasattr(doc_scd.softwarecomponent.componentfeatures,'ports'): 
    77         ports = doc_scd.softwarecomponent.componentfeatures.ports 
    78         if hasattr(ports,'provides'): 
    79             for p in ports.provides: 
    80                 tmpName = p.providesname 
    81                 tmpInt = getInterface(p.repid,tmpName) 
    82                 if tmpInt == None: 
    83                     return None 
    84                 tmpType = p.porttype.type 
    85                 newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType) 
    86                 newComp.ports.append(newPort) 
    87                  
    88         if hasattr(ports,'uses'): 
    89             for p in ports.uses: 
    90                 tmpName = p.usesname 
    91                 tmpInt = getInterface(p.repid,tmpName) 
    92                 if tmpInt == None: 
    93                     return None 
    94                 tmpType = p.porttype.type 
    95                 newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType) 
    96                 newComp.ports.append(newPort) 
    97      
     75    portsNodes = doc_scd.getElementsByTagName("ports") 
     76    for node in portsNodes: 
     77        providesPortsNodes = node.getElementsByTagName("provides") 
     78        usesPortsNodes = node.getElementsByTagName("uses") 
     79 
     80    # Provides ports 
     81    for node in providesPortsNodes: 
     82        tmpName = node.getAttribute("providesname") 
     83        tmpInt = getInterface( node.getAttribute("repid"), tmpName ) 
     84        if tmpInt == None: 
     85            return None 
     86        portTypeNodeList = node.getElementsByTagName("porttype") 
     87        tmpType = portTypeNodeList[0].getAttribute("type") 
     88        newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType) 
     89        newComp.ports.append(newPort) 
     90 
     91    # Uses ports 
     92    for node in usesPortsNodes: 
     93        tmpName = node.getAttribute("usesname") 
     94        tmpInt = getInterface( node.getAttribute("repid"), tmpName ) 
     95        if tmpInt == None: 
     96            return None 
     97        portTypeNodeList = node.getElementsByTagName("porttype") 
     98        tmpType = portTypeNodeList[0].getAttribute("type") 
     99        newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType) 
     100        newComp.ports.append(newPort) 
     101 
    98102    # Make sure that xml and code are not generated for this resource 
    99103    newComp.generate = False         
     
    113117        return newComp 
    114118 
    115     # !noamara 
    116119    doc_prf = xml.dom.minidom.parse(prfPath) 
    117120    try: