Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
4036 varun.gupt 1
import utils
2
 
3
def getscore(struct):
4
 
5
    score = 0.0
6
    screen_size_score = 0.0
7
    resolution_score = 0.0
8
 
9
    if struct.has_key('childrenslides'):
10
        childslides = struct.get('childrenslides')
11
 
12
        if childslides.has_key('Display'):
13
            display_slide = childslides.get('Display')
14
 
15
            if display_slide.has_key('features'):
16
                features = display_slide.get('features')
17
 
18
                if features.has_key('Screen size'):
19
                    screen_size = float(features.get('Screen size')[0])
20
 
21
                    if screen_size <= 10.0:
22
                        screen_size_score = 5.0
23
                    elif screen_size >= 15.0:
24
                        screen_size_score = 10.0
25
                    else:
26
                        screen_size_score = 5.0 + (screen_size - 10.0)
27
 
28
                if features.has_key('Display resolution'):
29
                    resolution = features.get('Display resolution')
30
 
31
                    if resolution == 'WVGA: 800x480':
32
                        resolution_score = 5.0
33
                    elif resolution == 'SVGA: 800x600':
34
                        resolution_score == 6.0
35
                    elif resolution == 'WSVGA:1024x600':
36
                        resolution_score == 7.0
37
                    elif resolution == 'XGA: 1024x768':
38
                        resolution_score = 7.5
39
                    elif resolution == 'WXGA: 1366x768':
40
                        resolution_score = 9.0
6582 amit.gupta 41
                    elif resolution == 'WQXGA: 2560x1600':
42
                        resolution_score = 10.0
4036 varun.gupt 43
                    else:
44
                        resolution_score = 10.0
5173 amit.gupta 45
                displayType_score = 0.0        
46
                if features.has_key('Display resolution'):
47
                    displayType = str(features.get('Display type')[0])
48
                    if displayType=='TFT LCD' or displayType =='LED':
49
                        displayType_score = 7.0 
50
                    elif displayType =='HD LED':
51
                        displayType_score = 8.0
52
                    elif displayType =='WLED':
53
                        displayType_score = 8.5
54
                    elif displayType =='OLED':
55
                        displayType_score = 9.0
56
                    elif displayType =='HD WLED':
57
                        displayType_score = 10.0
6582 amit.gupta 58
                    elif displayType == 'Retina Display':
59
                        displayType_score = 10.0
60
 
4036 varun.gupt 61
 
62
        #TODO: Acquire list of GPUs and Display Types
5173 amit.gupta 63
 
64
        score = (40.0 * screen_size_score + 20.0 * resolution_score + 40.0*displayType_score) / 100.0
4036 varun.gupt 65
    return score
66
 
67
 
68
print "expSlide=" + `expSlide`
69
 
70
struct = utils.contentModel2Struct(expSlide, categoryObj)
71
print "struct=" + `struct`
72
 
73
score = getscore(struct)