def _json_game_player_stats(game, data):
 players = OrderedDict()
 for team in ('home', 'away'):
  for category in nflgame.statmap.categories:
   if (category not in data[team]['stats']):
    continue
   for (pid, raw) in data[team]['stats'][category].iteritems():
    stats = {}
    for (k, v) in raw.iteritems():
     if (k == 'name'):
      continue
     stats[('%s_%s' % (category, k))] = v
    if (pid not in players):
     home = (team == 'home')
     if home:
      team_name = game.home
     else:
      team_name = game.away
     players[pid] = nflgame.player.GamePlayerStats(pid, raw['name'], home, team_name)
    players[pid]._add_stats(stats)
 return players

def _json_game_player_stats ( game , data ) : players = OrderedDict ( ) for team in ( 'home' , 'away' ) : for category in nflgame . statmap . categories : if ( category not in data [ team ] [ 'stats' ] ) : continue for ( pid , raw ) in data [ team ] [ 'stats' ] [ category ] . iteritems ( ) : stats = { } for ( k , v ) in raw . iteritems ( ) : if ( k == 'name' ) : continue stats [ ( '%s_%s' % ( category , k ) ) ] = v if ( pid not in players ) : home = ( team == 'home' ) if home : team_name = game . home else : team_name = game . away players [ pid ] = nflgame . player . GamePlayerStats ( pid , raw [ 'name' ] , home , team_name ) players [ pid ] . _add_stats ( stats ) return players
parses the home and away team stats and returns an ordereddict mapping player id to their total game statistics as instances of nflgame .