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
 
5173 amit.gupta 5
    score = 5.0
6
    #For now keep it simple
7
    #default value should be 5 
4036 varun.gupt 8
    if struct.has_key('features'):
9
        features = struct.get('features')
10
 
5173 amit.gupta 11
        capacity_score = 5.0
12
        if features.has_key('Maximum run time'):
13
            capacity = features.get('Maximum run time')[0] #TODO
14
            hours = [int(s) for s in capacity.encode().split() if s.isdigit()][0]
15
            if hours <= 2:
16
                capacity_score = 3.0
17
            elif hours > 2 and hours < 8:
18
                capacity_score = 3.0 + hours*(3.0/6.0)
19
            else :
20
                capacity_score = 10.0
21
        eff_score = 3.0
4036 varun.gupt 22
        if features.has_key('Energy efficiency'):
5173 amit.gupta 23
            energy_efficiency = features.get('Energy efficiency')[0].encode()
24
            if(energy_efficiency.find('Energy Star')>-1):
25
                eff_score = 10.0
26
            elif(energy_efficiency.find('EPEAT Gold')>-1):
27
                eff_score = 10.0
28
            elif(energy_efficiency.find('EPEAT Silver')>-1):
29
                eff_score = 7.0
30
            elif(energy_efficiency.find('EPEAT Bronze')>-1):
31
                eff_score = 4.0
4036 varun.gupt 32
 
5173 amit.gupta 33
        score = 0.7*capacity_score + 0.3*eff_score
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)