Added comments to application
This commit is contained in:
		| @@ -12,6 +12,9 @@ class ApplicationABC(ABC): | ||||
|  | ||||
|     @abstractmethod | ||||
|     def __init__(self): | ||||
|         """ | ||||
|         ABC of application | ||||
|         """ | ||||
|         self._startup: Optional[StartupABC] = None | ||||
|         self._app_host: Optional[ApplicationHostABC] = None | ||||
|         self._configuration: Optional[ConfigurationABC] = None | ||||
| @@ -19,9 +22,18 @@ class ApplicationABC(ABC): | ||||
|         self._services: Optional[ServiceProviderABC] = None | ||||
|  | ||||
|     def use_startup(self, startup: Type[StartupABC]): | ||||
|         """ | ||||
|         Sets the used startup class | ||||
|         :param startup: | ||||
|         :return: | ||||
|         """ | ||||
|         self._startup = startup() | ||||
|  | ||||
|     def build(self): | ||||
|         """ | ||||
|         Creates application host and runtime | ||||
|         :return: | ||||
|         """ | ||||
|         if self._startup is not None: | ||||
|             self._app_host = self._startup.create_application_host() | ||||
|             self._runtime = self._app_host.application_runtime | ||||
| @@ -29,11 +41,25 @@ class ApplicationABC(ABC): | ||||
|             self._services = self._startup.create_services() | ||||
|  | ||||
|     def run(self): | ||||
|         """ | ||||
|         Entry point | ||||
|         :return: | ||||
|         """ | ||||
|         self.configure() | ||||
|         self.main() | ||||
|  | ||||
|     @abstractmethod | ||||
|     def configure(self): pass | ||||
|     def configure(self): | ||||
|         """ | ||||
|         Prepare the application | ||||
|         :return: | ||||
|         """ | ||||
|         pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def main(self): pass | ||||
|     def main(self): | ||||
|         """ | ||||
|         Custom entry point | ||||
|         :return: | ||||
|         """ | ||||
|         pass | ||||
|   | ||||
| @@ -1,4 +1,3 @@ | ||||
| import atexit | ||||
| from collections import Callable | ||||
|  | ||||
| from cpl.application.application_host_abc import ApplicationHostABC | ||||
| @@ -6,7 +5,6 @@ from cpl.application.application_runtime import ApplicationRuntime | ||||
| from cpl.application.application_runtime_abc import ApplicationRuntimeABC | ||||
| from cpl.configuration.configuration import Configuration | ||||
| from cpl.configuration.configuration_abc import ConfigurationABC | ||||
| from cpl.console.console import Console | ||||
| from cpl.dependency_injection.service_provider import ServiceProvider | ||||
| from cpl.dependency_injection.service_provider_abc import ServiceProviderABC | ||||
|  | ||||
| @@ -14,6 +12,9 @@ from cpl.dependency_injection.service_provider_abc import ServiceProviderABC | ||||
| class ApplicationHost(ApplicationHostABC): | ||||
|  | ||||
|     def __init__(self): | ||||
|         """ | ||||
|         Representation of application host | ||||
|         """ | ||||
|         ApplicationHostABC.__init__(self) | ||||
|  | ||||
|         # Init | ||||
| @@ -33,9 +34,5 @@ class ApplicationHost(ApplicationHostABC): | ||||
|     def services(self) -> ServiceProviderABC: | ||||
|         return self._services | ||||
|  | ||||
|     @staticmethod | ||||
|     def output_at_exit(): | ||||
|         atexit.register(Console.close) | ||||
|  | ||||
|     def console_argument_error_function(self, function: Callable): | ||||
|         self._config.argument_error_function = function | ||||
|   | ||||
| @@ -9,7 +9,11 @@ from cpl.dependency_injection.service_provider_abc import ServiceProviderABC | ||||
| class ApplicationHostABC(ABC): | ||||
|  | ||||
|     @abstractmethod | ||||
|     def __init__(self): pass | ||||
|     def __init__(self): | ||||
|         """ | ||||
|         ABC for application host | ||||
|         """ | ||||
|         pass | ||||
|  | ||||
|     @property | ||||
|     @abstractmethod | ||||
| @@ -23,9 +27,11 @@ class ApplicationHostABC(ABC): | ||||
|     @abstractmethod | ||||
|     def services(self) -> ServiceProviderABC: pass | ||||
|  | ||||
|     @staticmethod | ||||
|     @abstractmethod | ||||
|     def output_at_exit(): pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def console_argument_error_function(self, function: Callable): pass | ||||
|     def console_argument_error_function(self, function: Callable): | ||||
|         """ | ||||
|         Defines function to call when a argument error is detected | ||||
|         :param function: | ||||
|         :return: | ||||
|         """ | ||||
|         pass | ||||
|   | ||||
| @@ -8,6 +8,10 @@ from cpl.configuration.configuration_abc import ConfigurationABC | ||||
| class ApplicationRuntime(ApplicationRuntimeABC): | ||||
|  | ||||
|     def __init__(self, config: ConfigurationABC): | ||||
|         """ | ||||
|         Representation of the application runtime | ||||
|         :param config: | ||||
|         """ | ||||
|         ApplicationRuntimeABC.__init__(self) | ||||
|  | ||||
|         self._app_configuration = config | ||||
|   | ||||
| @@ -7,7 +7,11 @@ from cpl.configuration.configuration_abc import ConfigurationABC | ||||
| class ApplicationRuntimeABC(ABC): | ||||
|  | ||||
|     @abstractmethod | ||||
|     def __init__(self): pass | ||||
|     def __init__(self): | ||||
|         """ | ||||
|         ABC for application runtime | ||||
|         """ | ||||
|         pass | ||||
|  | ||||
|     @property | ||||
|     @abstractmethod | ||||
| @@ -42,4 +46,10 @@ class ApplicationRuntimeABC(ABC): | ||||
|     def runtime_directory(self) -> str: pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def set_runtime_directory(self, runtime_directory: str): pass | ||||
|     def set_runtime_directory(self, runtime_directory: str): | ||||
|         """ | ||||
|         Sets the current runtime directory | ||||
|         :param runtime_directory: | ||||
|         :return: | ||||
|         """ | ||||
|         pass | ||||
|   | ||||
| @@ -8,13 +8,32 @@ from cpl.dependency_injection.service_provider_abc import ServiceProviderABC | ||||
| class StartupABC(ABC): | ||||
|  | ||||
|     @abstractmethod | ||||
|     def __init__(self): pass | ||||
|     def __init__(self): | ||||
|         """ | ||||
|         ABC for a startup class | ||||
|         """ | ||||
|         pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def create_application_host(self) -> ApplicationHostABC: pass | ||||
|     def create_application_host(self) -> ApplicationHostABC: | ||||
|         """ | ||||
|         Creates application host with specific attributes | ||||
|         :return: application host | ||||
|         """ | ||||
|         pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def create_configuration(self) -> ConfigurationABC: pass | ||||
|     def create_configuration(self) -> ConfigurationABC: | ||||
|         """ | ||||
|         Creates configuration of application | ||||
|         :return: configuration | ||||
|         """ | ||||
|         pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def create_services(self) -> ServiceProviderABC: pass | ||||
|     def create_services(self) -> ServiceProviderABC: | ||||
|         """ | ||||
|         Creates service provider | ||||
|         :return: service provider | ||||
|         """ | ||||
|         pass | ||||
|   | ||||
		Reference in New Issue
	
	Block a user