Changeset 4268

Show
Ignore:
Timestamp:
07/09/07 17:50:18 (6 years ago)
Author:
jgaeddert
Message:

finished removing Amara from component_gen.py except for odd simplesequence of provides ports

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • WaveDev/branches/WaveDevNoAmara/wavedev/XML_gen/component_gen.py

    r4267 r4268  
    2121import os, copy 
    2222import shutil 
    23 from amara import binderytools 
    2423 
    2524import xml.dom.minidom 
     
    189188def gen_prf(comp, waveformDir): 
    190189    componentName = unicode(comp.name)     
    191     doc_prf = binderytools.bind_file('XML_gen/_prf.xml.tpl') 
    192      
     190    doc_prf = xml.dom.minidom.parse('XML_gen/_prf.xml.tpl') 
     191     
     192    propertiesNode = doc_prf.getElementsByTagName("properties")[0] 
     193 
    193194    for p in comp.properties: 
    194195        if p.elementType == "Simple": 
    195             e = doc_prf.xml_create_element(u'simple', attributes={u'name': unicode(p.name),u'id': unicode(p.id), u'type': unicode(p.type), u'mode': unicode(p.mode)}) 
    196             doc_prf.properties.xml_append(e) 
    197             newLen = len(list(doc_prf.properties.simple)) 
    198             e = doc_prf.xml_create_element(u'description',content=unicode(p.description)) 
    199             doc_prf.properties.simple[newLen-1].xml_append(e) 
    200             e = doc_prf.xml_create_element(u'value',content=unicode(p.value)) 
    201             doc_prf.properties.simple[newLen-1].xml_append(e) 
    202             e = doc_prf.xml_create_element(u'kind',attributes={u'kindtype': unicode(p.kind)}) 
    203             doc_prf.properties.simple[newLen-1].xml_append(e) 
     196            e = doc_prf.createElement("simple") 
     197 
     198            # Add the property value 
     199            valueNode = doc_prf.createElement("value") 
     200            valueText = doc_prf.createTextNode(unicode(p.value)) 
     201            valueNode.appendChild(valueText) 
     202 
     203            e.appendChild(valueNode) 
    204204 
    205205        elif p.elementType == "SimpleSequence": 
    206             e = doc_prf.xml_create_element(u'simplesequence', attributes={u'name': unicode(p.name),u'id': unicode(p.id), u'type': unicode(p.type), u'mode': unicode(p.mode)}) 
    207             doc_prf.properties.xml_append(e) 
    208             newLen = len(list(doc_prf.properties.simplesequence)) 
    209             e = doc_prf.xml_create_element(u'description',content=unicode(p.description)) 
    210             doc_prf.properties.simplesequence[newLen-1].xml_append(e) 
    211  
    212             e = doc_prf.xml_create_element(u'values') 
    213             doc_prf.properties.simplesequence[newLen-1].xml_append(e) 
    214  
     206            e = doc_prf.createElement("simplesequence") 
     207 
     208            # Add the property values 
     209            valuesNode = doc_prf.createElement("values") 
    215210            for x in p.values: 
    216                 e = doc_prf.xml_create_element(u'value',content=unicode(x[0])) 
    217                 doc_prf.properties.simplesequence[newLen-1].values.xml_append(e) 
    218             e = doc_prf.xml_create_element(u'kind',attributes={u'kindtype': unicode(p.kind)}) 
    219             doc_prf.properties.simplesequence[newLen-1].xml_append(e) 
    220  
     211                valueNode = doc_prf.createElement("value") 
     212                valueText = doc_prf.createTextNode(x[0]) 
     213                valueNode.appendChild(valueText) 
     214                valuesNode.appendChild(valueNode) 
     215 
     216            e.appendChild(valuesNode) 
     217 
     218        e.setAttribute("type", unicode(p.type)) 
     219        e.setAttribute("id", unicode(p.id)) 
     220        e.setAttribute("name", unicode(p.name)) 
     221        e.setAttribute("mode", unicode(p.mode)) 
     222 
     223        # Add the property description 
     224        descriptionNode = doc_prf.createElement("description") 
     225        descriptionText = doc_prf.createTextNode(unicode(p.description)) 
     226        descriptionNode.appendChild(descriptionText) 
     227        e.appendChild(descriptionNode) 
     228             
     229        # Add the property kind 
     230        kindNode = doc_prf.createElement("kind") 
     231        kindNode.setAttribute("kindtype", unicode(p.kind)) 
     232        e.appendChild(kindNode) 
     233 
     234        propertiesNode.appendChild(e) 
     235             
     236    """ 
    221237    # Create a simplesequence of string type that lists each Provides port in the component 
    222238    # Used for connecting to components from outside the framework (ex. control gui) 
     
    241257        e = doc_prf.xml_create_element(u'kind',attributes={u'kindtype': u'configure'}) 
    242258        doc_prf.properties.simplesequence[newLen-1].xml_append(e) 
    243      
     259    """ 
    244260     
    245261    # Now do final processing and write to file 
     
    248264    #outputFileName_prf = comp.name + 'Resource' + '.prf.xml' 
    249265     
    250     data = doc_prf.xml() 
     266    data = doc_prf.toxml('UTF-8') 
    251267    xmlBeautify.beautify(data,compDir + '.' + outputFileName_prf + '.tmp') 
    252268