Rev 8045 | Blame | Compare with Previous | Last modification | View Log | RSS feed
def getscore(struct):score = 0.0file_formats_score = 0.0streaming_score = 0.0recording_score = 0.0hd_video_playback = 0.0category = struct.get("category")features = struct.get("features")if features.has_key("File formats") :file_formats = features.get("File formats")number_of_file_formats = len(file_formats)if number_of_file_formats == 1 :file_formats_score = 4.0elif number_of_file_formats >= 4 :file_formats_score = 10.0else :file_formats_score = 3*number_of_file_formatsif features.has_key("Streaming") :streaming_score = 10.0if category == "Tablets" :if features.has_key("HD video playback") :hd_video_playback = 10.0else :if features.has_key("Video recording") :recording = features.get("Video recording")if len(recording) > 0:print "recording :" + `recording`recording = recording[0]if recording == "Yes":recording_score = 4.0elif recording == "720p HD video recording":recording_score = 7.0elif recording == "1080p Full HD video recording":recording_score = 10.0if features.has_key("HD Video playback") :hd_video_playback = 10.0if category == "Tablets" :score = (50*file_formats_score + 25*streaming_score + 25*hd_video_playback)/100else :score = (40*file_formats_score + 30*recording_score + 30*hd_video_playback)/100print "file_formats_score" + `file_formats_score`print "hd_video_playback" + `hd_video_playback`print "recording_score" + `recording_score`return score