Compare commits

...

2 Commits

Author SHA1 Message Date
57040f85f0 Changed versions 2021-11-14 12:53:09 +01:00
589ef4fd4c Added logic to generate new projects with async 2021-11-14 12:32:11 +01:00
32 changed files with 566 additions and 290 deletions

View File

@ -1,16 +1,16 @@
#!/bin/bash
if [ $1 == "-prod" ]; then
twine upload -r pip.sh-edraft.de ../dist/sh_cpl-cli/publish/setup/*
twine upload -r pip.sh-edraft.de ../dist/sh_cpl-core/publish/setup/*
twine upload -r pip.sh-edraft.de ../dist/sh_cpl-query/publish/setup/*
twine upload -r pip.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
twine upload -r pip.sh-edraft.de dist/sh_cpl-core/publish/setup/*
twine upload -r pip.sh-edraft.de dist/sh_cpl-query/publish/setup/*
elif [ $1 == "-prod" ]; then
twine upload -r pip-exp.sh-edraft.de ../dist/sh_cpl-cli/publish/setup/*
twine upload -r pip-exp.sh-edraft.de ../dist/sh_cpl-core/publish/setup/*
twine upload -r pip-.sh-edraft.de ../dist/sh_cpl-query/publish/setup/*
twine upload -r pip-exp.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
twine upload -r pip-exp.sh-edraft.de dist/sh_cpl-core/publish/setup/*
twine upload -r pip-.sh-edraft.de dist/sh_cpl-query/publish/setup/*
else
twine upload -r pip-dev.sh-edraft.de ../dist/sh_cpl-cli/publish/setup/*
twine upload -r pip-dev.sh-edraft.de ../dist/sh_cpl-core/publish/setup/*
twine upload -r pip-dev.sh-edraft.de ../dist/sh_cpl-query/publish/setup/*
twine upload -r pip-dev.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
twine upload -r pip-dev.sh-edraft.de dist/sh_cpl-core/publish/setup/*
twine upload -r pip-dev.sh-edraft.de dist/sh_cpl-query/publish/setup/*
fi

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
@ -29,4 +29,4 @@ from .main import main
from .startup import Startup
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.build'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.generate'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -5,29 +5,51 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
class ApplicationTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'application.py'
self._path = path
self._value = textwrap.dedent("""\
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
self._use_async = use_async
if self._use_async:
self._value = textwrap.dedent("""\
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
def configure(self):
pass
def main(self):
Console.write_line('Hello World')
""")
async def configure(self):
pass
async def main(self):
Console.write_line('Hello World')
""")
else:
self._value = textwrap.dedent("""\
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
def configure(self):
pass
def main(self):
Console.write_line('Hello World')
""")
@property
def name(self) -> str:

View File

@ -6,7 +6,7 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
@ -15,22 +15,44 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
import_pkg = f'{name}.'
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
from {import_pkg}startup import Startup
def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent(f"""\
import asyncio
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
from {import_pkg}startup import Startup
async def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app: Application = await app_builder.build_async()
await app.run_async()
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
from {import_pkg}startup import Startup
def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:
@ -47,7 +69,7 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
class MainWithApplicationBaseTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
@ -56,20 +78,40 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
import_pkg = f'{name}.'
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
def main():
app_builder = ApplicationBuilder(Application)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent(f"""\
import asyncio
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
async def main():
app_builder = ApplicationBuilder(Application)
app: Application = await app_builder.build_async()
await app.run_async()
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
def main():
app_builder = ApplicationBuilder(Application)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:
@ -86,7 +128,7 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
@ -95,17 +137,33 @@ class MainWithoutApplicationBaseTemplate(TemplateFileABC):
import_pkg = f'{name}.'
self._value = textwrap.dedent("""\
from cpl_core.console import Console
def main():
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent("""\
import asyncio
from cpl_core.console import Console
async def main():
Console.write_line('Hello World')
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent("""\
from cpl_core.console import Console
def main():
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:
@ -122,7 +180,7 @@ class MainWithoutApplicationBaseTemplate(TemplateFileABC):
class MainWithDependencyInjection(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
@ -131,31 +189,61 @@ class MainWithDependencyInjection(TemplateFileABC):
import_pkg = f'{name}.'
self._value = textwrap.dedent("""\
from cpl_core.configuration import Configuration, ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC
def configure_configuration() -> ConfigurationABC:
config = Configuration()
return config
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
services = ServiceCollection(config)
return services.build_service_provider()
def main():
config = configure_configuration()
provider = configure_services(config)
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent("""\
import asyncio
from cpl_core.configuration import Configuration, ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC
async def configure_configuration() -> ConfigurationABC:
config = Configuration()
return config
async def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
services = ServiceCollection(config)
return services.build_service_provider()
async def main():
config = await configure_configuration()
provider = await configure_services(config)
Console.write_line('Hello World')
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent("""\
from cpl_core.configuration import Configuration, ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC
def configure_configuration() -> ConfigurationABC:
config = Configuration()
return config
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
services = ServiceCollection(config)
return services.build_service_provider()
def main():
config = configure_configuration()
provider = configure_services(config)
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:

View File

@ -5,29 +5,51 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
class StartupTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'startup.py'
self._path = path
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._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()
""")
@property
def name(self) -> str:

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -5,29 +5,50 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
class ApplicationTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'application.py'
self._path = path
self._value = textwrap.dedent("""\
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
if use_async:
self._value = textwrap.dedent("""\
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
def configure(self):
pass
def main(self):
Console.write_line('Hello World')
""")
async def configure(self):
pass
async def main(self):
Console.write_line('Hello World')
""")
else:
self._value = textwrap.dedent("""\
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
def configure(self):
pass
def main(self):
Console.write_line('Hello World')
""")
@property
def name(self) -> str:

View File

@ -5,7 +5,7 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'main.py'
@ -15,22 +15,44 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
if name == '':
import_pkg = ''
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
from {import_pkg}startup import Startup
def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent(f"""\
import asyncio
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
from {import_pkg}startup import Startup
async def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app: Application = await app_builder.build_async()
await app.run_async()
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
from {import_pkg}startup import Startup
def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:
@ -47,7 +69,7 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
class MainWithApplicationBaseTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'main.py'
@ -57,20 +79,40 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
if name == '':
import_pkg = ''
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
def main():
app_builder = ApplicationBuilder(Application)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent(f"""\
import asyncio
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
async def main():
app_builder = ApplicationBuilder(Application)
app: Application = await app_builder.build_async()
await app.run_async()
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent(f"""\
from cpl_core.application import ApplicationBuilder
from {import_pkg}application import Application
def main():
app_builder = ApplicationBuilder(Application)
app_builder.build().run()
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:
@ -87,23 +129,39 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'main.py'
self._path = path
self._value = textwrap.dedent("""\
from cpl_core.console import Console
def main():
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent("""\
import asyncio
from cpl_core.console import Console
async def main():
Console.write_line('Hello World')
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent("""\
from cpl_core.console import Console
def main():
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:
@ -120,37 +178,67 @@ class MainWithoutApplicationBaseTemplate(TemplateFileABC):
class MainWithDependencyInjection(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'main.py'
self._path = path
self._value = textwrap.dedent("""\
from cpl_core.configuration import Configuration, ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC
def configure_configuration() -> ConfigurationABC:
config = Configuration()
return config
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
services = ServiceCollection(config)
return services.build_service_provider()
def main():
config = configure_configuration()
provider = configure_services(config)
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
if use_async:
self._value = textwrap.dedent("""\
import asyncio
from cpl_core.configuration import Configuration, ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC
async def configure_configuration() -> ConfigurationABC:
config = Configuration()
return config
async def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
services = ServiceCollection(config)
return services.build_service_provider()
async def main():
config = await configure_configuration()
provider = await configure_services(config)
Console.write_line('Hello World')
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())
""")
else:
self._value = textwrap.dedent("""\
from cpl_core.configuration import Configuration, ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC
def configure_configuration() -> ConfigurationABC:
config = Configuration()
return config
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
services = ServiceCollection(config)
return services.build_service_provider()
def main():
config = configure_configuration()
provider = configure_services(config)
Console.write_line('Hello World')
if __name__ == '__main__':
main()
""")
@property
def name(self) -> str:

View File

@ -5,29 +5,50 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
class StartupTemplate(TemplateFileABC):
def __init__(self, name: str, path: str):
def __init__(self, name: str, path: str, use_async: bool):
TemplateFileABC.__init__(self)
self._name = 'startup.py'
self._path = path
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()
""")
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()
""")
@property
def name(self) -> str:

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
@ -28,4 +28,4 @@ from .publish_service import PublishService
from .version_service import VersionService
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -46,6 +46,7 @@ class NewService(CommandABC):
self._use_application_api: bool = False
self._use_startup: bool = False
self._use_service_providing: bool = False
self._use_async: bool = False
@property
def help_message(self) -> str:
@ -177,6 +178,10 @@ class NewService(CommandABC):
result = Console.read('Do you want to use service providing? (y/n) ')
if result.lower() == 'y':
self._use_service_providing = True
result = Console.read('Do you want to use async? (y/n) ')
if result.lower() == 'y':
self._use_async = True
Console.set_foreground_color(ForegroundColorEnum.default)
@ -202,6 +207,7 @@ class NewService(CommandABC):
self._use_application_api,
self._use_startup,
self._use_service_providing,
self._use_async,
self._project.name,
self._project_json,
self._workspace
@ -231,6 +237,7 @@ class NewService(CommandABC):
self._use_application_api,
self._use_startup,
self._use_service_providing,
self._use_async,
self._project.name,
self._project_json,
self._workspace

View File

@ -52,7 +52,11 @@ class VersionService(CommandABC):
]
packages = []
for modname in cpl_packages:
module = pkgutil.find_loader(modname).load_module(modname)
module = pkgutil.find_loader(modname)
if module is None:
break
module = module.load_module(modname)
if '__version__' in dir(module):
packages.append([f'{modname}', module.__version__])

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
@ -30,4 +30,4 @@ from .workspace_settings import WorkspaceSettings
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2021",
"Minor": "10",
"Micro": "2"
"Micro": "3"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl-core>=2021.10.0.post1"
"sh_cpl-core>=2021.10.2"
],
"PythonVersion": ">=3.8",
"PythonPath": {},

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
@ -24,4 +24,4 @@ from .publisher_abc import PublisherABC
from .publisher_service import PublisherService
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.source_creator'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.10.2'
__version__ = '2021.10.3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='10', micro='2')
version_info = VersionInfo(major='2021', minor='10', micro='3')

View File

@ -59,13 +59,14 @@ class ConsoleBuilder:
@classmethod
def build(cls, project_path: str, use_application_api: bool, use_startup: bool, use_service_providing: bool,
project_name: str, project_settings: dict, workspace: Optional[WorkspaceSettings]):
use_async: bool, project_name: str, project_settings: dict, workspace: Optional[WorkspaceSettings]):
"""
Builds the console project files
:param project_path:
:param use_application_api:
:param use_startup:
:param use_service_providing:
:param use_async:
:param project_name:
:param project_settings:
:param workspace:
@ -79,7 +80,8 @@ class ConsoleBuilder:
ReadmeTemplate(),
TestsInitTemplate(),
AppsettingsTemplate(),
MainInitTemplate(project_name, os.path.join('src/', project_name_snake))
MainInitTemplate(project_name, os.path.join(
'src/', project_name_snake))
]
else:
project_path = os.path.join(
@ -103,18 +105,22 @@ class ConsoleBuilder:
src_rel_path = os.path.join('src/', src_name)
if use_application_api:
templates.append(ApplicationTemplate(src_name, src_rel_path))
templates.append(ApplicationTemplate(src_name, src_rel_path, use_async))
if use_startup:
templates.append(StartupTemplate(src_name, src_rel_path))
templates.append(MainWithApplicationHostAndStartupTemplate(src_name, src_rel_path))
templates.append(StartupTemplate(src_name, src_rel_path, use_async))
templates.append(MainWithApplicationHostAndStartupTemplate(
src_name, src_rel_path, use_async))
else:
templates.append(MainWithApplicationBaseTemplate(src_name, src_rel_path))
templates.append(MainWithApplicationBaseTemplate(
src_name, src_rel_path, use_async))
else:
if use_service_providing:
templates.append(MainWithDependencyInjection(src_name, src_rel_path))
templates.append(MainWithDependencyInjection(
src_name, src_rel_path, use_async))
else:
templates.append(MainWithoutApplicationBaseTemplate(src_name, src_rel_path))
templates.append(MainWithoutApplicationBaseTemplate(
src_name, src_rel_path, use_async))
proj_name = project_name
if workspace is not None:
@ -132,7 +138,8 @@ class ConsoleBuilder:
else:
workspace.projects[project_name] = f'src/{project_file_path}'
cls._create_workspace('cpl-workspace.json', workspace.default_project, workspace.projects)
cls._create_workspace('cpl-workspace.json',
workspace.default_project, workspace.projects)
Console.spinner(
f'Creating {project_file_path}',

View File

@ -59,7 +59,7 @@ class LibraryBuilder:
@classmethod
def build(cls, project_path: str, use_application_api: bool, use_startup: bool,
use_service_providing: bool, project_name: str, project_settings: dict,
use_async: bool, use_service_providing: bool, project_name: str, project_settings: dict,
workspace: Optional[WorkspaceSettings]):
"""
Builds the library project files
@ -67,6 +67,7 @@ class LibraryBuilder:
:param use_application_api:
:param use_startup:
:param use_service_providing:
:param use_async:
:param project_name:
:param project_settings:
:param workspace:
@ -79,7 +80,8 @@ class LibraryBuilder:
LicenseTemplate(),
ReadmeTemplate(),
TestsInitTemplate(),
NameInitTemplate(project_name, os.path.join('src/', project_name_snake)),
NameInitTemplate(project_name, os.path.join(
'src/', project_name_snake)),
AppsettingsTemplate()
]
else:
@ -108,14 +110,18 @@ class LibraryBuilder:
if use_startup:
templates.append(StartupTemplate(src_name, src_rel_path))
templates.append(MainWithApplicationHostAndStartupTemplate(src_name, src_rel_path))
templates.append(MainWithApplicationHostAndStartupTemplate(
src_name, src_rel_path))
else:
templates.append(MainWithApplicationBaseTemplate(src_name, src_rel_path))
templates.append(MainWithApplicationBaseTemplate(
src_name, src_rel_path))
else:
if use_service_providing:
templates.append(MainWithDependencyInjection(src_name, src_rel_path))
templates.append(MainWithDependencyInjection(
src_name, src_rel_path))
else:
templates.append(MainWithoutApplicationBaseTemplate(src_name, src_rel_path))
templates.append(MainWithoutApplicationBaseTemplate(
src_name, src_rel_path))
proj_name = project_name
if workspace is not None:
@ -133,7 +139,8 @@ class LibraryBuilder:
else:
workspace.projects[project_name] = f'src/{project_file_path}'
cls._create_workspace('cpl-workspace.json', workspace.default_project, workspace.projects)
cls._create_workspace('cpl-workspace.json',
workspace.default_project, workspace.projects)
Console.spinner(
f'Creating {project_file_path}',

View File

@ -35,17 +35,6 @@ class ApplicationABC(ABC):
except KeyboardInterrupt:
Console.close()
def run(self):
r"""Entry point
Called by custom Application.main
"""
try:
self.configure()
self.main()
except KeyboardInterrupt:
Console.close()
async def run_async(self):
r"""Entry point