ResourceFetcher

class plutoprint.ResourceFetcher[source]

Base class for fetching external resources.

fetch_url(url: str) ResourceData[source]

Fetches a resource from the specified URL. This method can be overridden in derived classes.

Parameters:

url – The URL of the resource.

Returns:

The fetched resource data.

class plutoprint.DefaultResourceFetcher[source]

Default implementation of ResourceFetcher.

set_ssl_cainfo(path: str | bytes | PathLike) None[source]

Sets the path to a file containing trusted CA certificates.

If not set, no custom CA file is used.

Parameters:

path – Path to the CA certificate bundle file.

set_ssl_capath(path: str | bytes | PathLike) None[source]

Sets the path to a directory containing trusted CA certificates.

If not set, no custom CA path is used.

Parameters:

path – Path to the directory with CA certificates.

set_ssl_verify_peer(verify: bool) None[source]

Enables or disables SSL peer certificate verification.

If not set, verification is enabled by default.

Parameters:

verifyTrue to verify the peer, False to disable verification.

set_ssl_verify_host(verify: bool) None[source]

Enables or disables SSL host name verification.

If not set, verification is enabled by default.

Parameters:

verifyTrue to verify the host, False to disable verification.

set_http_follow_redirects(follow: bool) None[source]

Enables or disables automatic following of HTTP redirects.

If not set, following redirects is enabled by default.

Parameters:

followTrue to follow redirects, False to disable.

set_http_max_redirects(amount: int) None[source]

Sets the maximum number of redirects to follow.

If not set, the default maximum is 30.

Parameters:

amount – Maximum number of redirects.

set_http_timeout(timeout: int) None[source]

Sets the maximum time allowed for an HTTP request.

If not set, the default timeout is 300 seconds.

Parameters:

timeout – Timeout duration in seconds.

plutoprint.default_resource_fetcher: DefaultResourceFetcher = Ellipsis

Represents the default fetcher used to fetch external resources such as stylesheets, fonts, and images.