Submodules

Objects

class yukinator.objects.AverageSpeedDTO(units: Optional[str] = None, speed=None)

Bases: DTO

speed: Optional[int]
units: Optional[str]
class yukinator.objects.CircuitDTO(circuitId: str, url: str, circuitName: str, Location: dict)

Bases: DTO

Location: LocationDTO
circuitId: str
circuitName: str
url: str
class yukinator.objects.ConstructorDTO(constructorId: str, url: str, name: str, nationality: str)

Bases: DTO

constructorId: str
name: str
nationality: str
url: str
class yukinator.objects.ConstructorStandingDTO(Constructor: dict, position, positionText: str, points, wins)

Bases: DTO

Constructor: ConstructorDTO
points: float
position: int
positionText: str
wins: int
class yukinator.objects.DTO

Bases: object

Parent class for all DTOs

to_dict() dict

Convert object to a dictionary

to_flat_dict() dict

Convert object to a flat dictionary

to_json() str

Convert object to a json string

to_tuple() tuple

Convert object to a tuple

class yukinator.objects.DriverDTO(driverId: str, url: str, givenName: str, familyName: str, dateOfBirth: str, nationality: str, permanentNumber=None, code: Optional[str] = None)

Bases: DTO

code: Optional[str]
dateOfBirth: date
driverId: str
familyName: str
givenName: str
nationality: str
permanentNumber: Optional[int]
url: str
class yukinator.objects.DriverStandingDTO(Driver: dict, position, positionText: str, points, wins, Constructors: list)

Bases: DTO

Constructors: ConstructorDTO
Driver: DriverDTO
points: float
position: int
positionText: str
wins: int
class yukinator.objects.FastestLapDTO(rank=None, lap=None, Time: Optional[dict] = None, AverageSpeed: Optional[dict] = None)

Bases: DTO

AverageSpeed: Optional[AverageSpeedDTO]
Time: Optional[TimeDTO]
lap: Optional[int]
rank: Optional[int]
class yukinator.objects.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: JSONEncoder

Custom json encoder to deal with dates, times and DTOs

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class yukinator.objects.LapDTO(number, Timings: list)

Bases: DTO

Timings: list[yukinator.objects.TimingDTO]
number: int
class yukinator.objects.LocationDTO(lat, long, locality: str, country: str)

Bases: DTO

country: str
lat: float
locality: str
long: float
class yukinator.objects.PitStopDTO(driverId: str, lap, stop, time: str, duration)

Bases: DTO

driverId: str
duration: float
lap: int
stop: int
time: str
class yukinator.objects.QualifyingResultDTO(Driver: dict, number, position, Constructor: dict, Q1: Optional[str] = None, Q2: Optional[str] = None, Q3: Optional[str] = None)

Bases: DTO

Constructor: ConstructorDTO
Driver: DriverDTO
Q1: Optional[str]
Q2: Optional[str]
Q3: Optional[str]
number: int
position: int
class yukinator.objects.RaceDTO(season, round, url: str, raceName: str, Circuit: dict, date: str, time: Optional[str] = None, firstpracticeDate: Optional[str] = None, firstpracticeTime: Optional[str] = None, secondpracticeDate: Optional[str] = None, secondpracticeTime: Optional[str] = None, thirdpracticeDate: Optional[str] = None, thirdpracticeTime: Optional[str] = None, qualifyingDate: Optional[str] = None, qualifyingTime: Optional[str] = None, sprintDate: Optional[str] = None, sprintTime: Optional[str] = None)

Bases: DTO

Circuit: CircuitDTO
date: date
firstpracticeDate: Optional[date]
firstpracticeTime: Optional[time]
qualifyingDate: Optional[date]
qualifyingTime: Optional[time]
raceName: str
round: int
season: int
secondpracticeDate: Optional[date]
secondpracticeTime: Optional[time]
sprintDate: Optional[date]
sprintTime: Optional[time]
thirdpracticeDate: Optional[date]
thirdpracticeTime: Optional[time]
time: Optional[time]
url: str
class yukinator.objects.RaceResultDTO(Driver: dict, number, Constructor: dict, position, positionText: str, points, grid, laps, status: str, Time: Optional[dict] = None, FastestLap: Optional[dict] = None)

Bases: DTO

Constructor: ConstructorDTO
Driver: DriverDTO
FastestLap: Optional[FastestLapDTO]
Time: Optional[TimeDTO]
grid: int
laps: int
number: int
points: float
position: int
positionText: str
status: str
class yukinator.objects.SeasonDTO(season, url: str)

Bases: DTO

season: int
url: str
class yukinator.objects.SprintResultDTO(number, Driver: dict, Constructor: dict, position, positionText: str, points, grid, laps, status: str, Time: Optional[dict] = None, FastestLap: Optional[dict] = None)

Bases: DTO

Constructor: ConstructorDTO
Driver: DriverDTO
FastestLap: Optional[FastestLapDTO]
Time: Optional[TimeDTO]
grid: int
laps: int
number: int
points: float
position: int
positionText: str
status: str
class yukinator.objects.StatusDTO(statusId, status: str, count)

Bases: DTO

count: int
status: str
statusId: int
class yukinator.objects.TimeDTO(millis=None, time: Optional[str] = None)

Bases: DTO

millis: Optional[int]
time: Optional[str]
class yukinator.objects.TimingDTO(driverId: str, position, time: str)

Bases: DTO

driverId: str
position: int
time: str
yukinator.objects.to_averagespeed_dto(d: dict)
yukinator.objects.to_circuit_dto(d: dict)
yukinator.objects.to_constructor_dto(d: dict)
yukinator.objects.to_constructors_dto_list(ll: list)
yukinator.objects.to_date(f: str) date
yukinator.objects.to_driver_dto(d: dict)
yukinator.objects.to_fastestlap_dto(d: dict)
yukinator.objects.to_location_dto(d: dict)
yukinator.objects.to_race_dto(d: dict)
yukinator.objects.to_time(f: str) time
yukinator.objects.to_time_dto(d: dict)
yukinator.objects.to_timings_dto_list(ll: list)

Utils

class yukinator.utils.Cache

Bases: object

classmethod cache_enable(path: str, headers: dict, expires_after: Union[None, int, float, str], clear: bool)

Enable caching.

Parameters
  • path (str) – Directory for a cache file.

  • headers (dict) – Dictionary of headers to be sent on each request.

  • expires_after (None, int, float, str) – Time after cached items will expire.

  • clear (bool) – If True clear cache. Defaults to False.

Raises

WrongDirectory – The provider directory for a cache does not exist.

classmethod cache_get(url)

Make a get request with caching

Parameters

url (str) – API endpoint URL.

Returns

Response for the request.

Return type

requests.models.Response

HTTPError: If the response’s status code is not less than 400.

static path_create(path: str) str

Create a cache path.

Parameters

path (str) – Directory for a cache file.

Returns

Concatenated path.

Return type

str

Raises

WrongDirectory – The provider directory for a cache does not exist.

yukinator.utils.flat_dict(d: dict, keys: Optional[list] = None) dict

Flat nested dict

Exceptions

exception yukinator.exceptions.WrongDirectory

Bases: Exception

Raised when the directory for cache does not exist.

exception yukinator.exceptions.WrongQueryParameters

Bases: Exception

Raised when the expected output for a given parameters is empty.