def convertIds(vistrail): actions = vistrail.db_get_actions() actions.sort(key=lambda x: x.db_id) objectDict = {} # refDict = {'objectDict': objectDict} graph = Graph() for action in actions: graph.add_vertex(action.db_id) graph.add_edge(action.db_prevId, action.db_id) def convertAction(actionId): if actionId == 0: return allOps = [] action = vistrail.db_get_action(actionId) # objectDict = refDict['objectDict'] # if action.actionType == 'delete' or action.actionType == 'change': # action.objectDict = copy.deepcopy(objectDict) # else: # action.objectDict = objectDict for operation in action.db_get_operations(): allOps.extend( convertOperation(vistrail, objectDict, operation.vtType, operation)) action.db_operations = allOps def removeObjects(actionId): if actionId == 0: return # print "removeObjects(%s)" % actionId action = vistrail.db_get_action(actionId) # need to reverse ops here reverseOps = action.db_get_operations() reverseOps.reverse() for operation in reverseOps: parentList = getTypeIdList(operation) removeObject(operation.db_what, operation.db_oldId, objectDict, parentList[:-1]) reverseOps.reverse() graph.dfs(enter_vertex=convertAction, leave_vertex=removeObjects)
def convertIds(vistrail): actions = vistrail.db_get_actions() actions.sort(key=lambda x: x.db_id) objectDict = {} # refDict = {'objectDict': objectDict} graph = Graph() for action in actions: graph.add_vertex(action.db_id) graph.add_edge(action.db_prevId, action.db_id) def convertAction(actionId): # print 'converting %s' % actionId if actionId == 0: return allOps = [] action = vistrail.db_get_action(actionId) # objectDict = refDict['objectDict'] # if action.actionType == 'delete' or action.actionType == 'change': # action.objectDict = copy.deepcopy(objectDict) # else: # action.objectDict = objectDict for operation in action.db_get_operations(): allOps.extend(convertOperation(vistrail, objectDict, operation.vtType, operation)) action.db_operations = allOps def removeObjects(actionId): if actionId == 0: return # print "removeObjects(%s)" % actionId action = vistrail.db_get_action(actionId) # need to reverse ops here reverseOps = action.db_get_operations() reverseOps.reverse() for operation in reverseOps: parentList = getTypeIdList(operation) removeObject(operation.db_what, operation.db_oldId, objectDict, parentList[:-1]) reverseOps.reverse() graph.dfs(enter_vertex=convertAction, leave_vertex=removeObjects)