def goals_for(game_id, player=None, goal_name=None): """Return the list of goals for the passed game id""" test_game = game.Game(parse_game.parse_game( \ codecs.open('testing/testdata/'+game_id, encoding='utf-8').read())) found_goals = goals.check_goals(test_game) if player: found_goals = [g for g in found_goals if g['player'] == player] if goal_name: found_goals = [g for g in found_goals if g['goal_name'] == goal_name] return found_goals
def get_goals(game): glist = goals.check_goals(game) if len(glist)==0: goal_contents = None else: goal_contents = '<table cellpadding="7">' for goal in glist: goal_name = goal['goal_name'] player = goal['player'] reason = goal['reason'] reason = str.lower(reason[0:1]) + reason[1:] goal_contents += '<tr><td><img src="%s" alt="%s"><td><strong>%s</strong><br>%s %s</tr>' % (goals.GetGoalImageFilename(goal_name), goal_name, goal_name, player, reason) goal_contents += '</table>' return "<tr><td>goals</td><td>%s</td></tr>"%goal_contents