Skip to content

Instantly share code, notes, and snippets.

@cwmanning
Created April 17, 2013 16:22
Show Gist options
  • Save cwmanning/5405644 to your computer and use it in GitHub Desktop.
Save cwmanning/5405644 to your computer and use it in GitHub Desktop.
Scores
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