Mercurial > hg > horiscopes
view V3/compatibility.py @ 19:ae220e89cb3a
fixing parse bugs, and angle calculation bugs
author | DaveM |
---|---|
date | Tue, 06 Mar 2018 17:25:38 +0000 |
parents | 18e337b2550d |
children |
line wrap: on
line source
#!/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']