From dc489cbf7af4e6154dbb89e4a8d78a8c17887390 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 17 Sep 2022 11:58:43 +0200 Subject: [PATCH] Removed async from startup functions --- .../new/console/source/name/startup.py | 59 ++++++------------- .../new/library/source/name/startup.py | 59 ++++++------------- src/cpl_cli/source_creator/console_builder.py | 2 +- src/cpl_cli/source_creator/library_builder.py | 2 +- 4 files changed, 40 insertions(+), 82 deletions(-) diff --git a/src/cpl_cli/_templates/new/console/source/name/startup.py b/src/cpl_cli/_templates/new/console/source/name/startup.py index f2d51009..20e14842 100644 --- a/src/cpl_cli/_templates/new/console/source/name/startup.py +++ b/src/cpl_cli/_templates/new/console/source/name/startup.py @@ -5,51 +5,30 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC class StartupTemplate(TemplateFileABC): - def __init__(self, name: str, path: str, use_async: bool): + def __init__(self, name: str, path: str): TemplateFileABC.__init__(self) self._name = 'startup.py' self._path = path - self._use_async = use_async - if self._use_async: - self._value = textwrap.dedent("""\ - from cpl_core.application import StartupABC - from cpl_core.configuration import ConfigurationABC - from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC - from cpl_core.environment import ApplicationEnvironment - - - class Startup(StartupABC): - - def __init__(self): - StartupABC.__init__(self) - - async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: - return configuration - - async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: - return services.build_service_provider() - """) - else: - self._value = textwrap.dedent("""\ - from cpl_core.application import StartupABC - from cpl_core.configuration import ConfigurationABC - from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC - from cpl_core.environment import ApplicationEnvironment - - - class Startup(StartupABC): - - def __init__(self): - StartupABC.__init__(self) - - def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: - return configuration - - def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: - return services.build_service_provider() - """) + self._value = textwrap.dedent("""\ + from cpl_core.application import StartupABC + from cpl_core.configuration import ConfigurationABC + from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC + from cpl_core.environment import ApplicationEnvironment + + + class Startup(StartupABC): + + def __init__(self): + StartupABC.__init__(self) + + def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: + return configuration + + def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: + return services.build_service_provider() + """) @property def name(self) -> str: diff --git a/src/cpl_cli/_templates/new/library/source/name/startup.py b/src/cpl_cli/_templates/new/library/source/name/startup.py index fcfe0b8b..959bc0ce 100644 --- a/src/cpl_cli/_templates/new/library/source/name/startup.py +++ b/src/cpl_cli/_templates/new/library/source/name/startup.py @@ -5,50 +5,29 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC class StartupTemplate(TemplateFileABC): - def __init__(self, name: str, path: str, use_async: bool): + def __init__(self, name: str, path: str): TemplateFileABC.__init__(self) self._name = 'startup.py' self._path = path - - if use_async: - self._value = textwrap.dedent("""\ - from cpl_core.application import StartupABC - from cpl_core.configuration import ConfigurationABC - from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC - from cpl_core.environment import ApplicationEnvironment - - - class Startup(StartupABC): - - def __init__(self): - StartupABC.__init__(self) - - async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: - return configuration - - async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: - return services.build_service_provider() - """) - else: - self._value = textwrap.dedent("""\ - from cpl_core.application import StartupABC - from cpl_core.configuration import ConfigurationABC - from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC - from cpl_core.environment import ApplicationEnvironment - - - class Startup(StartupABC): - - def __init__(self): - StartupABC.__init__(self) - - def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: - return configuration - - def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: - return services.build_service_provider() - """) + self._value = textwrap.dedent("""\ + from cpl_core.application import StartupABC + from cpl_core.configuration import ConfigurationABC + from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC + from cpl_core.environment import ApplicationEnvironment + + + class Startup(StartupABC): + + def __init__(self): + StartupABC.__init__(self) + + def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: + return configuration + + def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: + return services.build_service_provider() + """) @property def name(self) -> str: diff --git a/src/cpl_cli/source_creator/console_builder.py b/src/cpl_cli/source_creator/console_builder.py index 9120b392..e8b86f84 100644 --- a/src/cpl_cli/source_creator/console_builder.py +++ b/src/cpl_cli/source_creator/console_builder.py @@ -109,7 +109,7 @@ class ConsoleBuilder: templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async)) if use_startup: - templates.append(StartupTemplate(src_name, py_src_rel_path, use_async)) + templates.append(StartupTemplate(src_name, py_src_rel_path)) templates.append(MainWithApplicationHostAndStartupTemplate(src_name, py_src_rel_path, use_async)) else: templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async)) diff --git a/src/cpl_cli/source_creator/library_builder.py b/src/cpl_cli/source_creator/library_builder.py index 2fb7c2fc..702aa449 100644 --- a/src/cpl_cli/source_creator/library_builder.py +++ b/src/cpl_cli/source_creator/library_builder.py @@ -113,7 +113,7 @@ class LibraryBuilder: templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async)) if use_startup: - templates.append(StartupTemplate(src_name, py_src_rel_path, use_async)) + templates.append(StartupTemplate(src_name, py_src_rel_path)) templates.append(MainWithApplicationHostAndStartupTemplate(src_name, py_src_rel_path, use_async)) else: templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))