-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
40 lines (27 loc) · 1.02 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import datetime
from pydantic import BaseModel, Field
class Location(BaseModel):
locality: str
country: str
class Circuit(BaseModel):
location: Location = Field(None, alias="Location")
class RaceTime(BaseModel):
date: datetime.datetime
time: datetime.time
class Race(RaceTime, BaseModel):
round: int
raceName: str
circuit: Circuit = Field(None, alias="Circuit")
fp1: RaceTime = Field(None, alias="FirstPractice")
fp2: RaceTime = Field(None, alias="SecondPractice")
fp3: RaceTime = Field(None, alias="ThirdPractice")
quali: RaceTime = Field(None, alias="Qualifying")
sprint: RaceTime = Field(None, alias="Sprint")
class RaceTable(BaseModel):
season: int
races: list[Race] = Field(list[Race], alias="Races")
class ScheduleModel(BaseModel):
raceTable: RaceTable = Field(RaceTable, alias="RaceTable")
def __repr__(self) -> str:
members = ", ".join(f"{key}={value}" for key, value in self.__dict__.items())
return f"{type(self).__name__}({members})"