2022-06-06 02:58:53 +02:00
|
|
|
""" Race class """
|
|
|
|
|
2022-06-01 15:31:52 +02:00
|
|
|
import datetime
|
2022-06-06 02:58:53 +02:00
|
|
|
from dataclasses import dataclass
|
2022-06-01 15:31:52 +02:00
|
|
|
|
|
|
|
from ergast_py.models.circuit import Circuit
|
|
|
|
from ergast_py.models.lap import Lap
|
|
|
|
from ergast_py.models.pit_stop import PitStop
|
2022-06-06 02:58:53 +02:00
|
|
|
from ergast_py.models.result import Result
|
|
|
|
|
2022-06-01 15:31:52 +02:00
|
|
|
|
|
|
|
@dataclass
|
2022-06-06 13:20:48 +02:00
|
|
|
class Race():
|
2022-06-01 15:31:52 +02:00
|
|
|
"""
|
|
|
|
Representation of a single Race from a Formula One season
|
2022-06-06 02:58:53 +02:00
|
|
|
|
2022-06-01 15:31:52 +02:00
|
|
|
Races may contain:
|
|
|
|
season: Integer
|
2022-06-06 02:58:53 +02:00
|
|
|
round_no: Integer
|
2022-06-01 15:31:52 +02:00
|
|
|
url: String
|
2022-06-06 02:58:53 +02:00
|
|
|
race_name: String
|
2022-06-01 15:31:52 +02:00
|
|
|
circuit: Circuit
|
|
|
|
date: datetime.datetime
|
|
|
|
results: Result[]
|
2022-06-06 02:58:53 +02:00
|
|
|
first_practice: datetime.datetime
|
|
|
|
second_practice: datetime.datetime
|
|
|
|
third_practice: datetime.datetime
|
2022-06-01 15:31:52 +02:00
|
|
|
sprint: datetime.datetime
|
2022-06-06 02:58:53 +02:00
|
|
|
sprint_results: Result[]
|
2022-06-01 15:31:52 +02:00
|
|
|
qualifying: datetime.datetime
|
2022-06-06 02:58:53 +02:00
|
|
|
qualifying_results: Result[]
|
|
|
|
pit_stops: PitStop[]
|
2022-06-01 15:31:52 +02:00
|
|
|
laps: Lap[]
|
|
|
|
"""
|
|
|
|
|
2022-06-06 02:58:53 +02:00
|
|
|
def __init__(self, season: int, round_no: int, url: str, race_name: str, circuit: Circuit,
|
|
|
|
date: datetime.datetime, results: list[Result], first_practice: datetime.datetime,
|
|
|
|
second_practice: datetime.datetime, third_practice: datetime.datetime,
|
|
|
|
sprint: datetime.datetime, sprint_results: list[Result],
|
|
|
|
qualifying: datetime.datetime, qualifying_results: list[Result],
|
|
|
|
pit_stops: list[PitStop], laps: list[Lap]) -> None:
|
2022-06-01 15:31:52 +02:00
|
|
|
self.season = season
|
2022-06-06 02:58:53 +02:00
|
|
|
self.round_no = round_no
|
2022-06-01 15:31:52 +02:00
|
|
|
self.url = url
|
2022-06-06 02:58:53 +02:00
|
|
|
self.race_name = race_name
|
2022-06-01 15:31:52 +02:00
|
|
|
self.circuit = circuit
|
|
|
|
self.date = date
|
|
|
|
self.results = results
|
2022-06-06 02:58:53 +02:00
|
|
|
self.first_practice = first_practice
|
|
|
|
self.second_practice = second_practice
|
|
|
|
self.third_practice = third_practice
|
2022-06-01 15:31:52 +02:00
|
|
|
self.sprint = sprint
|
2022-06-06 02:58:53 +02:00
|
|
|
self.sprint_results = sprint_results
|
2022-06-01 15:31:52 +02:00
|
|
|
self.qualifying = qualifying
|
2022-06-06 02:58:53 +02:00
|
|
|
self.qualifying_results = qualifying_results
|
|
|
|
self.pit_stops = pit_stops
|
2022-06-01 15:31:52 +02:00
|
|
|
self.laps = laps
|
2022-06-06 13:20:48 +02:00
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
|
members = ', '.join(f"{key}={value}" for key, value in self.__dict__.items())
|
|
|
|
return f"{type(self).__name__}({members})"
|