Subversion Repositories SmartDukaan

Rev

Rev 6273 | Rev 8083 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

def getscore(struct):

    score = 0.0
    java_score = 6.0
    security_score = 4.0
    os_score = 0.0
    
    if struct.has_key("features") :
        features = struct.get("features")
        
        # GPS Type : Integrated GPS-4, Bluetooth GPS-2
        if features.has_key("Java") :
           java_score = 10

        if features.has_key("Security") :
            if features.get("Security") > 5 :
                security_score = 10
            else:
                security_score = 2*features.get("Security") 

        if features.has_key("OS") :
           os = features.get("OS")
           os = os[0]
           if os.find("Proprietary") > -1 :
               os_score = 4
           elif os.find("Android") > -1 :
               if os.find("1.5") > -1 :
                   os_score = 6
               if os.find("1.6") > -1 :
                   os_score = 6.5
               if os.find("2.1") > -1 :
                   os_score = 7
               if os.find("2.2") > -1 :
                   os_score = 7.5
               if os.find("2.3") > -1 :
                   os_score = 8
               if os.find("3.0") > -1 :
                   os_score = 9
               if os.find("3.1") > -1 :
                   os_score = 9
               if os.find("3.2") > -1 :
                   os_score = 9
               if os.find("4.0") > -1 :
                   os_score = 9.5
               if os.find("4.1") > -1 :
                   os_score = 10
               if os.find("4.2") > -1 :
                   os_score = 10
            
           elif os.find("BlackBerry") > -1 :
               if os.find("OS") > -1 :
                   os_score = 6.5
               if os.find("5.0") > -1 :
                   os_score = 7
               if os.find("6.0") > -1 :
                   os_score = 8
               if os.find("7.0") > -1 :
                   os_score = 8.5
               if os.find("7.1") > -1 :
                   os_score = 9
               if os.find("Tablet OS") > -1 :
                   os_score = 8
                   
           else :
               if os.find("Brew Mobile Platform") > -1 :
                   os_score = 6
           

               if os.find("Samsung") > -1 :
                   if os.find("bada") > -1 :
                       os_score = 5
                   if os.find("bada 1.2") > -1 :
                       os_score = 5
    
               if os.find("Windows Phone 7") > -1 :
                   os_score = 7.5
    
    
               if os.find("Windows Phone 7.5 Mango") > -1 :
                   os_score = 8.5

               if os.find("Windows Phone 8") > -1 :
                   os_score = 9.5

               if os.find("Windows Mobile 6.5") > -1 :
                   os_score = 5
                   
               if os.find("Maemo 5") > -1 :
                   os_score = 7
    
               if os.find("Symbian") > -1 :
                   if os.find("40") > -1 :
                       os_score = 4
                   if os.find("60") > -1 :
                       os_score = 6
                   if os.find("^3") > -1 :
                       os_score = 7.5
                   if os.find("Symbian Anna") > -1:
                       os_score = 8
                   if os.find("Symbian Belle") > -1:
                       os_score = 8.5
                
               if os.find("iOS") > -1 :
                   if os.find("4") > -1 :
                       os_score = 9
                   if os.find("5") > -1 :
                       os_score = 9.5
                   if os.find("6") > -1 :
                       os_score = 10
    
           if os_score == 0:
               os_score = 3
           print "Scores" + str(os_score)
        score = (20*java_score + 20*security_score + 60*os_score)/100
    return score