mod1 = [x for x in modules if x.id == link.parent_a][0]

    port = ElementTree.SubElement(add2, 'port')
    port.attrib['id'] = str(count['port'])
    port.attrib['moduleId'] =  str(mod1.vt_id)
    port.attrib['moduleName'] = mod1.type
    modname1 = mod1.type
    modport1 = link.port_a

    try:
        port.attrib['name'] = web2vt.get_port_name(mod1.type, link.port_a)
    except KeyError:
        port.attrib['name'] = str(modport1)#inportname[0]
    try:
        port.attrib['signature'] = web2vt.get_signature(mod1.type, link.port_a)
    except KeyError:
        port.attrib['signature'] = '(org.vistrails.vistrails.basic:String)'
    try:
        port.attrib['type'] = web2vt.get_port_type(mod1.type, link.port_a)
    except KeyError:
        if modport1 in inportname.values():
            port.attrib['type'] = 'destination'#inporttype[0]
        else:
            port.attrib['type'] = 'source'
    # port.attrib['name'] = get_port_name(mod1.type, link.port_a)
    # port.attrib['signature'] = get_signature(mod1.type, link.port_a)
    # port.attrib['type'] = get_port_type(mod1.type, link.port_a)

    count['add'] += 1
    count['port'] += 1
                count['action'] += 1
                count['function'] += 1
    
                in_add2 = ElementTree.SubElement(in_act, 'add')
                in_add2.attrib['id'] = str(count['add'])
                in_add2.attrib['objectId'] = str(count['parameter'])
                in_add2.attrib['parentObjId'] = str(count['parameter'])
                in_add2.attrib['parentObjType'] = 'function'
                in_add2.attrib['what'] = 'parameter'
    
                in_param = ElementTree.SubElement(in_add2, 'parameter')
                in_param.attrib['alias'] = ''
                in_param.attrib['id'] = str(count['parameter'])
                in_param.attrib['name'] = '<no description>'
                in_param.attrib['pos'] = '0'
                in_param.attrib['type'] = web2vt.get_signature(mod.type, name) 
                in_param.attrib['val'] = str(value)
    
                count['add'] += 1
                count['parameter'] += 1
        else:
            in_act = ElementTree.SubElement(vt, 'action')
            in_act.attrib['date'] = '2014-01-01 00:00:00'
            in_act.attrib['id'] = str(count['action'])
            in_act.attrib['prevId'] = str(count['action'] - 1)
            in_act.attrib['session'] = '0'
            in_act.attrib['user'] = '******'

            in_add = ElementTree.SubElement(in_act, 'add')
            in_add.attrib['id'] = str(count['add'])
            in_add.attrib['objectId'] = str(count['function'])