Files
Python-With-Gtk-Template/src/libs/singleton_raised.py
itdominator 1447a68fb0 Refactor controller architecture and multi-insert state
- Rename ControllerContext to ControllerMessageBus for clarity
- Switch ControllerBase to use SingletonRaised
- Replace MarkEventsMixin with MarkerManager for multi-cursor editing
- Add populate_popup event support for source view context menus
- Remove unused swap file events
- Moved JSON prettify feature to plugin
- Fix event name: "removed_file" -> "remove_file"
2026-02-28 01:10:28 -06:00

30 lines
623 B
Python

# Python imports
from typing import Type, TypeVar, Any
# Lib imports
# Application imports
class SingletonError(Exception):
pass
T = TypeVar('T', bound='SingletonRaised')
class SingletonRaised:
__instance = None
def __new__(cls: Type[T], *args: Any, **kwargs: Any) -> T:
if cls.__instance is not None:
raise SingletonError(f"'{cls.__name__}' is a Singleton. Cannot create a new instance...")
cls.__instance = super(SingletonRaised, cls).__new__(cls)
return cls.__instance
def __init__(self) -> None:
if self.__instance is not None:
return