Adapter API Documentation

class Target(*args, **kwargs)[source]

Bases: Protocol

Defines the domain-specific interface used by the client.

request()[source]

Handles the request in a format expected by the client.

Return type:

str

Returns:

A string response.

class Adaptee[source]

Bases: object

Defines the existing interface with specific functionality that needs adaptation.

specific_request()[source]

Provides functionality that needs to be adapted.

Return type:

str

Returns:

A specific string response.

class Adapter(adaptee)[source]

Bases: Target

Adapts the Adaptee to the Target interface.

Parameters:

adaptee (Adaptee)

__init__(adaptee)[source]

Initializes the Adapter with an Adaptee instance.

Parameters:

adaptee (Adaptee) – The Adaptee instance to be adapted. Must not be None.

Raises:

ValueError – If the provided Adaptee instance is None.

request()[source]

Translates the Target’s request to the Adaptee’s specific_request.

Return type:

str

Returns:

A string response translated by the Adapter.