Rev 4042 | Blame | Compare with Previous | Last modification | View Log | RSS feed
import utilsdef getscore(struct):score = 0.0storage_capacity_score = 0.0rotational_speed_score = 0.0optical_drive_score = 0.0if struct.has_key('childrenslides'):childslides = struct.get('childrenslides')if childslides.has_key('Hard disk drive'):hard_disk_drive_slide = childslides.get('Hard disk drive')if hard_disk_drive_slide.has_key('features'):features = hard_disk_drive_slide.get('features')if features.has_key('Storage capacity'):storage_capacity = float(features.get('Storage capacity')[0])if storage_capacity > 1024.0 and storage_capacity < (1024.0 * 1024.0):storage_capacity = storage_capacity / 1024.0 #MBs to GBselif storage_capacity > 1024.0 * 1024.0:storage_capacity = storage_capacity / (1024.0 * 1024.0) #KBs to GBsif storage_capacity <= 250.0:storage_capacity_score = 4.0elif storage_capacity > 640.0:storage_capacity_score = 10.0else:storage_capacity_score = 4.0 + (storage_capacity - 250.0) * 6.0 / 390.0if features.has_key('Hard disk rotational speed'):rotational_speed = features.get('Hard disk rotational speed')[0]rotational_speed_score = 5.0 if int(rotational_speed) <= 5400 else 10.0if childslides.has_key('Optical drive'):optical_drive_slide = childslides.get('Optical drive')if optical_drive_slide.has_key('features'):features = optical_drive_slide.get('features')if features.has_key('Type'):optical_drive_score = 10.0 #TODO: Get the list of optical drive typesscore = (70.0 * storage_capacity_score + 10.0 * rotational_speed_score + 20.0 * optical_drive_score) / 100.0return scoreprint "expSlide=" + `expSlide`struct = utils.contentModel2Struct(expSlide, categoryObj)print "struct=" + `struct`score = getscore(struct)