Subversion Repositories SmartDukaan

Rev

Rev 8045 | Blame | Compare with Previous | Last modification | View Log | RSS feed

def getscore(struct):
    
    score = 0.0
    file_formats_score = 0.0
    streaming_score = 0.0
    recording_score = 0.0
    hd_video_playback = 0.0
    
    category = 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.0
        elif number_of_file_formats >= 4 :
            file_formats_score = 10.0
        else :
            file_formats_score = 3*number_of_file_formats

    if features.has_key("Streaming") :
        streaming_score = 10.0

    if category == "Tablets" :
        if features.has_key("HD video playback") :
           hd_video_playback = 10.0
    else :
        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.0
                elif recording == "720p HD video recording":
                    recording_score = 7.0
                elif recording == "1080p Full HD video recording":
                    recording_score = 10.0
                    
        if features.has_key("HD Video playback") :
            hd_video_playback = 10.0
                
    if category == "Tablets" :
        score = (50*file_formats_score + 25*streaming_score + 25*hd_video_playback)/100
    else : 
        score = (40*file_formats_score + 30*recording_score + 30*hd_video_playback)/100
        
    
    print "file_formats_score" + `file_formats_score`
    print "hd_video_playback" + `hd_video_playback`
    print "recording_score" + `recording_score`
    
    return score