def player_stats(self):
        total_points = 0.00
        games = 0.00
        won_count = 0
        for result in self.player.result_player.filter(player=self.player, ladder=self.ladder):

            if result.result == 9:
                total_points += (result.result + 2 + 1)  # two for winning one for playing
                won_count += 1
            else:
                total_points += (result.result + 1)  # one for playing

            games += 1

        # work out points per match
        if games > 0:
            pointsdivgames = total_points / games
            percplayed = games / (self.ladder.league_set.count() - 1) * 100
        else:
            percplayed = pointsdivgames = 0

        return {
            'total_points': total_points,
            'games': games,
            'pointsdivgames': pointsdivgames,
            'won_count': won_count,
            'percplayed': percplayed
        }
Simple function to return if a host is Windows or not
dataset/ETHPy150Open jzahedieh/django-tennis-ladder/ladder/models.py/League.player_stats--crossover with--dataset/ETHPy150Open saltstack/salt/salt/utils/__init__.py/is_windows