<s> from __future__ import division <EOL> import copy <EOL> from vistrails . db . versions . v0_9_3 . domain import DBVistrail , DBAction , DBTag , DBModule , DBConnection , DBPortSpec , DBFunction , DBParameter , DBLocation , DBAdd , DBChange , DBDelete , DBAnnotation , DBPort , DBAbstractionRef , DBGroup <EOL> def translateVistrail ( _vistrail ) : <EOL> vistrail = DBVistrail ( ) <EOL> for _action in _vistrail . db_actions : <EOL> ops = [ ] <EOL> for op in _action . db_operations : <EOL> if op . vtType == '<STR_LIT>' : <EOL> data = convert_data ( op . db_data ) <EOL> ops . append ( DBAdd ( id = op . db_id , <EOL> what = op . db_what , <EOL> objectId = op . db_objectId , <EOL> parentObjId = op . db_parentObjId , <EOL> parentObjType = op . db_parentObjType , <EOL> data = data ) ) <EOL> elif op . vtType == '<STR_LIT>' : <EOL> data = convert_data ( op . db_data ) <EOL> ops . append ( DBChange ( id = op . db_id , <EOL> what = op . db_what , <EOL> oldObjId = op . db_oldObjId , <EOL> newObjId = op . db_newObjId , <EOL> parentObjId = op . db_parentObjId , <EOL> parentObjType = op . db_parentObjType , <EOL> data = data ) ) <EOL> elif op . vtType == '<STR_LIT>' : <EOL> ops . append ( DBDelete ( id = op . db_id , <EOL> what = op . db_what , <EOL> objectId = op . db_objectId , <EOL> parentObjId = op . db_parentObjId , <EOL> parentObjType = op . db_parentObjType ) ) <EOL> annotations = [ ] <EOL> for annotation in _action . db_annotations : <EOL> annotations . append ( DBAnnotation ( id = annotation . db_id , <EOL> key = annotation . db_key , <EOL> value = annotation . db_value ) ) <EOL> session = _action . db_session <EOL> if not session : <EOL> session = None <EOL> else : <EOL> session = long ( _action . db_session ) <EOL> action = DBAction ( id = _action . db_id , <EOL> prevId = _action . db_prevId , <EOL> date = _action . db_date , <EOL> user = _action . db_user , <EOL> prune = _action . db_prune , <EOL> session = session , <EOL> operations = ops , <EOL> annotations = annotations ) <EOL> vistrail . db_add_action ( action ) <EOL> for _tag in _vistrail . db_tags : <EOL> tag = DBTag ( id = _tag . db_id , <EOL> name = _tag . db_name ) <EOL> vistrail . db_add_tag ( tag ) <EOL> vistrail . db_version = '<STR_LIT>' <EOL> return vistrail <EOL> def convert_data ( child ) : <EOL> if child . vtType == '<STR_LIT>' : <EOL> return DBModule ( id = child . db_id , <EOL> cache = child . db_cache , <EOL> name = child . db_name , <EOL> namespace = child . db_namespace , <EOL> package = child . db_package , <EOL> version = child . db_version , <EOL> tag = child . db_tag ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBAbstractionRef ( id = child . db_id , <EOL> name = child . db_name , <EOL> cache = child . db_cache , <EOL> abstraction_id = child . db_abstraction_id , <EOL> version = child . db_version ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBConnection ( id = child . db_id ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBPortSpec ( id = child . db_id , <EOL> name = child . db_name , <EOL> type = child . db_type , <EOL> spec = child . db_spec ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBFunction ( id = child . db_id , <EOL> pos = child . db_pos , <EOL> name = child . db_name ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBParameter ( id = child . db_id , <EOL> pos = child . db_pos , <EOL> name = child . db_name , <EOL> type = child . db_type , <EOL> val = child . db_val , <EOL> alias = child . db_alias ) <EOL> elif child . vtType == '<STR_LIT:location>' : <EOL> return DBLocation ( id = child . db_id , <EOL> x = child . db_x , <EOL> y = child . db_y ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBAnnotation ( id = child . db_id , <EOL> key = child . db_key , <EOL> value = child . db_value ) <EOL> elif child . vtType == '<STR_LIT:port>' : <EOL> return DBPort ( id = child . db_id , <EOL> type = child . db_type , <EOL> moduleId = child . db_moduleId , <EOL> moduleName = child . db_moduleName , <EOL> name = child . db_name , <EOL> spec = child . db_spec ) <EOL> elif child . vtType == '<STR_LIT>' : <EOL> return DBGroup ( id = child . db_id , <EOL> workflow = child . db_workflow , <EOL> cache = child . db_cache , <EOL> name = child . db_name , <EOL> namespace = child . db_namespace , <EOL> package = child . db_package , <EOL> version = child . db_version , <EOL> tag = child . db_tag ) </s>
