How to use the fpl.constants.MYTEAM_FORMAT 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 / fpl / cli.py View on Github external
def team_width(positions, points=False):
    """Returns the maximum string width of a team."""
    width = 0

    for position in positions:
        if points:
            player_names = [PICKS_FORMAT.format(
                player.web_name, player.event_points,
                player.role) for player in position]
        else:
            player_names = [MYTEAM_FORMAT.format(
                player.web_name, player.role) for player in position]

        position_width = len(" - ".join(player_names))

        if position_width > width:
            width = position_width

    return width
github amosbastian / fpl / fpl / cli.py View on Github external
async def format_myteam(user):
    """Formats a user's team and echoes it to the terminal."""
    team = await user.get_team()
    players = sorted(await get_picks(team), key=lambda x: x.team_position)

    goalkeeper, defenders, midfielders, forwards, bench = split_by_position(
        players)

    team_printer([goalkeeper, defenders, midfielders, forwards], MYTEAM_FORMAT)

    click.echo("\nSubstitutes: {}".format(", ".join(
        [click.style("{}".format(player.web_name), fg=player.colour)
         for player in bench])))

    await myteam_table(user)