def setType(props, prop_id, _type, typeCheck=True):
'''
change the property type for the element in the props sequence with id of prop_id
This method returns a copy of props (does not modify the props input)
'''
if typeCheck:
__typeCheck(props)
if not properties.getTypeMap().has_key(_type):
raise BadValue('Type "'+_type+'" does not exist')
if _type == getType(props, prop_id, False):
return props
prop_idx = __getPropIdx(props, prop_id)
ret_props = copy.deepcopy(props)
if props[prop_idx].value._t._k == CORBA.tk_sequence:
ret_props[prop_idx].value._t._d = (props[prop_idx].value._t._d[0], tvCode(_type), props[prop_idx].value._t._d[2])
else:
ret_props[prop_idx].value = properties.to_tc_value(props[prop_idx].value,_type)
return ret_props
评论列表
文章目录