notification
dev_tool.services.notification
__all__ = ['NotificationDisplay', 'NotificationFormat', 'NotificationManager', 'NotificationService', 'NotificationType']
module-attribute
NotificationDisplay
A display class for rendering notifications in the terminal.
This class handles the formatting and styling of notifications for display in both banner and text formats with terminal color support.
The constructor for the NotificationDisplay class.
Parameters:
-
terminal(Terminal | None, default:None) –The blessed Terminal instance for display operations.
-
theme(Default | None, default:None) –The theme instance for styling notifications.
Source code in dev_tool/services/notification/display.py
notification = NotificationService()
instance-attribute
terminal = terminal or Terminal()
instance-attribute
theme = theme or Default(self.terminal)
instance-attribute
display_active
A method that displays all active notifications in command mode.
Parameters:
-
service(NotificationService) –The notification service to get active notifications from.
Source code in dev_tool/services/notification/display.py
display_new_notifications
A method that displays any new notifications that haven't been shown yet.
Parameters:
-
service(NotificationService) –The notification service to get active notifications from.
-
displayed(set) –Set of already displayed notification keys.
Source code in dev_tool/services/notification/display.py
format_notification_banner
A method that formats a notification for banner display.
Parameters:
-
notification(Notification) –The notification object to format.
Returns:
-
str–The formatted notification banner string.
Source code in dev_tool/services/notification/display.py
get_notification_lines
A method that gets formatted notification lines for display.
Returns:
Source code in dev_tool/services/notification/display.py
has_active_notifications
A method that checks if there are any active notifications.
Returns:
-
bool–True if there are active notifications, False otherwise.
Source code in dev_tool/services/notification/display.py
NotificationFormat
Bases: StrEnum
BANNER = 'banner'
class-attribute
instance-attribute
TEXT = 'text'
class-attribute
instance-attribute
NotificationType
Bases: StrEnum
NORMAL = 'normal'
class-attribute
instance-attribute
INFO = 'info'
class-attribute
instance-attribute
WARNING = 'warning'
class-attribute
instance-attribute
ERROR = 'error'
class-attribute
instance-attribute
SUCCESS = 'success'
class-attribute
instance-attribute
NotificationManager
A manager class that coordinates between notification service and display.
This class orchestrates notification monitoring, display, and lifecycle without mixing the concerns of data management and presentation.
The constructor for the NotificationManager class.
Parameters:
-
display(NotificationDisplay) –The notification display instance for rendering.
-
service(NotificationService) –The notification service instance for data management.
Source code in dev_tool/services/notification/manager.py
display = display
instance-attribute
last_count = 0
instance-attribute
last_update = 0
instance-attribute
service = service
instance-attribute
clear
display_active
A method that displays all active notifications in command mode.
Source code in dev_tool/services/notification/manager.py
display_new
A method that displays any new notifications that haven't been shown yet.
Parameters:
-
displayed(set) –Set of already displayed notification keys.
Source code in dev_tool/services/notification/manager.py
error
get_active_count
A method that gets the count of active notifications.
Returns:
-
int–The number of active notifications.
info
is_changed
A method that checks if notifications have changed in a way that requires attention.
Returns:
-
bool–True if notifications have changed, False otherwise.
Source code in dev_tool/services/notification/manager.py
monitor
A context manager for monitoring and displaying notifications during command execution.
Returns:
-
Generator[None, None, None]–A generator for the context manager.
Source code in dev_tool/services/notification/manager.py
normal
A method that adds a normal notification.
Parameters:
-
message(str) –The notification message text.
success
warning
NotificationService
A thread-safe singleton service for managing application notifications.
This class provides centralized notification management with support for different notification types, formats, and lifecycle management.
The constructor for the NotificationService class.
Initializes the service with an empty notification list and thread safety.
Source code in dev_tool/services/notification/service.py
__new__
A class method that creates a singleton instance with thread safety.
Returns:
-
Self–The singleton NotificationService instance.
Source code in dev_tool/services/notification/service.py
add_notification
A method that adds a new notification to the active list.
Parameters:
-
message(str) –The notification message text.
-
notification_type(NotificationType, default:INFO) –The type of notification for styling.
-
notification_format(NotificationFormat, default:BANNER) –The display format for the notification.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the notification type prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
clear
dismiss
A method that removes a specific notification from the active list.
Parameters:
-
notification(Notification) –The notification object to remove.
Source code in dev_tool/services/notification/service.py
dismiss_by_identifier
A method that removes notifications with a specific identifier.
Parameters:
-
identifier(str) –The identifier to match for removal.
Source code in dev_tool/services/notification/service.py
error
A method that adds an error notification with red styling.
Parameters:
-
message(str) –The error message text.
-
duration(float, default:10.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the error prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
error_banner
A method that adds an error notification with banner format.
Parameters:
-
message(str) –The error message text.
-
duration(float, default:10.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the error prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
error_text
A method that adds an error notification with text format.
Parameters:
-
message(str) –The error message text.
-
duration(float, default:10.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the error prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
flush
get_active
A method that gets active notifications and cleans up expired ones.
Returns:
-
list[Notification]–A list of active notification objects.
Source code in dev_tool/services/notification/service.py
info
A method that adds an info notification with blue styling.
Parameters:
-
message(str) –The info message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the info prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
info_banner
A method that adds an info notification with banner format.
Parameters:
-
message(str) –The info message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the info prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
info_text
A method that adds an info notification with text format.
Parameters:
-
message(str) –The info message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the info prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
normal
A method that adds a normal notification with plain styling.
Parameters:
-
message(str) –The notification message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the normal prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
normal_banner
A method that adds a normal notification with banner format.
Parameters:
-
message(str) –The notification message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the normal prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
normal_text
A method that adds a normal notification with text format.
Parameters:
-
message(str) –The notification message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the normal prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
success
A method that adds a success notification with green styling.
Parameters:
-
message(str) –The success message text.
-
duration(float, default:3.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the success prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
success_banner
A method that adds a success notification with banner format.
Parameters:
-
message(str) –The success message text.
-
duration(float, default:3.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the success prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
success_text
A method that adds a success notification with text format.
Parameters:
-
message(str) –The success message text.
-
duration(float, default:3.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the success prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
warning
A method that adds a warning notification with yellow styling.
Parameters:
-
message(str) –The warning message text.
-
duration(float, default:7.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the warning prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
warning_banner
A method that adds a warning notification with banner format.
Parameters:
-
message(str) –The warning message text.
-
duration(float, default:7.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the warning prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
warning_text
A method that adds a warning notification with text format.
Parameters:
-
message(str) –The warning message text.
-
duration(float, default:7.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the warning prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.