| 4036 |
varun.gupt |
1 |
import utils
|
|
|
2 |
|
|
|
3 |
def getscore(struct):
|
|
|
4 |
|
|
|
5 |
score = 0.0
|
|
|
6 |
storage_capacity_score = 0.0
|
|
|
7 |
rotational_speed_score = 0.0
|
|
|
8 |
optical_drive_score = 0.0
|
|
|
9 |
|
|
|
10 |
if struct.has_key('childrenslides'):
|
|
|
11 |
childslides = struct.get('childrenslides')
|
|
|
12 |
|
|
|
13 |
if childslides.has_key('Hard disk drive'):
|
|
|
14 |
hard_disk_drive_slide = childslides.get('Hard disk drive')
|
|
|
15 |
|
|
|
16 |
if hard_disk_drive_slide.has_key('features'):
|
|
|
17 |
features = hard_disk_drive_slide.get('features')
|
|
|
18 |
|
|
|
19 |
if features.has_key('Storage capacity'):
|
|
|
20 |
storage_capacity = int(features.get('Storage capacity')[0])
|
|
|
21 |
|
|
|
22 |
if storage_capacity > 1024 and storage_capacity < (1024 * 1024):
|
|
|
23 |
storage_capacity = storage_capacity / 1024 #MBs to GBs
|
|
|
24 |
elif storage_capacity > 1024 * 1024:
|
|
|
25 |
storage_capacity = storage_capacity / (1024 * 1024) #KBs to GBs
|
|
|
26 |
|
|
|
27 |
if storage_capacity <= 250.0:
|
|
|
28 |
storage_capacity_score = 4.0
|
|
|
29 |
elif storage_capacity > 640.0:
|
|
|
30 |
storage_capacity_score = 10.0
|
|
|
31 |
else:
|
|
|
32 |
storage_capacity_score = 4.0 + (storage_capacity - 250.0) * 6.0 / 390.0
|
|
|
33 |
|
|
|
34 |
if features.has_key('Hard disk rotational speed'):
|
|
|
35 |
rotational_speed = features.get('Hard disk rotational speed')
|
|
|
36 |
rotational_speed_score = 5.0 if int(rotational_speed) <= 5400 else 10.0
|
|
|
37 |
|
|
|
38 |
if childslides.has_key('Optical drive'):
|
|
|
39 |
optical_drive_slide = childslides.get('Optical drive')
|
|
|
40 |
|
|
|
41 |
if optical_drive_slide.has_key('features'):
|
|
|
42 |
features = optical_drive_slide.get('features')
|
|
|
43 |
|
|
|
44 |
if features.has_key('Type'):
|
|
|
45 |
optical_drive_score = 10.0 #TODO: Get the list of optical drive types
|
|
|
46 |
|
|
|
47 |
score = (70.0 * storage_capacity_score + 10.0 * rotational_speed_score + 20.0 * optical_drive_score) / 100.0
|
|
|
48 |
return score
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
print "expSlide=" + `expSlide`
|
|
|
52 |
|
|
|
53 |
struct = utils.contentModel2Struct(expSlide, categoryObj)
|
|
|
54 |
print "struct=" + `struct`
|
|
|
55 |
|
|
|
56 |
score = getscore(struct)
|