Skip to content

client

Modules:

Name Description
client_server
communication
exceptions
settings

Attributes:

Name Type Description
Communication Type[Communication]

Client communication module.

Settings Type[Settings]

Client settings module.

Attributes

Communication module-attribute

Communication: Type[Communication] = import_string(COMMUNICATION_MODULE if hasattr(Settings, 'COMMUNICATION_MODULE') else 'dlr.fl.client.communication.Communication')

Client communication module.

The client communication can be customized by setting the COMMUNICATION_MODULE attribute inside the Settings to the dotted path of the module. By default and fallback the communication is loaded from the module dlr.fl.client.communication.Communication.

Settings module-attribute

Settings: Type[Settings] = import_string(get('FL_CLIENT_SETTINGS_MODULE', 'dlr.fl.client.settings.Settings'))

Client settings module.

The client settings can be customized by creating a custom settings module and setting the environment variable FL_CLIENT_SETTINGS_MODULE to the dotted path of the module. By default and fallback the settings are loaded from the module dlr.fl.client.settings.Settings.

__all__ module-attribute

__all__ = ['Settings', 'Communication']

Classes

Functions

import_string

import_string(dotted_path: str) -> Any

Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed.

Parameters:

Name Type Description Default

dotted_path

str

The dotted path to the attribute/class/method to import.

required

Returns:

Type Description
Any

The attribute/class/method designated by the dotted path.

Source: https://github.com/django/django/blob/01c00dc/django/utils/module_loading.py#L15-L33

Source code in dlr/fl/client/__init__.py
def import_string(dotted_path: str) -> Any:
    """
    Import a dotted module path and return the attribute/class designated by the
    last name in the path. Raise ImportError if the import failed.

    Args:
        dotted_path (str): The dotted path to the attribute/class/method to import.

    Returns:
        The attribute/class/method designated by the dotted path.

    Source: https://github.com/django/django/blob/01c00dc/django/utils/module_loading.py#L15-L33
    """
    try:
        module_path, class_name = dotted_path.rsplit('.', 1)
    except ValueError:
        msg = f"{dotted_path} doesn't look like a module path"
        raise ImportError(msg).with_traceback(sys.exc_info()[2])

    module = import_module(module_path)

    try:
        return getattr(module, class_name)
    except AttributeError:
        msg = f'Module "{dotted_path}" does not define a "{class_name}" attribute/class/method'
        raise ImportError(msg).with_traceback(sys.exc_info()[2])