def getCrimeScore(): ''' Returns the calculated CrimeScore.''' ratingsHash = getRatingsHashFromForm() cs = CrimeScore(ratingsHash) score = cs.calculateCrimeScore() commentary = cs.getScoreCommentary() if ratingsHash.keys == ["ERROR"] or len(ratingsHash) == 0: # If there's an error or the user hasn't filled in ratings yet, # there's no CrimeScore to return! return "" else: #so, if the hash table is populated return score
def getCrimeScoreCommentary(): '''Returns the CrimeScore's associated commentary.''' ratingsHash = getRatingsHashFromForm() cs = CrimeScore(ratingsHash) return cs.getScoreCommentary()