checkbox_sdk.client package

Subpackages

Submodules

checkbox_sdk.client.asynchronous module

checkbox_sdk.client.base module

checkbox_sdk.client.rate_limit module

class checkbox_sdk.client.rate_limit.AsyncRateLimitTransport(transport: AsyncBaseTransport, requests_per_10s: int | None = None)

Bases: AsyncBaseTransport

Transport wrapper to enforce rate limiting using requests per 10 seconds.

This class wraps an asynchronous HTTP transport to implement rate limiting, ensuring that no more than a specified number of requests are made within a 10-second window.

transport

The underlying asynchronous HTTP transport to handle requests.

Type:

httpx.AsyncBaseTransport

lock

A lock to ensure thread-safe request handling.

Type:

Lock

min_interval

The minimum time interval between requests, calculated from the rate limit.

Type:

float

last_request_time

The timestamp of the last request, used to track elapsed time.

Type:

float

async handle_async_request(request)

Handles the asynchronous request, enforcing the rate limit by ensuring the time between requests does not exceed the specified interval.

The method calculates the elapsed time since the last request and waits if necessary to maintain the rate limit before forwarding the request to the underlying transport.

Параметри:

request – The asynchronous HTTP request to be handled.

Повертає:

The response returned by the underlying transport after handling the request.

class checkbox_sdk.client.rate_limit.RateLimitTransport(transport: BaseTransport, requests_per_10s: int | None = None)

Bases: BaseTransport

Transport wrapper to enforce rate limiting using requests per 10 seconds.

This class wraps a synchronous HTTP transport to implement rate limiting, ensuring that no more than a specified number of requests are made within a 10-second window.

transport

The underlying HTTP transport to handle requests.

Type:

httpx.BaseTransport

lock

A lock to ensure thread-safe request handling.

Type:

Lock

min_interval

The minimum time interval between requests, calculated from the rate limit.

Type:

float

last_request_time

The timestamp of the last request, used to track elapsed time.

Type:

float

handle_request(request)

Handles the request, enforcing the rate limit by ensuring the time between requests does not exceed the specified interval.

The method calculates the elapsed time since the last request and waits if necessary to maintain the rate limit before forwarding the request to the underlying transport.

Параметри:

request – The HTTP request to be handled.

Повертає:

The response returned by the underlying transport after handling the request.

checkbox_sdk.client.synchronous module

checkbox_sdk.client.utils module

class checkbox_sdk.client.utils.MLStripper

Bases: HTMLParser

get_data()
handle_data(data)
handle_endtag(tag)
handle_starttag(tag, attrs)
checkbox_sdk.client.utils.strip_tags(value)

Remove HTML tags and certain unwanted content from the given HTML string, returning clean, plain text with normalized whitespace.

This function uses a custom HTML parser that strips out all HTML tags, and also ignores the content inside <title>, <style>, and <script> tags, which often contain CSS, JavaScript, or metadata not useful for log messages.

Whitespace, including newlines, is collapsed to single spaces for readability.

Intended use: Clean and simplify HTML error responses from Checkbox (e.g., 503 Service Temporarily Unavailable pages) to produce more readable and concise log messages.

Параметри:

value (str) – The raw HTML string to clean.

Повертає:

Plain text extracted from the HTML input, without tags or ignored content,

with normalized whitespace.

Тип повернення:

str

Module contents