def getCurrentOperationDict(actions, currentOperations=None):
    if currentOperations is None:
        currentOperations = {}

    # note that this operation assumes unique ids for each operation's data
    # any add adds to the dict, delete removes from the dict, and
    # change replaces the current value in the dict
    for action in actions:
        for operation in action.db_operations:
            operationvtType = operation.vtType
            d = operation.__dict__
            if operationvtType == 'add':
                currentOperations[(d['_db_what'], 
                                   d['_db_objectId'])] = \
                                   operation
            elif operationvtType == 'delete':
                what = d['_db_what']
                objectId = d['_db_objectId']
                t = (what, objectId)
                try:
                    del currentOperations[t]
                except KeyError:
                    msg = "Illegal delete operation: %d" % d['_db_id']
                    raise RuntimeError(msg)
            elif operationvtType == 'change':
                what = d['_db_what']
                objectId = d['_db_oldObjId']
                t = (what, objectId)
                try:
                    del currentOperations[t]
                except __HOLE__:
                    msg = "Illegal change operation: %d" % d['_db_id']
                    raise RuntimeError(msg)
                currentOperations[(what,
                                   d['_db_newObjId'])] = operation
            else:
                msg = "Unrecognized operation '%s'" % operation.vtType
                raise TypeError(msg)

    return currentOperations
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/db/services/action_chain.py/getCurrentOperationDict