nglcobdai_utils.messages

class Messenger(filepath: str | Path)[source]

Bases: object

Messenger class to retrieve messages from a message file.

__init__(filepath: str | Path) None[source]

Constructor of Message

Parameters:

filepath (str | Path) – File path of the message file.

__call__(section: str, key: str, **kwargs) str[source]

Get message

Parameters:
  • key (str) – Key of the message.

  • section (str) – Section of the message.

  • kwargs (dict) – Arguments for message.

Returns:

Message

Return type:

str

Raises:

ValueError – If message section or key is not found, or if required arguments are missing.

exception MessengerFileNotFoundError(**kwargs)[source]

Bases: TemplateError

Raised when the message file is not found.

exception MessengerMissingSectionHeaderError(**kwargs)[source]

Bases: TemplateError

Raised when a required section header is missing in the message file.

exception MessengerSectionNotFoundError(**kwargs)[source]

Bases: TemplateError

Raised when a specified message section cannot be found in the file.

exception MessengerKeyNotFoundError(**kwargs)[source]

Bases: TemplateError

Raised when the specified message key is not found in the section.

exception MessengerMissingArgumentsError(**kwargs)[source]

Bases: TemplateError

Raised when required arguments for the message template are missing.

exception MessengerUnexpectedError(**kwargs)[source]

Bases: TemplateError

Raised for unexpected errors while retrieving messages.