| 75 |
naveen |
1 |
import math
|
|
|
2 |
|
| 71 |
naveen |
3 |
def getscore(struct):
|
| 75 |
naveen |
4 |
|
|
|
5 |
score = 0.0
|
|
|
6 |
|
|
|
7 |
if struct.has_key("features") :
|
|
|
8 |
# REVISIT - Nokia power adaptor should get more points
|
|
|
9 |
# Power Adaptor
|
|
|
10 |
|
|
|
11 |
# REVISIT - Certain battery types need to be than others
|
|
|
12 |
# Battery Type
|
|
|
13 |
pass
|
|
|
14 |
|
|
|
15 |
# Max will be 1.5 * 7 = ceil(10.5) = 10
|
|
|
16 |
if struct.has_key("childrenslides") :
|
|
|
17 |
childrenslides = struct.get("childrenslides")
|
|
|
18 |
|
|
|
19 |
if childrenslides.has_key("Capacity") :
|
|
|
20 |
capacity = childrenslides.get("Capacity")
|
|
|
21 |
if capacity.has_key("features") :
|
|
|
22 |
features = capacity.get("features")
|
|
|
23 |
|
|
|
24 |
# Capacity > Music Playback : <20 - 0.5, <35 - 1, >35 - 1.5
|
|
|
25 |
if features.has_key("Music Playback") :
|
|
|
26 |
musicplayback = features.get("Music Playback")
|
|
|
27 |
|
| 76 |
naveen |
28 |
if len(musicplayback) > 0 :
|
|
|
29 |
musicplayback = int(musicplayback[0])
|
|
|
30 |
print "musicplayback=" + `musicplayback`
|
|
|
31 |
|
|
|
32 |
if musicplayback < 20 :
|
|
|
33 |
score = score + 0.5
|
|
|
34 |
|
|
|
35 |
elif musicplayback < 35 :
|
|
|
36 |
score = score + 1.0
|
|
|
37 |
|
|
|
38 |
elif musicplayback > 35 :
|
|
|
39 |
score = score + 1.5
|
| 75 |
naveen |
40 |
|
|
|
41 |
# Capacity > Video Playback : <2 - 0.5, <5 - 1, >5 - 1.5
|
|
|
42 |
if features.has_key("Video Playback") :
|
|
|
43 |
videoplayback = features.get("Video Playback")
|
| 76 |
naveen |
44 |
|
|
|
45 |
if len(videoplayback) > 0 :
|
|
|
46 |
videoplayback = int(videoplayback[0])
|
|
|
47 |
print "videoplayback=" + `videoplayback`
|
|
|
48 |
|
|
|
49 |
if videoplayback < 2 :
|
|
|
50 |
score = score + 0.5
|
|
|
51 |
|
|
|
52 |
elif videoplayback < 5 :
|
|
|
53 |
score = score + 1.0
|
|
|
54 |
|
|
|
55 |
elif videoplayback > 5 :
|
|
|
56 |
score = score + 1.5
|
| 75 |
naveen |
57 |
|
|
|
58 |
# Capacity > TV Playback : <2 - 0.5, <5 - 1, >5 - 1.5
|
|
|
59 |
if features.has_key("TV Playback") :
|
|
|
60 |
tvplayback = features.get("TV Playback")
|
|
|
61 |
tvplayback = int(tvplayback[0])
|
| 76 |
naveen |
62 |
|
|
|
63 |
if len(tvplayback) > 0 :
|
|
|
64 |
print "tvplayback=" + `tvplayback`
|
| 75 |
naveen |
65 |
|
| 76 |
naveen |
66 |
if tvplayback < 2 :
|
|
|
67 |
score = score + 0.5
|
|
|
68 |
|
|
|
69 |
elif tvplayback < 5 :
|
|
|
70 |
score = score + 1.0
|
|
|
71 |
|
|
|
72 |
elif tvplayback > 5 :
|
|
|
73 |
score = score + 1.5
|
|
|
74 |
|
| 75 |
naveen |
75 |
if capacity.has_key("childrenslides") :
|
|
|
76 |
childrenslides = capacity.get("childrenslides")
|
|
|
77 |
|
|
|
78 |
if childrenslides.has_key("Talk time") :
|
|
|
79 |
talktime = childrenslides.get("Talk time")
|
|
|
80 |
|
|
|
81 |
if talktime.has_key("features") :
|
|
|
82 |
features = talktime.get("features")
|
|
|
83 |
|
|
|
84 |
# Capacity > Talk time > 2G : <5 - 0.5, <10 - 1, >10 - 1.5
|
|
|
85 |
if features.has_key("2G") :
|
|
|
86 |
twog = features.get("2G")
|
| 76 |
naveen |
87 |
if len(twog) > 0 :
|
|
|
88 |
twog = twog[0]
|
|
|
89 |
twog = twog.split(" ")
|
|
|
90 |
twog = int(twog[0])
|
|
|
91 |
print "twog=" + `twog`
|
| 75 |
naveen |
92 |
|
| 76 |
naveen |
93 |
if twog < 5 :
|
|
|
94 |
score = score + 0.5
|
|
|
95 |
|
|
|
96 |
elif twog < 10 :
|
|
|
97 |
score = score + 1.0
|
|
|
98 |
|
|
|
99 |
elif twog > 10 :
|
|
|
100 |
score = score + 1.5
|
|
|
101 |
|
| 75 |
naveen |
102 |
# Capacity > Talk time > 3G : <5 - 0.5, <10 - 1, >10 - 1.5
|
|
|
103 |
if features.has_key("3G") :
|
|
|
104 |
threeg = features.get("3G")
|
|
|
105 |
|
| 76 |
naveen |
106 |
if len(threeg) > 0 :
|
|
|
107 |
threeg = threeg[0]
|
|
|
108 |
threeg = threeg.split(" ")
|
|
|
109 |
threeg = int(threeg[0])
|
|
|
110 |
print "threeg=" + `threeg`
|
|
|
111 |
|
|
|
112 |
if threeg < 5 :
|
|
|
113 |
score = score + 0.5
|
|
|
114 |
|
|
|
115 |
elif threeg < 10 :
|
|
|
116 |
score = score + 1.0
|
|
|
117 |
|
|
|
118 |
elif threeg > 10 :
|
|
|
119 |
score = score + 1.5
|
|
|
120 |
|
| 75 |
naveen |
121 |
if childrenslides.has_key("Standby time") :
|
|
|
122 |
standbytime = childrenslides.get("Standby time")
|
|
|
123 |
|
|
|
124 |
if standbytime.has_key("features") :
|
|
|
125 |
features = standbytime.get("features")
|
|
|
126 |
|
|
|
127 |
# Capacity > Standby time > 2G : <10 - 0.5, <20 - 1, >20 - 1.5
|
|
|
128 |
if features.has_key("2G") :
|
|
|
129 |
twog = features.get("2G")
|
|
|
130 |
|
| 76 |
naveen |
131 |
if len(twog) > 0 :
|
|
|
132 |
twog = twog[0]
|
|
|
133 |
twog = twog.split(" ")
|
|
|
134 |
twog = int(twog[0])
|
|
|
135 |
print "twog=" + `twog`
|
|
|
136 |
|
|
|
137 |
if twog < 10 :
|
|
|
138 |
score = score + 0.5
|
| 75 |
naveen |
139 |
|
| 76 |
naveen |
140 |
elif twog < 20 :
|
|
|
141 |
score = score + 1.0
|
|
|
142 |
|
|
|
143 |
elif twog > 20 :
|
|
|
144 |
score = score + 1.5
|
|
|
145 |
|
| 75 |
naveen |
146 |
# Capacity > Standby time > 3G : <10 - 0.5, <20 - 1, >20 - 1.5
|
|
|
147 |
if features.has_key("3G") :
|
|
|
148 |
threeg = features.get("3G")
|
|
|
149 |
|
| 76 |
naveen |
150 |
if len(threeg) > 0 :
|
|
|
151 |
threeg = threeg[0]
|
|
|
152 |
threeg = threeg.split(" ")
|
|
|
153 |
threeg = int(threeg[0])
|
|
|
154 |
print "threeg=" + `threeg`
|
|
|
155 |
|
|
|
156 |
if threeg < 10 :
|
|
|
157 |
score = score + 0.5
|
|
|
158 |
|
|
|
159 |
elif threeg < 20 :
|
|
|
160 |
score = score + 1.5
|
|
|
161 |
|
|
|
162 |
elif threeg > 20 :
|
|
|
163 |
score = score + 1.5
|
|
|
164 |
|
|
|
165 |
return int(math.floor(score))
|