API
Faker provider for ILC data models.
When imported this module creates a faker.Faker instance
and calls fake.add_provider(ILCProvider).
You can then from ilc_models import fake and use the
providers as you would any other Faker provider e.g.:
from ilc_models import fake
player = fake.player()
match = fake.match()
league = fake.league()
// etc.
- class ilc_provider.ILCProvider(generator: Any)[source]
Faker provider for ILC data models
- base_player() BasePlayer[source]
Returns a randomly generated BasePlayer.
- Returns:
BasePlayer with random name and ID
- Return type:
- card(team: str | None = None, time: EventTime | None = None, players: list[BasePlayer] | None = None) Card[source]
Returns a randomly generated red or yellow card.
Any parameters not supplied will be randomly generated.
- Parameters:
team (str) – Name of the team receiving this card (default=None)
time (
ilc_models.EventTime) – Time of the card (default=None)players (list[BasePlayer]) – Players who can receive the card (default=None)
- Returns:
Randomly generated card event
- Return type:
- event_time(first_half_weighting=50) EventTime[source]
Returns a randomly generated event time.
The
first_half_weightingparameter controls how likely it is that the time will be in the first half. A value of 50 means either half will have equal probability; higher values increase the likelihood of a first half time.- Parameters:
first_half_weighting (int) – Weight / 100 to give to a time in the first half
- Returns:
Randomly generated event time
- Return type:
- goal(team: Team | None = None, time: EventTime | None = None, goal_type: Literal['N', 'O', 'P'] | None = None, players: tuple[list[BasePlayer], list[BasePlayer]] | None = None) Goal[source]
Returns a randomly generated goal.
Any parameters not supplied will be randomly generated.
- Parameters:
team (
Team) – Team scoring this goal (default=None)time (
ilc_models.EventTime) – Time of the goal (default=None)goal_type (str) – One of ‘N’ (normal goal), ‘O’ (own goal), ‘P’ (penalty) (default=None)
players (tuple[list[
ilc_models.BasePlayer], list[ilc_models.BasePlayer]]) – Players who can score the goal as a two-item tuple, the scoring team’s players are the first item and the opposing team’s players (for own goals) are the second item (default=None)
- Returns:
Randomly generated goal event
- Return type:
- kickoff(anchor: date | None = None) datetime[source]
Returns a randomly generated kickoff time.
If
anchoris provided the kickoff will be on that day at 15:00 or 17:30, the following day at 15:00, or at 19:45 on d-1. This simulates a gameweek being played across a Friday to Sunday, whereanchoris the Saturday.If
anchoris not provided the kickoff will be a random Saturday at 3pm.- Parameters:
anchor (
datetime.date) – Saturday to anchor this gameweek (default=None)- Returns:
Randomly generated kickoff date and time
- Return type:
- league(team_count: int = 0, matches: bool = True, games_per_opponent: int = 0, split_mode: Literal['auto', 'none', 'fixed'] = 'auto', games_before_split: int = 3) League[source]
Returns a randomly generated league.
If
matchesis False no matches will be added to the league.If
games_per_opponentis not provided it will default to 2 for leagues with more than 12 teams, or 4 otherwise.If
split_modeis not provided it will default to auto and a split will occur in leagues with 3 or more games per opponent.Any other parameters not supplied will be randomly generated.
- Parameters:
team_count (int) – Number of teams in this league (default=0)
matches (bool) – Whether matches should be added to this league (default=True)
games_per_opponent (int) – Number of games to play against each other team (including post-split games) (default=0)
split_mode (str) – One of ‘none’ (no split), ‘auto’ (auto-generated split point) or ‘fixed’ (use split point provided) (default=’auto’)
games_before_split (int) – Number of matches to play against each opponent before the league splits in ‘fixed’ split mode, ignored if split_mode is ‘none’ or ‘auto’ (default=3)
- Returns:
Randomly generated league
- Return type:
- league_id() int[source]
Returns a random league ID.
- Returns:
Random match ID between 1 and 999
- Return type:
- league_name() str[source]
Returns a randomly selected league name.
- Returns:
Random league name
- Return type:
- lineup(squad: list[SquadPlayer] | None = None) Lineup[source]
Returns a randomly generated Lineup.
Creates a lineup with 11 starting players and 7 substitutes.
If
squadis supplied the players will be chosen from the squad, otherwise a new set of players will be randomly generated.- Parameters:
squad (list[
SquadPlayer]) – Squad players to choose from (default=None)- Returns:
Lineup with randomly generated players
- Return type:
- lineups(home_squad: list[SquadPlayer] | None = None, away_squad: list[SquadPlayer] | None = None) Lineups[source]
Returns two randomly generated lineups.
If
home_squadoraway_squadis supplied the players will be chosen from the squads, otherwise new sets of players will be randomly generated.- Parameters:
home_squad (list[
SquadPlayer]) – Squad players for the home team (default=None)away_squad (list[
SquadPlayer]) – Squad players for the home team (default=None)
- Returns:
Lineups with randomly generated players
- Return type:
- match(kickoff: datetime | None = None, round: str | None = None, home: Team | None = None, away: Team | None = None, status: str | None = None) Match[source]
Returns a randomly generated match.
Takes a number of optional parameters which if supplied will be added to the match. Any parameters not supplied will be randomly generated.
- Parameters:
kickoff (
datetime.datetime) – Kickoff time (default=None)round (str) – Round this match is part of (default=None)
home (
Team) – Home team (default=None)away (
Team) – Away team (default=None)status (str) – Match status (default=None)
- Returns:
Randomly generated match
- Return type:
- match_id() int[source]
Returns a random match ID.
- Returns:
Random match ID between 1 and 999,999
- Return type:
- player(active_date: date | None = None) Player[source]
Returns a randomly generated Player.
If
active_dateis supplied the player’s DOB will be generated so that they are between 17 and 35 onactive_date, otherwise they will be between 17 and 35 on today’s date.- Parameters:
active_date (
datetime.date) – Date on which this player is active - this will be used to generate a reasonable date of birth (default=None)- Returns:
Player with randomly generated attributes
- Return type:
- player_id() int[source]
Returns a random player ID.
- Returns:
Random player ID between 1 and 999,999
- Return type:
- squad(size=25, keepers=3, active_date: date | None = None) list[SquadPlayer][source]
Returns a randomly generated list of SquadPlayers.
- Parameters:
size (int) – Number of players to generate (default=25)
keepers (int) – Number of goalkeepers to include (default=3)
active_date (
datetime.date) – Date on which all players in this squad are active - this will be used to generate reasonable dates of birth (default=None)
- Returns:
List of randomly generated squad players
- Return type:
list[
SquadPlayer]
- sub_window(team: str | None = None, sub_count: int = 0, time: EventTime | None = None, possible_exits: list[BasePlayer] | None = None, possible_entries: list[BasePlayer] | None = None) list[Substitution][source]
Returns a randomly generated list of substitutions made within a single window.
Any parameters not supplied will be randomly generated.
- Parameters:
team (str) – Name of the team making this substitution (default=None)
sub_count (str) – Number of substitutions to be made in this window (default=0)
time (
ilc_models.EventTime) – Time of the substitutions (default=None)possible_exits (list[
ilc_models.BasePlayer]) – Players who can come off the field (default=None)possible_entries (list[
ilc_models.BasePlayer]) – Players who can come on the field (default=None)
- Returns:
Randomly generated substitutions
- Return type:
list[
ilc_models.Substitution]
- substitution(team: str | None = None, time: EventTime | None = None, possible_exits: list[BasePlayer] | None = None, possible_entries: list[BasePlayer] | None = None) Substitution[source]
Returns a randomly generated substitution.
Any parameters not supplied will be randomly generated.
- Parameters:
team (str) – Name of the team making this substitution (default=None)
time (
EventTime) – Time of the substitution (default=None)possible_exits (list[
ilc_models.BasePlayer]) – Players who can come off the field (default=None)possible_entries (list[
ilc_models.BasePlayer]) – Players who can come on the field (default=None)
- Returns:
Randomly generated substitution
- Return type:
- table_row(matches: int = 0, team: Team | None = None) TableRow[source]
Returns a randomly generated league table row.
Any parameters not supplied will be randomly generated.
- Parameters:
- Returns:
Randomly generated row from a league table
- Return type:
- team(active_date: date | None = None) Team[source]
Returns a randomly generated team.
- Parameters:
active_date (
datetime.date) – Date on which all players in this team’s squad are active - this will be used to generate reasonable dates of birth (default=None)- Returns:
Randomly generated team, populated with a squad of players
- Return type:
- class ilc_provider.SquadPlayer(shirt_number: int, keeper=False, active_date: date | None = None)[source]
Member of a squad.
On initialization the object will be populated with a randomly generated
Playerand will be allocated two weighting attributes:selection_weight: How likely this player is to be selected (1-100)scorer_weight: How likely this player is to score a goal (1-100)
- Parameters:
shirt_number (int) – Player’s squad number
keeper (bool) – True if this player is a goalkeeper (default=False)
active_date (
datetime.date) – Date on which this player is active - this will be used to generate a reasonable date of birth (default=None)
- property base_player: BasePlayer
Return a BasePlayer object corresponding to this SquadPlayer.
- Returns:
The BasePlayer corresponding to this SquadPlayer
- Return type:
- class ilc_provider.Team(active_date: date | None = None)[source]
Randomly generated team.
- Parameters:
active_date (
datetime.date) – Date on which all players in this team’s squad are active - this will be used to generate reasonable dates of birth (default=None)
- ilc_provider.invert_schedule(schedule: list[list[tuple[Team, Team]]]) list[list[tuple[Team, Team]]][source]
Invert all fixtures in the schedule so home becomes away and vice versa.
Also shuffles the match days so they reoccur in a randomized order.
- ilc_provider.match_schedule(teams: list[Team]) list[list[tuple[Team, Team]]][source]
Develop a match schedule with each team playing all others once.
Returns a list of matchdays, each containing a list of fixtures in the form of (home, away) tuples.
- ilc_provider.players_on(team: str, starting: list[BasePlayer], events: list[Event], time: EventTime) list[BasePlayer][source]
Returns the list of players on the pitch at a given time.
- Parameters:
team (str) – Team name
starting (list[
ilc_models.BasePlayer]) – Starting XIevents (list[
ilc_models.Event]) – Match eventstime (
ilc_models.EventTime) – Time to check