Rev 75 | Blame | Last modification | View Log | RSS feed
import mathdef getscore(struct):score = 0.0if struct.has_key("features") :# REVISIT - Nokia power adaptor should get more points# Power Adaptor# REVISIT - Certain battery types need to be than others# Battery Typepass# Max will be 1.5 * 7 = ceil(10.5) = 10if struct.has_key("childrenslides") :childrenslides = struct.get("childrenslides")if childrenslides.has_key("Capacity") :capacity = childrenslides.get("Capacity")if capacity.has_key("features") :features = capacity.get("features")# Capacity > Music Playback : <20 - 0.5, <35 - 1, >35 - 1.5if features.has_key("Music Playback") :musicplayback = features.get("Music Playback")if len(musicplayback) > 0 :musicplayback = int(musicplayback[0])print "musicplayback=" + `musicplayback`if musicplayback < 20 :score = score + 0.5elif musicplayback < 35 :score = score + 1.0elif musicplayback > 35 :score = score + 1.5# Capacity > Video Playback : <2 - 0.5, <5 - 1, >5 - 1.5if features.has_key("Video Playback") :videoplayback = features.get("Video Playback")if len(videoplayback) > 0 :videoplayback = int(videoplayback[0])print "videoplayback=" + `videoplayback`if videoplayback < 2 :score = score + 0.5elif videoplayback < 5 :score = score + 1.0elif videoplayback > 5 :score = score + 1.5# Capacity > TV Playback : <2 - 0.5, <5 - 1, >5 - 1.5if features.has_key("TV Playback") :tvplayback = features.get("TV Playback")tvplayback = int(tvplayback[0])if len(tvplayback) > 0 :print "tvplayback=" + `tvplayback`if tvplayback < 2 :score = score + 0.5elif tvplayback < 5 :score = score + 1.0elif tvplayback > 5 :score = score + 1.5if capacity.has_key("childrenslides") :childrenslides = capacity.get("childrenslides")if childrenslides.has_key("Talk time") :talktime = childrenslides.get("Talk time")if talktime.has_key("features") :features = talktime.get("features")# Capacity > Talk time > 2G : <5 - 0.5, <10 - 1, >10 - 1.5if features.has_key("2G") :twog = features.get("2G")if len(twog) > 0 :twog = twog[0]twog = twog.split(" ")twog = int(twog[0])print "twog=" + `twog`if twog < 5 :score = score + 0.5elif twog < 10 :score = score + 1.0elif twog > 10 :score = score + 1.5# Capacity > Talk time > 3G : <5 - 0.5, <10 - 1, >10 - 1.5if features.has_key("3G") :threeg = features.get("3G")if len(threeg) > 0 :threeg = threeg[0]threeg = threeg.split(" ")threeg = int(threeg[0])print "threeg=" + `threeg`if threeg < 5 :score = score + 0.5elif threeg < 10 :score = score + 1.0elif threeg > 10 :score = score + 1.5if childrenslides.has_key("Standby time") :standbytime = childrenslides.get("Standby time")if standbytime.has_key("features") :features = standbytime.get("features")# Capacity > Standby time > 2G : <10 - 0.5, <20 - 1, >20 - 1.5if features.has_key("2G") :twog = features.get("2G")if len(twog) > 0 :twog = twog[0]twog = twog.split(" ")twog = int(twog[0])print "twog=" + `twog`if twog < 10 :score = score + 0.5elif twog < 20 :score = score + 1.0elif twog > 20 :score = score + 1.5# Capacity > Standby time > 3G : <10 - 0.5, <20 - 1, >20 - 1.5if features.has_key("3G") :threeg = features.get("3G")if len(threeg) > 0 :threeg = threeg[0]threeg = threeg.split(" ")threeg = int(threeg[0])print "threeg=" + `threeg`if threeg < 10 :score = score + 0.5elif threeg < 20 :score = score + 1.5elif threeg > 20 :score = score + 1.5return int(math.floor(score))