How to use the fpl.constants.PICKS_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_picks(user):
    """Formats a user's picks and echoes it to the terminal."""
    user_picks = await user.get_picks()
    user_information = user_picks[len(user_picks)]
    players = sorted(await get_picks(user_information["picks"]),
                     key=lambda x: x.team_position)

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

    team_printer([goalkeeper, defenders, midfielders, forwards],
                 PICKS_FORMAT, True)

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

    picks_table(user, user_information, players)