Subversion Repositories SmartDukaan

Rev

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

import utils

def getscore(struct):
    
    score = 0.0
    screen_size_score = 0.0
    resolution_score = 0.0
    
    if struct.has_key('childrenslides'):
        childslides = struct.get('childrenslides')
        
        if childslides.has_key('Display'):
            display_slide = childslides.get('Display')
            
            if display_slide.has_key('features'):
                features = display_slide.get('features')
                
                if features.has_key('Screen size'):
                    screen_size = float(features.get('Screen size')[0])
                    
                    if screen_size <= 10.0:
                        screen_size_score = 5.0
                    elif screen_size >= 15.0:
                        screen_size_score = 10.0
                    else:
                        screen_size_score = 5.0 + (screen_size - 10.0)
                    
                if features.has_key('Display resolution'):
                    resolution = features.get('Display resolution')
                    
                    if resolution == 'WVGA: 800x480':
                        resolution_score = 5.0
                    elif resolution == 'SVGA: 800x600':
                        resolution_score == 6.0
                    elif resolution == 'WSVGA:1024x600':
                        resolution_score == 7.0
                    elif resolution == 'XGA: 1024x768':
                        resolution_score = 7.5
                    elif resolution == 'WXGA: 1366x768':
                        resolution_score = 9.0
                    elif resolution == 'WQXGA: 2560x1600':
                        resolution_score = 10.0
                    else:
                        resolution_score = 10.0
                displayType_score = 0.0        
                if features.has_key('Display resolution'):
                    displayType = str(features.get('Display type')[0])
                    if displayType=='TFT LCD' or displayType =='LED':
                        displayType_score = 7.0 
                    elif displayType =='HD LED':
                        displayType_score = 8.0
                    elif displayType =='WLED':
                        displayType_score = 8.5
                    elif displayType =='OLED':
                        displayType_score = 9.0
                    elif displayType =='HD WLED':
                        displayType_score = 10.0
                    elif displayType == 'Retina Display':
                        displayType_score = 10.0
                        

        #TODO: Acquire list of GPUs and Display Types
        
        score = (40.0 * screen_size_score + 20.0 * resolution_score + 40.0*displayType_score) / 100.0
    return score


print "expSlide=" + `expSlide`

struct = utils.contentModel2Struct(expSlide, categoryObj)
print "struct=" + `struct`

score = getscore(struct)