Created
April 17, 2013 16:22
-
-
Save cwmanning/5405644 to your computer and use it in GitHub Desktop.
Scores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _scores(self, scores): | |
if not hasattr(scores, 'team_game_stats') or not hasattr(scores.team_game_stats, 'sub_score'): | |
return [] | |
widget_scores = [] | |
for score in scores.team_game_stats.sub_score: | |
try: | |
widget_scores.append(score.period_score) | |
except AttributeError: | |
widget_scores.append(0) | |
label = self.caption.get(self.league_key, self.caption['default']) | |
normal = label['period_count'] | |
if len(widget_scores) > normal: # combine multiple OT scores | |
widget_scores[normal] = sum([ int(n) for n in widget_scores[normal:] ]) | |
del widget_scores[normal+1:] | |
return widget_scores |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment