Changeset 4260
- Timestamp:
- 07/05/07 15:02:54 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
WaveDev/branches/WaveDevNoAmara/wavedev/importResource.py
r4258 r4260 18 18 19 19 import os, sys 20 import amara21 from amara import binderytools22 20 23 21 import xml.dom.minidom … … 46 44 # Build the main component or device from the SCD file 47 45 # 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: 51 51 errorMsg(parent,"Invalid file: " + scdPath) 52 52 return None 53 53 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: 57 59 Rdescription='No description found in ' + spdPath 58 else: 59 Rdescription=str(doc_spd.softpkg.implementation.description) 60 #errorMsg(parent,Rdescription) 61 60 62 61 #Instantiate a new component of the appropriate type 63 if doc_scd.softwarecomponent.componenttype == u'resource':62 if componenttype == u'resource': 64 63 newComp = CC.Component(name=Rname,type='resource',description=Rdescription) 65 elif doc_scd.softwarecomponent.componenttype == u'executabledevice':64 elif componenttype == u'executabledevice': 66 65 newComp = CC.Component(name=Rname,type='executabledevice',description=Rdescription) 67 elif doc_scd.softwarecomponent.componenttype == u'loadabledevice':66 elif componenttype == u'loadabledevice': 68 67 newComp = CC.Component(name=Rname,type='loadabledevice',description=Rdescription) 69 elif doc_scd.softwarecomponent.componenttype == u'device':68 elif componenttype == u'device': 70 69 newComp = CC.Component(name=Rname,type='device',description=Rdescription) 71 70 else: … … 74 73 75 74 # 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 98 102 # Make sure that xml and code are not generated for this resource 99 103 newComp.generate = False … … 113 117 return newComp 114 118 115 # !noamara116 119 doc_prf = xml.dom.minidom.parse(prfPath) 117 120 try: