Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
78 naveen 1
import math
2
 
71 naveen 3
def getscore(struct):
77 naveen 4
 
78 naveen 5
    score = 0.0
77 naveen 6
 
78 naveen 7
    if struct.has_key("features") :
8
        features = struct.get("features")
9
 
10
        # Screen Size : <=2 - 1, <=2.5 - 2, > 2.5 - 3
11
        if features.has_key("Screen Size") :
12
            ss = features.get("Screen Size")
13
 
14
            if len(ss) > 0 :
15
                ss = ss[0]
16
                ss = float(ss)
17
                print "ss=" + `ss`
18
 
19
                if  ss <= 2 :
20
                    score += 1
21
 
22
                elif  ss <= 2.5 :
23
                    score += 2
24
 
25
                elif  ss > 2.5 :
26
                    score += 3
27
 
28
        # Resolution : 320x240 px - 1, 480x360 px - 2
29
        if features.has_key("Resolution") :
30
            res = features.get("Resolution")
31
 
32
            if len(res) > 1 :
33
                width = int(res[0])
34
                height = int(res[1])
35
                print "width=" + `width`
36
                print "height=" + `height`
37
 
38
                if  width <= 320 :
39
                    score += 1
40
 
41
                elif  width > 320 :
42
                    score += 2
43
 
44
        # Number of Colors : 64 K - 0.5, 256 K - 1, 16 M - 1.5, 4 B - 2
45
        if features.has_key("Number of Colors") :
46
            nfcs = features.get("Number of Colors")
47
 
48
            if len(nfcs) > 0 :
49
                nfcs = nfcs[0]
50
 
51
            if nfcs == "64 K" :
52
                score += 0.5
53
 
54
            elif nfcs == "256 K" :
55
                score += 1
56
 
57
            elif nfcs == "16 M" :
58
                score += 1.5
59
 
60
            elif nfcs == "4 B" :
61
                score += 2
62
 
63
        # REVISIT
64
        # Type : TFT - 1, Others - 0.5
65
        if features.has_key("Type") :
66
            type = features.get("Type")
67
 
68
            if len(type) > 0 :
69
                type = type[0]
70
 
71
            if type == "TFT" :
72
                score += 1
73
 
74
            else :
75
                score += 0.5
77 naveen 76
 
78 naveen 77
    return int(math.floor(score))