Utilities

ehforwarderbot.utils.extra(name, desc)[source]

Decorator for slave channel’s “additional features” interface.

Parameters
  • name (str) – A human readable name for the function.

  • desc (str) – A short description and usage of it. Use {function_name} in place of the function name in the description.

Return type

Callable[..., Optional[str]]

Returns

The decorated method.

Example

@extra(name="Echo", desc="Return the text entered.\n\nUsage:\n    {function_name} text")
def echo(self, text: str) -> Optional[str]:
    return text
ehforwarderbot.utils.get_base_path()[source]

Get the base data path for EFB. This can be defined by the environment variable EFB_DATA_PATH.

If EFB_DATA_PATH is not defined, this gives ~/.ehforwarderbot.

This method creates the queried path if not existing.

Return type

Path

Returns

The base path.

ehforwarderbot.utils.get_config_path(module_id=None, ext='yaml')[source]

Get path for configuration file. Defaulted to ~/.ehforwarderbot/profiles/profile_name/module_id/config.yaml.

This method creates the queried path if not existing. The config file will not be created, however.

Parameters
  • module_id (Optional[NewType()(ModuleID, str)]) – Module ID.

  • ext (str) – Extension name of the config file. Defaulted to "yaml".

Return type

Path

Returns

The path to the configuration file.

ehforwarderbot.utils.get_custom_modules_path()[source]

Get the path to custom channels

Return type

Path

Returns

The path for custom channels.

ehforwarderbot.utils.get_data_path(module_id)[source]

Get the path for permanent storage of a module.

This method creates the queried path if not existing.

Parameters

module_id (NewType()(ModuleID, str)) – Module ID

Return type

Path

Returns

The data path of indicated module.

ehforwarderbot.utils.locate_module(module_id, module_type=None)[source]

Locate module by module ID

Parameters
  • module_id (NewType()(ModuleID, str)) – Module ID

  • module_type (Optional[str]) – Type of module, one of 'master', 'slave' and 'middleware'