Subversion Repositories SmartDukaan

Rev

Rev 4036 | Go to most recent revision | 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
41
                    else:
42
                        resolution_score = 10.0
5173 amit.gupta 43
                displayType_score = 0.0        
44
                if features.has_key('Display resolution'):
45
                    displayType = str(features.get('Display type')[0])
46
                    if displayType=='TFT LCD' or displayType =='LED':
47
                        displayType_score = 7.0 
48
                    elif displayType =='HD LED':
49
                        displayType_score = 8.0
50
                    elif displayType =='WLED':
51
                        displayType_score = 8.5
52
                    elif displayType =='OLED':
53
                        displayType_score = 9.0
54
                    elif displayType =='HD WLED':
55
                        displayType_score = 10.0
4036 varun.gupt 56
 
57
        #TODO: Acquire list of GPUs and Display Types
5173 amit.gupta 58
 
59
        score = (40.0 * screen_size_score + 20.0 * resolution_score + 40.0*displayType_score) / 100.0
4036 varun.gupt 60
    return score
61
 
62
 
63
print "expSlide=" + `expSlide`
64
 
65
struct = utils.contentModel2Struct(expSlide, categoryObj)
66
print "struct=" + `struct`
67
 
68
score = getscore(struct)