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):
78 naveen 4
 
5
    score = 0.0
6
 
7
    if struct.has_key("features") :
8
        features = struct.get("features")
9
 
10
        # Built-in : <=50-0.5, <=100-1, <=250-1.5, >250-2
11
        if features.has_key("Built-in") :
12
            builtin = features.get("Built-in")
13
 
14
            if len(builtin) > 0 :
15
                builtin = int(builtin[0])
16
                print "builtin=" + `builtin`
17
 
18
                if builtin <=50 :
19
                    score += 0.5
20
 
21
                elif builtin <=100 :
22
                    score += 1
23
 
24
                elif builtin <=250 :
25
                    score += 1.5
26
 
27
                elif builtin > 250 :
28
                    score += 2
29
 
30
        # RAM : <=128-2, <=256-4, >256-6
31
        if features.has_key("RAM") :
32
            ram = features.get("RAM")
33
 
34
            if len(ram) > 0 :
35
                ram = int(ram[0])
36
                print "ram=" + `ram`
37
 
38
                if ram <= 128 :
39
                    score += 1
40
 
41
                elif builtin <= 256 :
42
                    score += 2
43
 
44
                elif builtin > 256 :
45
                    score += 3
46
 
47
        # REVISIT
48
        # Expansion Type : microSD-2, others-1
49
 
50
        # Expansion Capacity : 2, 4, 8, 16, 32
51
        if features.has_key("Expansion Capacity") :
52
            ec = features.get("Expansion Capacity")
53
 
54
            if len(ec) > 0 :
55
                ec = int(ec[0])
56
                print "ec=" + `ec`
57
 
58
                if ec <= 2 :
59
                    score += 0.5
60
 
61
                elif ec <= 4 :
62
                    score += 1
63
 
64
                elif ec <= 8 :
65
                    score += 1.5
66
 
67
                elif ec > 16 :
68
                    score += 2
69
 
70
    return int(math.floor(score))