This repository has been archived on 2022-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
ergast-py/ergast_py/models/race.py

62 lines
2.1 KiB
Python
Raw Normal View History

""" Race class """
2022-06-01 15:31:52 +02:00
import datetime
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
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-01 15:31:52 +02:00
Races may contain:
season: Integer
round_no: Integer
2022-06-01 15:31:52 +02:00
url: String
race_name: String
2022-06-01 15:31:52 +02:00
circuit: Circuit
date: datetime.datetime
results: Result[]
first_practice: datetime.datetime
second_practice: datetime.datetime
third_practice: datetime.datetime
2022-06-01 15:31:52 +02:00
sprint: datetime.datetime
sprint_results: Result[]
2022-06-01 15:31:52 +02:00
qualifying: datetime.datetime
qualifying_results: Result[]
pit_stops: PitStop[]
2022-06-01 15:31:52 +02:00
laps: Lap[]
"""
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
self.round_no = round_no
2022-06-01 15:31:52 +02:00
self.url = url
self.race_name = race_name
2022-06-01 15:31:52 +02:00
self.circuit = circuit
self.date = date
self.results = results
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
self.sprint_results = sprint_results
2022-06-01 15:31:52 +02:00
self.qualifying = qualifying
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})"