Пример #1
0
def convert_data(child):
    if child.vtType == 'module':
        return DBModule(id=child.db_id,
                        cache=child.db_cache,
                        name=child.db_name)
    elif child.vtType == 'connection':
        return DBConnection(id=child.db_id)
    elif child.vtType == 'portSpec':
        return DBPortSpec(id=child.db_id,
                          name=child.db_name,
                          type=child.db_type,
                          spec=child.db_spec)
    elif child.vtType == 'function':
        return DBFunction(id=child.db_id, pos=child.db_pos, name=child.db_name)
    elif child.vtType == 'parameter':
        return DBParameter(id=child.db_id,
                           pos=child.db_pos,
                           name=child.db_name,
                           type=child.db_type,
                           val=child.db_val,
                           alias=child.db_alias)
    elif child.vtType == 'location':
        return DBLocation(id=child.db_id, x=child.db_x, y=child.db_y)
    elif child.vtType == 'annotation':
        return DBAnnotation(id=child.db_id,
                            key=child.db_key,
                            value=child.db_value)
    elif child.vtType == 'port':
        return DBPort(id=child.db_id,
                      type=child.db_type,
                      moduleId=child.db_moduleId,
                      moduleName=child.db_moduleName,
                      sig=child.db_sig)
Пример #2
0
def createAction(_action, operations, id_scope):
    annotations = {}
    if _action.db_notes is not None and _action.db_notes.strip() != '':
        annotations['notes'] = DBAnnotation(id=id_scope.getNewId(DBAnnotation.vtType),
                                            key='notes',
                                            value=_action.db_notes.strip(),
                                            )
    return DBAction(id=_action.db_time,
                    prevId=_action.db_parent,
                    date=convertDate(_action.db_date),
                    user=_action.db_user,
                    operations=operations,
                    annotations=annotations,
                    )
Пример #3
0
def translateChangeAnnotationAction(_action, id_scope):
    operations = []
    for _annotation in _action.db_datas:
        if _annotation.db_key.strip() != '' or \
                _annotation.db_value.strip() != '':
            annotation = DBAnnotation(id=-1,
                                      key=_annotation.db_key,
                                      value=_annotation.db_value)
            operation = DBChange(id=_action.db_time,
                                 what='annotation',
                                 oldObjId=_annotation.db_key,
                                 parentObjId=_annotation.db_moduleId,
                                 parentObjType='module',
                                 data=annotation)
            operations.append(operation)

    return createAction(_action, operations, id_scope)