How to use the fpl.utils.position_converter function in fpl

To help you get started, we’ve selected a few fpl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amosbastian / fpl / tests / test_utils.py View on Github external
def test_position_converter():
        positions = ["Goalkeeper", "Defender", "Midfielder", "Forward"]
        converted = [position_converter(position) for position in range(1, 5)]
        assert positions == converted
github amosbastian / fpl / fpl / cli.py View on Github external
def get_starters(players, position):
    """Helper function that returns starting players in a given position."""
    starters = [player for player in players if position_converter(
        player.element_type) == position]
    return starters
github amosbastian / fpl / fpl / fpl.py View on Github external
"forward": {
                "H": [1, ..., 2],
                "A": [6, ..., 1]
                }
            },
            ...
          }

        :rtype: dict
        """
        players = await self.get_players(
            include_summary=True, return_json=True)
        points_against = {}

        for player in players:
            position = position_converter(player["element_type"]).lower()

            for fixture in player["history"]:
                if fixture["minutes"] == 0:
                    continue

                points = fixture["total_points"]
                opponent = team_converter(fixture["opponent_team"])
                location = "H" if fixture["was_home"] else "A"

                points_against.setdefault(
                    opponent,
                    {
                        "all": {"H": [], "A": []},
                        "goalkeeper": {"H": [], "A": []},
                        "defender": {"H": [], "A": []},
                        "midfielder": {"H": [], "A": []},