Mercurial > hg > horiscopes
diff V3/compatibility.py @ 12:18e337b2550d
timesheet and notes from meeting
author | DaveM |
---|---|
date | Thu, 01 Feb 2018 17:32:49 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/V3/compatibility.py Thu Feb 01 17:32:49 2018 +0000 @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import csv + + +def readFile(filename): + text = [] + with open(filename) as fp: + line = fp.readline() + text.append(line.strip()) + while line: + line = fp.readline() + text.append(line.strip()) + return text + +def parseCompatDef(filename): + comList = readFile(filename) + compat = {} + for com in comList: + c = com.split(',') + # print c + if len(c) == 4: + if len(c[1]) > 1: + for subset in c[1].split(' '): + key = sorted((c[0],c[2])) + key.append(subset) + compat[tuple(key)] = c[3] + elif len(c[1]) == 0 : + key = (c[0],c[2]) + compat[key] = c[3] + return compat + # pdb.set_trace() + +def applyCompatScore(people,rules): + # ruleKeys = rules.keys() + for person in people: + print "newPerson: " + str(person['ID']) + person['score'] = 0 + for pRule in person.keys(): + if pRule in rules: + person['score'] += int(rules[pRule]) + print pRule, rules[pRule] + print person['score'] +