Subversion Repositories SmartDukaan

Rev

Rev 4043 | 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
    wireless_score = 0.0
7
    ethernet_score = 0.0
8
    bluetooth_score = 0.0
9
 
10
    if struct.has_key('features'):
11
        features = struct.get('features')
12
 
13
        if features.has_key("Wireless LAN"):
14
            wireless = str(features.get('Wireless LAN')[0])
15
            wireless_score = 10.0 if wireless.find('b/g/n') > -1 else 8.0
16
 
17
        if features.has_key('Ethernet LAN'):
18
            ethernet = str(features.get('Ethernet LAN')[0])
19
 
5173 amit.gupta 20
            if ethernet.find('1 Gbps') > -1:
4036 varun.gupt 21
                ethernet_score = 10.0
5173 amit.gupta 22
            elif ethernet.find('100 Mbps') > -1:
4036 varun.gupt 23
                ethernet_score = 7.0
24
            else:
25
                ethernet_score = 4.0
26
        if features.has_key('Bluetooth'):
4043 rajveer 27
            if len(features.get('Bluetooth')) > 0:
28
                bluetooth = str(features.get('Bluetooth')[0])
29
                bluetooth_score = 10.0 if bluetooth.find('3.0') else 7.0
30
            else:
31
                bluetooth_score = 7.0
4036 varun.gupt 32
 
4037 rajveer 33
    score = (55.0 * wireless_score + 35.0 * ethernet_score + 10.0 * bluetooth_score) / 100
4036 varun.gupt 34
    return score
35
 
36
 
37
print "expSlide=" + `expSlide`
38
 
39
struct = utils.contentModel2Struct(expSlide, categoryObj)
40
print "struct=" + `struct`
41
 
42
score = getscore(struct)