Release 2022.10 #112
@ -5,51 +5,30 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
|
|||||||
|
|
||||||
class StartupTemplate(TemplateFileABC):
|
class StartupTemplate(TemplateFileABC):
|
||||||
|
|
||||||
def __init__(self, name: str, path: str, use_async: bool):
|
def __init__(self, name: str, path: str):
|
||||||
TemplateFileABC.__init__(self)
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
self._name = 'startup.py'
|
self._name = 'startup.py'
|
||||||
self._path = path
|
self._path = path
|
||||||
self._use_async = use_async
|
|
||||||
|
|
||||||
if self._use_async:
|
self._value = textwrap.dedent("""\
|
||||||
self._value = textwrap.dedent("""\
|
from cpl_core.application import StartupABC
|
||||||
from cpl_core.application import StartupABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
from cpl_core.environment import ApplicationEnvironment
|
||||||
from cpl_core.environment import ApplicationEnvironment
|
|
||||||
|
|
||||||
|
|
||||||
class Startup(StartupABC):
|
class Startup(StartupABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
StartupABC.__init__(self)
|
StartupABC.__init__(self)
|
||||||
|
|
||||||
async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||||
return configuration
|
return configuration
|
||||||
|
|
||||||
async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||||
return services.build_service_provider()
|
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()
|
|
||||||
""")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
@ -5,50 +5,29 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
|
|||||||
|
|
||||||
class StartupTemplate(TemplateFileABC):
|
class StartupTemplate(TemplateFileABC):
|
||||||
|
|
||||||
def __init__(self, name: str, path: str, use_async: bool):
|
def __init__(self, name: str, path: str):
|
||||||
TemplateFileABC.__init__(self)
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
self._name = 'startup.py'
|
self._name = 'startup.py'
|
||||||
self._path = path
|
self._path = path
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
if use_async:
|
from cpl_core.application import StartupABC
|
||||||
self._value = textwrap.dedent("""\
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.application import StartupABC
|
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.environment import ApplicationEnvironment
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
|
||||||
from cpl_core.environment import ApplicationEnvironment
|
|
||||||
|
|
||||||
|
|
||||||
class Startup(StartupABC):
|
class Startup(StartupABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
StartupABC.__init__(self)
|
StartupABC.__init__(self)
|
||||||
|
|
||||||
async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||||
return configuration
|
return configuration
|
||||||
|
|
||||||
async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||||
return services.build_service_provider()
|
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()
|
|
||||||
""")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
@ -109,7 +109,7 @@ class ConsoleBuilder:
|
|||||||
templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async))
|
templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async))
|
||||||
|
|
||||||
if use_startup:
|
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))
|
templates.append(MainWithApplicationHostAndStartupTemplate(src_name, py_src_rel_path, use_async))
|
||||||
else:
|
else:
|
||||||
templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))
|
templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))
|
||||||
|
@ -113,7 +113,7 @@ class LibraryBuilder:
|
|||||||
templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async))
|
templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async))
|
||||||
|
|
||||||
if use_startup:
|
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))
|
templates.append(MainWithApplicationHostAndStartupTemplate(src_name, py_src_rel_path, use_async))
|
||||||
else:
|
else:
|
||||||
templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))
|
templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))
|
||||||
|
Loading…
Reference in New Issue
Block a user