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.

37 lines
1009 B
Python
Raw Normal View History

""" Circuit class """
2022-06-01 14:31:52 +01:00
from dataclasses import dataclass
2022-06-01 14:31:52 +01:00
from ergast_py.models.location import Location
2022-06-01 14:31:52 +01:00
@dataclass
2022-06-06 12:20:48 +01:00
class Circuit():
2022-06-01 14:31:52 +01:00
"""
Representation of a Formula One Circuit
2022-06-01 14:31:52 +01:00
Circuits may contain:
circuit_id: String
2022-06-01 14:31:52 +01:00
url: String
circuit_name: String
2022-06-01 14:31:52 +01:00
location: Location
"""
def __init__(self, circuit_id: str, url: str, circuit_name: str, location: Location) -> None:
self.circuit_id = circuit_id
2022-06-01 14:31:52 +01:00
self.url = url
self.circuit_name = circuit_name
2022-06-01 14:31:52 +01:00
self.location = location
2022-06-06 12:20:48 +01:00
def __repr__(self) -> str:
members = ', '.join(f"{key}={value}" for key, value in self.__dict__.items())
return f"{type(self).__name__}({members})"
2022-06-09 23:19:28 +01:00
def __eq__(self, __o: object) -> bool:
return isinstance(__o, Circuit) and (
self.circuit_id == __o.circuit_id and
self.url == __o.url and
self.circuit_name == __o.circuit_name and
self.location == __o.location
)