Subversion Repositories SmartDukaan

Rev

Rev 4043 | Blame | Compare with Previous | Last modification | View Log | RSS feed

import utils

def getscore(struct):
    
    score = 0.0
    wireless_score = 0.0
    ethernet_score = 0.0
    bluetooth_score = 0.0
    
    if struct.has_key('features'):
        features = struct.get('features')
        
        if features.has_key("Wireless LAN"):
            wireless = str(features.get('Wireless LAN')[0])
            wireless_score = 10.0 if wireless.find('b/g/n') > -1 else 8.0
            
        if features.has_key('Ethernet LAN'):
            ethernet = str(features.get('Ethernet LAN')[0])
            
            if ethernet.find('1 Gbps') > -1:
                ethernet_score = 10.0
            elif ethernet.find('100 Mbps') > -1:
                ethernet_score = 7.0
            else:
                ethernet_score = 4.0
        if features.has_key('Bluetooth'):
            if len(features.get('Bluetooth')) > 0:
                bluetooth = str(features.get('Bluetooth')[0])
                bluetooth_score = 10.0 if bluetooth.find('3.0') else 7.0
            else:
                bluetooth_score = 7.0
        
    score = (55.0 * wireless_score + 35.0 * ethernet_score + 10.0 * bluetooth_score) / 100
    return score
    

print "expSlide=" + `expSlide`

struct = utils.contentModel2Struct(expSlide, categoryObj)
print "struct=" + `struct`

score = getscore(struct)