Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_team_converter(self, loop, fpl):
teams = await fpl.get_teams()
for team in teams:
assert team_converter(team.id) == team.name
def get_player_table(players, risers=True):
"""Returns the table used in the player price change posts on Reddit."""
table_header = ("|Name|Team|Position|Ownership|Price|∆|Form|\n"
"|:-|:-|:-|:-:|:-:|:-:|:-:|\n")
table_body = "\n".join([
f"|{player.web_name}|"
f"{team_converter(player.team)}|"
f"{position_converter(player.element_type)}|"
f"{player.selected_by_percent}%|"
f"£{player.now_cost / 10.0:.1f}|"
f"{'+' if risers else '-'}£{abs(player.cost_change_event / 10.0):.1f}|"
f"{sum([fixture['total_points'] for fixture in player.history[-5:]])}|"
for player in players])
return table_header + table_body
def __str__(self):
return (f"{self.web_name} - "
f"{position_converter(self.element_type)} - "
: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": []},
"forward": {"H": [], "A": []}
}
)
points_against[opponent]["all"][location].append(points)
points_against[opponent][position][location].append(points)
def __str__(self):
return (f"{team_converter(self.team_h)} vs. "
f"{team_converter(self.team_a)} - "