Compare commits
43 Commits
2021.4.2
...
b91544a0da
Author | SHA1 | Date | |
---|---|---|---|
b91544a0da | |||
caca34168e | |||
18b8ac589d | |||
d85e628784 | |||
1e150cf10c | |||
9b0f0b7559 | |||
cc118b5030 | |||
3e7ff78861 | |||
448d538d21 | |||
d368161eb3 | |||
eef8488ca2 | |||
b22d04b145 | |||
6579e54c2b | |||
88c0153ca2 | |||
f28c6ab309 | |||
976041f812 | |||
7693dd462f | |||
df5e61cf98 | |||
df87d08be3 | |||
33cb35e26f | |||
18b2cd8f2f | |||
7ab2a881e8 | |||
960de880ee | |||
c0d8904782 | |||
b6d508526a | |||
31307485f0 | |||
612c3583f1 | |||
6cdd3376f1 | |||
b947789779 | |||
0da83935fc | |||
3428c70b69 | |||
3d511ff727 | |||
cf2f293290 | |||
c39601a35d | |||
5f36e0a43e | |||
31fe1c5cd7 | |||
0cdecd893a | |||
260fe06be8 | |||
8ddfd35a82 | |||
099bae3d7c | |||
9758e1fae2 | |||
211143d6ab | |||
70b49a098a |
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
MIT License Copyright (c) <year> <copyright holders>
|
MIT License Copyright (c) 2020 - 2021 sh-edraft.de
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
101
README.md
101
README.md
@@ -1,2 +1,101 @@
|
|||||||
# sh_common_py_lib
|
<h1 align="center">CPL - Common python library</h1>
|
||||||
|
|
||||||
|
<!-- Summary -->
|
||||||
|
<p align="center">
|
||||||
|
<!-- <img src="" alt="cpl-logo" width="120px" height="120px"/> -->
|
||||||
|
<br>
|
||||||
|
<i>
|
||||||
|
CPL is a development platform for python server applications
|
||||||
|
<br>using Python.</i>
|
||||||
|
<br>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
<!-- TABLE OF CONTENTS -->
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
<a href="#getting-started">Getting Started</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#prerequisites">Prerequisites</a></li>
|
||||||
|
<li><a href="#installation">Installation</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a href="#roadmap">Roadmap</a></li>
|
||||||
|
<li><a href="#contributing">Contributing</a></li>
|
||||||
|
<li><a href="#license">License</a></li>
|
||||||
|
<li><a href="#contact">Contact</a></li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- GETTING STARTED -->
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
[Get started with CPL][quickstart].
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- Install [python] which includes [Pip installs packages][pip]
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
Install the cpl package
|
||||||
|
```sh
|
||||||
|
pip install sh_cpl --extra-index-url https://pip.sh-edraft.de
|
||||||
|
```
|
||||||
|
|
||||||
|
Create workspace:
|
||||||
|
```sh
|
||||||
|
cpl new <console|library> <PROJECT NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the application:
|
||||||
|
```sh
|
||||||
|
cd <PROJECT NAME>
|
||||||
|
cpl start
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ROADMAP -->
|
||||||
|
## Roadmap
|
||||||
|
|
||||||
|
See the [open issues](https://git.sh-edraft.de/sh-edraft.de/sh_common_py_lib/issues) for a list of proposed features (and known issues).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- CONTRIBUTING -->
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
### Contributing Guidelines
|
||||||
|
|
||||||
|
Read through our [contributing guidelines][contributing] to learn about our submission process, coding rules and more.
|
||||||
|
|
||||||
|
### Want to Help?
|
||||||
|
|
||||||
|
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for [contributing][contributing].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- LICENSE -->
|
||||||
|
## License
|
||||||
|
|
||||||
|
Distributed under the MIT License. See [LICENSE] for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- CONTACT -->
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
Sven Heidemann - sven.heidemann@sh-edraft.de
|
||||||
|
|
||||||
|
Project link: [https://git.sh-edraft.de/sh-edraft.de/sh_common_py_lib](https://git.sh-edraft.de/sh-edraft.de/sh_common_py_lib)
|
||||||
|
|
||||||
|
<!-- External LINKS -->
|
||||||
|
[pip_url]: https://pip.sh-edraft.de
|
||||||
|
[python]: https://www.python.org/
|
||||||
|
[pip]: https://pypi.org/project/pip/
|
||||||
|
|
||||||
|
<!-- Internal LINKS -->
|
||||||
|
[project]: https://git.sh-edraft.de/sh-edraft.de/sh_common_py_lib
|
||||||
|
[quickstart]: https://git.sh-edraft.de/sh-edraft.de/sh_common_py_lib/wiki/quickstart
|
||||||
|
[contributing]: https://git.sh-edraft.de/sh-edraft.de/sh_common_py_lib/wiki/contributing
|
||||||
|
[license]: LICENSE
|
||||||
|
7
cpl.json
7
cpl.json
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2021",
|
"Major": "2021",
|
||||||
"Minor": "04",
|
"Minor": "04",
|
||||||
"Micro": "02"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
"packaging==20.9",
|
"packaging==20.9",
|
||||||
"pyfiglet==0.8.post1",
|
"pyfiglet==0.8.post1",
|
||||||
"pynput==1.7.3",
|
"pynput==1.7.3",
|
||||||
"SQLAlchemy==1.4.0",
|
"SQLAlchemy==1.4.3",
|
||||||
"setuptools==54.1.2",
|
"setuptools==54.2.0",
|
||||||
"tabulate==0.8.9",
|
"tabulate==0.8.9",
|
||||||
"termcolor==1.1.0",
|
"termcolor==1.1.0",
|
||||||
"watchdog==2.0.2",
|
"watchdog==2.0.2",
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "library",
|
||||||
"SourcePath": "src",
|
"SourcePath": "src",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "cpl_cli.main",
|
"Main": "cpl_cli.main",
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'sh_cpl.cpl'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.application'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -26,4 +26,4 @@ from .application_builder_abc import ApplicationBuilderABC
|
|||||||
from .startup_abc import StartupABC
|
from .startup_abc import StartupABC
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.configuration'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -27,4 +27,4 @@ from .configuration_variable_name_enum import ConfigurationVariableNameEnum
|
|||||||
from .console_argument import ConsoleArgument
|
from .console_argument import ConsoleArgument
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.console'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -27,4 +27,4 @@ from .foreground_color_enum import ForegroundColorEnum
|
|||||||
from .spinner_thread import SpinnerThread
|
from .spinner_thread import SpinnerThread
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.database'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -25,4 +25,4 @@ from .database_settings import DatabaseSettings
|
|||||||
from .database_settings_name_enum import DatabaseSettingsNameEnum
|
from .database_settings_name_enum import DatabaseSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.database.connection'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@ from .database_connection import DatabaseConnection
|
|||||||
from .database_connection_abc import DatabaseConnectionABC
|
from .database_connection_abc import DatabaseConnectionABC
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.database.context'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@ from .database_context import DatabaseContext
|
|||||||
from .database_context_abc import DatabaseContextABC
|
from .database_context_abc import DatabaseContextABC
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -30,6 +30,9 @@ class DatabaseContext(DatabaseContextABC):
|
|||||||
self._db.connect(connection_string)
|
self._db.connect(connection_string)
|
||||||
self._create_tables()
|
self._create_tables()
|
||||||
|
|
||||||
|
def save_changes(self):
|
||||||
|
self._db.session.commit()
|
||||||
|
|
||||||
def _create_tables(self):
|
def _create_tables(self):
|
||||||
try:
|
try:
|
||||||
for subclass in DatabaseModel.__subclasses__():
|
for subclass in DatabaseModel.__subclasses__():
|
||||||
|
@@ -27,6 +27,12 @@ class DatabaseContextABC(ABC):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def save_changes(self):
|
||||||
|
"""
|
||||||
|
Saves changes of the database
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def _create_tables(self):
|
def _create_tables(self):
|
||||||
"""
|
"""
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.dependency_injection'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -28,4 +28,4 @@ from .service_provider import ServiceProvider
|
|||||||
from .service_provider_abc import ServiceProviderABC
|
from .service_provider_abc import ServiceProviderABC
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -8,6 +8,8 @@ from cpl.dependency_injection.service_collection_abc import ServiceCollectionABC
|
|||||||
from cpl.dependency_injection.service_descriptor import ServiceDescriptor
|
from cpl.dependency_injection.service_descriptor import ServiceDescriptor
|
||||||
from cpl.dependency_injection.service_lifetime_enum import ServiceLifetimeEnum
|
from cpl.dependency_injection.service_lifetime_enum import ServiceLifetimeEnum
|
||||||
from cpl.dependency_injection.service_provider import ServiceProvider
|
from cpl.dependency_injection.service_provider import ServiceProvider
|
||||||
|
from cpl.logging.logger_service import Logger
|
||||||
|
from cpl.logging.logger_abc import LoggerABC
|
||||||
from cpl.utils.credential_manager import CredentialManager
|
from cpl.utils.credential_manager import CredentialManager
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +41,9 @@ class ServiceCollection(ServiceCollectionABC):
|
|||||||
self._database_context = db_context_type(db_settings)
|
self._database_context = db_context_type(db_settings)
|
||||||
self._database_context.connect(CredentialManager.build_string(db_settings.connection_string, db_settings.credentials))
|
self._database_context.connect(CredentialManager.build_string(db_settings.connection_string, db_settings.credentials))
|
||||||
|
|
||||||
|
def add_logging(self):
|
||||||
|
self.add_singleton(LoggerABC, Logger)
|
||||||
|
|
||||||
def add_singleton(self, service_type: Union[type, object], service: Union[type, object] = None):
|
def add_singleton(self, service_type: Union[type, object], service: Union[type, object] = None):
|
||||||
impl = None
|
impl = None
|
||||||
if service is not None:
|
if service is not None:
|
||||||
|
@@ -26,6 +26,13 @@ class ServiceCollectionABC(ABC):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def add_logging(self):
|
||||||
|
"""
|
||||||
|
Adds the CPL internal logger
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_transient(self, service_type: Type, service: Callable = None):
|
def add_transient(self, service_type: Type, service: Callable = None):
|
||||||
"""
|
"""
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.environment'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -25,4 +25,4 @@ from .environment_name_enum import EnvironmentNameEnum
|
|||||||
from .application_environment import ApplicationEnvironment
|
from .application_environment import ApplicationEnvironment
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.logging'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -27,4 +27,4 @@ from .logging_settings import LoggingSettings
|
|||||||
from .logging_settings_name_enum import LoggingSettingsNameEnum
|
from .logging_settings_name_enum import LoggingSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.mailing'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -27,4 +27,4 @@ from .email_client_settings import EMailClientSettings
|
|||||||
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
|
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.time'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@ from .time_format_settings import TimeFormatSettings
|
|||||||
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
|
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl.utils'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -25,4 +25,4 @@ from .string import String
|
|||||||
from .pip import Pip
|
from .pip import Pip
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'sh_cpl.cpl_cli'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -29,4 +29,4 @@ from .main import main
|
|||||||
from .startup import Startup
|
from .startup import Startup
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"CLI": {
|
"CLI": {
|
||||||
"PipPath": "https://pip-dev.sh-edraft.de"
|
"PipPath": "https://pip.sh-edraft.de"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -28,4 +28,4 @@ from .publish_service import PublishService
|
|||||||
from .version_service import VersionService
|
from .version_service import VersionService
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -6,6 +6,7 @@ from cpl.console.foreground_color_enum import ForegroundColorEnum
|
|||||||
from cpl.console.console import Console
|
from cpl.console.console import Console
|
||||||
from cpl.utils.string import String
|
from cpl.utils.string import String
|
||||||
from cpl_cli.command_abc import CommandABC
|
from cpl_cli.command_abc import CommandABC
|
||||||
|
from cpl_cli.templates.generate.init_template import InitTemplate
|
||||||
from cpl_cli.templates.generate.abc_template import ABCTemplate
|
from cpl_cli.templates.generate.abc_template import ABCTemplate
|
||||||
from cpl_cli.templates.generate.class_template import ClassTemplate
|
from cpl_cli.templates.generate.class_template import ClassTemplate
|
||||||
from cpl_cli.templates.generate.configmodel_template import ConfigModelTemplate
|
from cpl_cli.templates.generate.configmodel_template import ConfigModelTemplate
|
||||||
@@ -106,6 +107,19 @@ class GenerateService(CommandABC):
|
|||||||
file_path = os.path.join(self._env.working_directory, template.path, template.name)
|
file_path = os.path.join(self._env.working_directory, template.path, template.name)
|
||||||
if not os.path.isdir(os.path.dirname(file_path)):
|
if not os.path.isdir(os.path.dirname(file_path)):
|
||||||
os.makedirs(os.path.dirname(file_path))
|
os.makedirs(os.path.dirname(file_path))
|
||||||
|
directory = ''
|
||||||
|
for subdir in template.path.split('/'):
|
||||||
|
directory = os.path.join(directory, subdir)
|
||||||
|
if subdir != 'src':
|
||||||
|
file = InitTemplate(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
|
||||||
|
Console.spinner(
|
||||||
|
f'Creating {os.path.abspath(directory)}/{file.name}',
|
||||||
|
self._create_file,
|
||||||
|
os.path.join(os.path.abspath(directory), file.name),
|
||||||
|
file.value,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
|
)
|
||||||
|
|
||||||
if os.path.isfile(file_path):
|
if os.path.isfile(file_path):
|
||||||
Console.error(f'{String.first_to_upper(schematic)} already exists!')
|
Console.error(f'{String.first_to_upper(schematic)} already exists!')
|
||||||
|
@@ -24,7 +24,7 @@ class HelpService(CommandABC):
|
|||||||
['help (h|H)', 'Lists available command and their short descriptions.'],
|
['help (h|H)', 'Lists available command and their short descriptions.'],
|
||||||
['install (i|I)', 'With argument installs packages to project, without argument installs project dependencies.'],
|
['install (i|I)', 'With argument installs packages to project, without argument installs project dependencies.'],
|
||||||
['new (n|N)', 'Creates new CPL project.'],
|
['new (n|N)', 'Creates new CPL project.'],
|
||||||
['publish (p|P)', 'Prepares files for publish into an output directory named dist/ at the given output path and executes setup_template.py. Must be executed from within a workspace directory.'],
|
['publish (p|P)', 'Prepares files for publish into an output directory named dist/ at the given output path and executes setup.py. Must be executed from within a library workspace directory.'],
|
||||||
['start (s|S)', 'Starts CPL project, restarting on file changes'],
|
['start (s|S)', 'Starts CPL project, restarting on file changes'],
|
||||||
['uninstall (ui|UI)', 'Uninstalls packages from project.'],
|
['uninstall (ui|UI)', 'Uninstalls packages from project.'],
|
||||||
['update (u|u)', 'Update CPL and project dependencies.'],
|
['update (u|u)', 'Update CPL and project dependencies.'],
|
||||||
|
@@ -10,20 +10,16 @@ import cpl
|
|||||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||||
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||||
from cpl.console.console import Console
|
from cpl.console.console import Console
|
||||||
|
from cpl.utils.string import String
|
||||||
from cpl_cli.command_abc import CommandABC
|
from cpl_cli.command_abc import CommandABC
|
||||||
from cpl_cli.configuration.build_settings import BuildSettings
|
from cpl_cli.configuration.build_settings import BuildSettings
|
||||||
from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum
|
from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum
|
||||||
from cpl_cli.configuration.project_settings import ProjectSettings
|
from cpl_cli.configuration.project_settings import ProjectSettings
|
||||||
from cpl_cli.configuration.project_settings_name_enum import ProjectSettingsNameEnum
|
from cpl_cli.configuration.project_settings_name_enum import ProjectSettingsNameEnum
|
||||||
|
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
|
||||||
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
|
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
|
||||||
from cpl_cli.templates.new.console.license import LicenseTemplate
|
from cpl_cli.source_creator.console_builder import ConsoleBuilder
|
||||||
from cpl_cli.templates.new.console.readme_py import ReadmeTemplate
|
from cpl_cli.source_creator.library_builder import LibraryBuilder
|
||||||
from cpl_cli.templates.new.console.src.application import ApplicationTemplate
|
|
||||||
from cpl_cli.templates.new.console.src.main import MainWithApplicationHostAndStartupTemplate, \
|
|
||||||
MainWithoutApplicationBaseTemplate, MainWithApplicationBaseTemplate, MainWithDependencyInjection
|
|
||||||
from cpl_cli.templates.new.console.src.startup import StartupTemplate
|
|
||||||
from cpl_cli.templates.new.console.src.tests.init import TestsInitTemplate
|
|
||||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
|
||||||
|
|
||||||
|
|
||||||
class NewService(CommandABC):
|
class NewService(CommandABC):
|
||||||
@@ -95,10 +91,15 @@ class NewService(CommandABC):
|
|||||||
self._project.from_dict(self._project_dict)
|
self._project.from_dict(self._project_dict)
|
||||||
|
|
||||||
def _create_build_settings(self):
|
def _create_build_settings(self):
|
||||||
|
main = f'{String.convert_to_snake_case(self._project.name)}.main'
|
||||||
|
if self._command == ProjectTypeEnum.library.value:
|
||||||
|
main = f'{String.convert_to_snake_case(self._project.name)}_cli.main'
|
||||||
|
|
||||||
self._build_dict = {
|
self._build_dict = {
|
||||||
|
BuildSettingsNameEnum.project_type.value: self._command,
|
||||||
BuildSettingsNameEnum.source_path.value: 'src',
|
BuildSettingsNameEnum.source_path.value: 'src',
|
||||||
BuildSettingsNameEnum.output_path.value: 'dist',
|
BuildSettingsNameEnum.output_path.value: 'dist',
|
||||||
BuildSettingsNameEnum.main.value: 'main',
|
BuildSettingsNameEnum.main.value: main,
|
||||||
BuildSettingsNameEnum.entry_point.value: self._project.name,
|
BuildSettingsNameEnum.entry_point.value: self._project.name,
|
||||||
BuildSettingsNameEnum.include_package_data.value: False,
|
BuildSettingsNameEnum.include_package_data.value: False,
|
||||||
BuildSettingsNameEnum.included.value: [],
|
BuildSettingsNameEnum.included.value: [],
|
||||||
@@ -142,78 +143,16 @@ class NewService(CommandABC):
|
|||||||
if result.lower() == 'y':
|
if result.lower() == 'y':
|
||||||
self._use_application_api = True
|
self._use_application_api = True
|
||||||
|
|
||||||
|
result = Console.read('Do you want to use startup? (y/n) ')
|
||||||
|
if result.lower() == 'y':
|
||||||
|
self._use_startup = True
|
||||||
|
else:
|
||||||
result = Console.read('Do you want to use service providing? (y/n) ')
|
result = Console.read('Do you want to use service providing? (y/n) ')
|
||||||
if result.lower() == 'y':
|
if result.lower() == 'y':
|
||||||
self._use_service_providing = True
|
self._use_service_providing = True
|
||||||
|
|
||||||
if self._use_application_api:
|
|
||||||
result = Console.read('Do you want to use startup? (y/n) ')
|
|
||||||
if result.lower() == 'y':
|
|
||||||
self._use_startup = True
|
|
||||||
|
|
||||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||||
|
|
||||||
def _build_project_dir(self, project_path: str):
|
|
||||||
"""
|
|
||||||
Builds the project files
|
|
||||||
:param project_path:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if not os.path.isdir(project_path):
|
|
||||||
os.makedirs(project_path)
|
|
||||||
|
|
||||||
with open(os.path.join(project_path, 'cpl.json'), 'w') as project_json:
|
|
||||||
project_json.write(json.dumps(self._project_json, indent=2))
|
|
||||||
project_json.close()
|
|
||||||
|
|
||||||
templates: list[TemplateFileABC] = [
|
|
||||||
LicenseTemplate(),
|
|
||||||
ReadmeTemplate(),
|
|
||||||
TestsInitTemplate()
|
|
||||||
]
|
|
||||||
|
|
||||||
if self._use_application_api:
|
|
||||||
templates.append(ApplicationTemplate())
|
|
||||||
|
|
||||||
if self._use_startup:
|
|
||||||
templates.append(StartupTemplate())
|
|
||||||
templates.append(MainWithApplicationHostAndStartupTemplate())
|
|
||||||
else:
|
|
||||||
templates.append(MainWithApplicationBaseTemplate())
|
|
||||||
else:
|
|
||||||
if self._use_service_providing:
|
|
||||||
templates.append(MainWithDependencyInjection())
|
|
||||||
else:
|
|
||||||
templates.append(MainWithoutApplicationBaseTemplate())
|
|
||||||
|
|
||||||
for template in templates:
|
|
||||||
Console.spinner(
|
|
||||||
f'Creating {self._project.name}/{template.path}{template.name}',
|
|
||||||
self._create_template,
|
|
||||||
project_path,
|
|
||||||
template,
|
|
||||||
text_foreground_color=ForegroundColorEnum.green,
|
|
||||||
spinner_foreground_color=ForegroundColorEnum.cyan
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _create_template(project_path: str, template: TemplateFileABC):
|
|
||||||
"""
|
|
||||||
Creates template
|
|
||||||
:param project_path:
|
|
||||||
:param template:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
file_path = os.path.join(project_path, template.path, template.name)
|
|
||||||
file_rel_path = os.path.join(project_path, template.path)
|
|
||||||
|
|
||||||
if not os.path.isdir(file_rel_path):
|
|
||||||
os.makedirs(file_rel_path)
|
|
||||||
|
|
||||||
with open(file_path, 'w') as license_file:
|
|
||||||
license_file.write(template.value)
|
|
||||||
license_file.close()
|
|
||||||
|
|
||||||
def _console(self, args: list[str]):
|
def _console(self, args: list[str]):
|
||||||
"""
|
"""
|
||||||
Generates new console project
|
Generates new console project
|
||||||
@@ -231,7 +170,42 @@ class NewService(CommandABC):
|
|||||||
|
|
||||||
self._get_project_information()
|
self._get_project_information()
|
||||||
try:
|
try:
|
||||||
self._build_project_dir(path)
|
ConsoleBuilder.build(
|
||||||
|
path,
|
||||||
|
self._use_application_api,
|
||||||
|
self._use_startup,
|
||||||
|
self._use_service_providing,
|
||||||
|
self._project.name,
|
||||||
|
self._project_json
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
Console.error('Could not create project', str(e))
|
||||||
|
|
||||||
|
def _library(self, args: list[str]):
|
||||||
|
"""
|
||||||
|
Generates new library project
|
||||||
|
:param args:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
name = self._config.get_configuration(self._command)
|
||||||
|
|
||||||
|
self._create_project_settings(name)
|
||||||
|
self._create_build_settings()
|
||||||
|
self._create_project_json()
|
||||||
|
path = self._get_project_path()
|
||||||
|
if path is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._get_project_information()
|
||||||
|
try:
|
||||||
|
LibraryBuilder.build(
|
||||||
|
path,
|
||||||
|
self._use_application_api,
|
||||||
|
self._use_startup,
|
||||||
|
self._use_service_providing,
|
||||||
|
self._project.name,
|
||||||
|
self._project_json
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error('Could not create project', str(e))
|
Console.error('Could not create project', str(e))
|
||||||
|
|
||||||
@@ -243,12 +217,15 @@ class NewService(CommandABC):
|
|||||||
"""
|
"""
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
self._help('Usage: cpl new <schematic> [options]')
|
self._help('Usage: cpl new <schematic> [options]')
|
||||||
exit()
|
return
|
||||||
|
|
||||||
self._command = args[0]
|
self._command = str(args[0]).lower()
|
||||||
if self._command == 'console':
|
if self._command == ProjectTypeEnum.console.value:
|
||||||
self._console(args)
|
self._console(args)
|
||||||
|
|
||||||
|
elif self._command == ProjectTypeEnum.library.value:
|
||||||
|
self._library(args)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._help('Usage: cpl new <schematic> [options]')
|
self._help('Usage: cpl new <schematic> [options]')
|
||||||
exit()
|
return
|
||||||
|
@@ -34,16 +34,27 @@ class UpdateService(CommandABC):
|
|||||||
self._project_settings = project_settings
|
self._project_settings = project_settings
|
||||||
self._cli_settings = cli_settings
|
self._cli_settings = cli_settings
|
||||||
|
|
||||||
def _update_project_dependencies(self):
|
def _collect_project_dependencies(self) -> list[tuple]:
|
||||||
"""
|
"""
|
||||||
Updates project dependencies
|
Collects project dependencies
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
dependencies = []
|
||||||
for package in self._project_settings.dependencies:
|
for package in self._project_settings.dependencies:
|
||||||
name = package
|
name = package
|
||||||
if '==' in package:
|
if '==' in package:
|
||||||
name = package.split('==')[0]
|
name = package.split('==')[0]
|
||||||
|
|
||||||
|
dependencies.append((package, name))
|
||||||
|
|
||||||
|
return dependencies
|
||||||
|
|
||||||
|
def _update_project_dependencies(self, dependencies):
|
||||||
|
"""
|
||||||
|
Updates project dependencies
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
for package, name in dependencies:
|
||||||
Pip.install(
|
Pip.install(
|
||||||
name,
|
name,
|
||||||
'--upgrade',
|
'--upgrade',
|
||||||
@@ -66,11 +77,18 @@ class UpdateService(CommandABC):
|
|||||||
Checks project dependencies for updates
|
Checks project dependencies for updates
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
Console.spinner(
|
dependencies = Console.spinner(
|
||||||
'Collecting installed dependencies', self._update_project_dependencies,
|
'Collecting installed dependencies', self._collect_project_dependencies,
|
||||||
text_foreground_color=ForegroundColorEnum.green,
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
spinner_foreground_color=ForegroundColorEnum.cyan
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Console.spinner(
|
||||||
|
'Updating installed dependencies', self._update_project_dependencies, dependencies,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
|
)
|
||||||
|
|
||||||
Console.write_line(f'Found {len(self._project_settings.dependencies)} dependencies.')
|
Console.write_line(f'Found {len(self._project_settings.dependencies)} dependencies.')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -28,4 +28,4 @@ from .version_settings import VersionSettings
|
|||||||
from .version_settings_name_enum import VersionSettingsNameEnum
|
from .version_settings_name_enum import VersionSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@@ -5,6 +6,7 @@ from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
|||||||
from cpl.console.console import Console
|
from cpl.console.console import Console
|
||||||
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||||
from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum
|
from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum
|
||||||
|
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
|
||||||
|
|
||||||
|
|
||||||
class BuildSettings(ConfigurationModelABC):
|
class BuildSettings(ConfigurationModelABC):
|
||||||
@@ -12,6 +14,7 @@ class BuildSettings(ConfigurationModelABC):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
ConfigurationModelABC.__init__(self)
|
ConfigurationModelABC.__init__(self)
|
||||||
|
|
||||||
|
self._project_type: Optional[ProjectTypeEnum] = None
|
||||||
self._source_path: Optional[str] = None
|
self._source_path: Optional[str] = None
|
||||||
self._output_path: Optional[str] = None
|
self._output_path: Optional[str] = None
|
||||||
self._main: Optional[str] = None
|
self._main: Optional[str] = None
|
||||||
@@ -21,6 +24,10 @@ class BuildSettings(ConfigurationModelABC):
|
|||||||
self._excluded: Optional[list[str]] = None
|
self._excluded: Optional[list[str]] = None
|
||||||
self._package_data: Optional[dict[str, list[str]]] = None
|
self._package_data: Optional[dict[str, list[str]]] = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def project_type(self):
|
||||||
|
return self._project_type
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_path(self) -> str:
|
def source_path(self) -> str:
|
||||||
return self._source_path
|
return self._source_path
|
||||||
@@ -55,6 +62,7 @@ class BuildSettings(ConfigurationModelABC):
|
|||||||
|
|
||||||
def from_dict(self, settings: dict):
|
def from_dict(self, settings: dict):
|
||||||
try:
|
try:
|
||||||
|
self._project_type = settings[BuildSettingsNameEnum.project_type.value]
|
||||||
self._source_path = settings[BuildSettingsNameEnum.source_path.value]
|
self._source_path = settings[BuildSettingsNameEnum.source_path.value]
|
||||||
self._output_path = settings[BuildSettingsNameEnum.output_path.value]
|
self._output_path = settings[BuildSettingsNameEnum.output_path.value]
|
||||||
self._include_package_data = bool(settings[BuildSettingsNameEnum.include_package_data.value])
|
self._include_package_data = bool(settings[BuildSettingsNameEnum.include_package_data.value])
|
||||||
@@ -63,6 +71,25 @@ class BuildSettings(ConfigurationModelABC):
|
|||||||
self._included = settings[BuildSettingsNameEnum.included.value]
|
self._included = settings[BuildSettingsNameEnum.included.value]
|
||||||
self._excluded = settings[BuildSettingsNameEnum.excluded.value]
|
self._excluded = settings[BuildSettingsNameEnum.excluded.value]
|
||||||
self._package_data = settings[BuildSettingsNameEnum.package_data.value]
|
self._package_data = settings[BuildSettingsNameEnum.package_data.value]
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
self._source_path = str(self._source_path).replace('/', '\\')
|
||||||
|
self._output_path = str(self._output_path).replace('/', '\\')
|
||||||
|
|
||||||
|
# windows paths for excluded files
|
||||||
|
excluded = []
|
||||||
|
for ex in self._excluded:
|
||||||
|
excluded.append(str(ex).replace('/', '\\'))
|
||||||
|
|
||||||
|
self._excluded = excluded
|
||||||
|
|
||||||
|
# windows paths for included files
|
||||||
|
included = []
|
||||||
|
for inc in self._included:
|
||||||
|
included.append(str(inc).replace('/', '\\'))
|
||||||
|
|
||||||
|
self._included = included
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.set_foreground_color(ForegroundColorEnum.red)
|
Console.set_foreground_color(ForegroundColorEnum.red)
|
||||||
Console.write_line(
|
Console.write_line(
|
||||||
|
@@ -3,6 +3,7 @@ from enum import Enum
|
|||||||
|
|
||||||
class BuildSettingsNameEnum(Enum):
|
class BuildSettingsNameEnum(Enum):
|
||||||
|
|
||||||
|
project_type = 'ProjectType'
|
||||||
source_path = 'SourcePath'
|
source_path = 'SourcePath'
|
||||||
output_path = 'OutputPath'
|
output_path = 'OutputPath'
|
||||||
main = 'Main'
|
main = 'Main'
|
||||||
|
7
src/cpl_cli/configuration/project_type_enum.py
Normal file
7
src/cpl_cli/configuration/project_type_enum.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class ProjectTypeEnum(Enum):
|
||||||
|
|
||||||
|
console = 'console'
|
||||||
|
library = 'library'
|
@@ -34,6 +34,7 @@ class SettingsHelper:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_build_settings_dict(build: BuildSettings) -> dict:
|
def get_build_settings_dict(build: BuildSettings) -> dict:
|
||||||
return {
|
return {
|
||||||
|
BuildSettingsNameEnum.project_type.value: build.project_type,
|
||||||
BuildSettingsNameEnum.source_path.value: build.source_path,
|
BuildSettingsNameEnum.source_path.value: build.source_path,
|
||||||
BuildSettingsNameEnum.output_path.value: build.output_path,
|
BuildSettingsNameEnum.output_path.value: build.output_path,
|
||||||
BuildSettingsNameEnum.main.value: build.main,
|
BuildSettingsNameEnum.main.value: build.main,
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from abc import ABC
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
|
||||||
import psutil as psutil
|
import psutil as psutil
|
||||||
@@ -13,7 +12,7 @@ from cpl_cli.configuration.build_settings import BuildSettings
|
|||||||
from cpl_cli.live_server.live_server_thread import LiveServerThread
|
from cpl_cli.live_server.live_server_thread import LiveServerThread
|
||||||
|
|
||||||
|
|
||||||
class LiveServerService(ABC, FileSystemEventHandler):
|
class LiveServerService(FileSystemEventHandler):
|
||||||
|
|
||||||
def __init__(self, env: ApplicationEnvironmentABC, build_settings: BuildSettings):
|
def __init__(self, env: ApplicationEnvironmentABC, build_settings: BuildSettings):
|
||||||
"""
|
"""
|
||||||
@@ -21,7 +20,6 @@ class LiveServerService(ABC, FileSystemEventHandler):
|
|||||||
:param env:
|
:param env:
|
||||||
:param build_settings:
|
:param build_settings:
|
||||||
"""
|
"""
|
||||||
ABC.__init__(self)
|
|
||||||
FileSystemEventHandler.__init__(self)
|
FileSystemEventHandler.__init__(self)
|
||||||
|
|
||||||
self._env = env
|
self._env = env
|
||||||
@@ -72,7 +70,7 @@ class LiveServerService(ABC, FileSystemEventHandler):
|
|||||||
|
|
||||||
def _start(self):
|
def _start(self):
|
||||||
self._start_observer()
|
self._start_observer()
|
||||||
self._ls_thread = LiveServerThread(self._src_dir)
|
self._ls_thread = LiveServerThread(self._src_dir, self._build_settings)
|
||||||
self._ls_thread.start()
|
self._ls_thread.start()
|
||||||
self._ls_thread.join()
|
self._ls_thread.join()
|
||||||
Console.close()
|
Console.close()
|
||||||
|
@@ -6,11 +6,12 @@ from datetime import datetime
|
|||||||
|
|
||||||
from cpl.console.console import Console
|
from cpl.console.console import Console
|
||||||
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||||
|
from cpl_cli.configuration import BuildSettings
|
||||||
|
|
||||||
|
|
||||||
class LiveServerThread(threading.Thread):
|
class LiveServerThread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, path: str):
|
def __init__(self, path: str, build_settings: BuildSettings):
|
||||||
"""
|
"""
|
||||||
Thread to start the CPL project for the live development server
|
Thread to start the CPL project for the live development server
|
||||||
:param path:
|
:param path:
|
||||||
@@ -18,6 +19,8 @@ class LiveServerThread(threading.Thread):
|
|||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
|
self._build_settings = build_settings
|
||||||
|
|
||||||
self._main = ''
|
self._main = ''
|
||||||
self._command = []
|
self._command = []
|
||||||
|
|
||||||
@@ -34,7 +37,8 @@ class LiveServerThread(threading.Thread):
|
|||||||
Starts the CPL project
|
Starts the CPL project
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self._main = os.path.join(self._path, 'main.py')
|
main = self._build_settings.main.replace('.', '/')
|
||||||
|
self._main = os.path.join(self._path, f'{main}.py')
|
||||||
if not os.path.isfile(self._main):
|
if not os.path.isfile(self._main):
|
||||||
Console.error('Entry point main.py not found')
|
Console.error('Entry point main.py not found')
|
||||||
return
|
return
|
||||||
@@ -46,5 +50,13 @@ class LiveServerThread(threading.Thread):
|
|||||||
Console.write_line(f'Started at {now.strftime("%Y-%m-%d %H:%M:%S")}\n\n')
|
Console.write_line(f'Started at {now.strftime("%Y-%m-%d %H:%M:%S")}\n\n')
|
||||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||||
|
|
||||||
|
env_vars = os.environ
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)};' \
|
||||||
|
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
|
||||||
|
else:
|
||||||
|
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)}:' \
|
||||||
|
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
|
||||||
|
|
||||||
self._command = [sys.executable, self._main, ''.join(sys.argv[2:])]
|
self._command = [sys.executable, self._main, ''.join(sys.argv[2:])]
|
||||||
subprocess.run(self._command)
|
subprocess.run(self._command, env=env_vars)
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@ from .publisher_abc import PublisherABC
|
|||||||
from .publisher_service import PublisherService
|
from .publisher_service import PublisherService
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import importlib
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
from string import Template as stringTemplate
|
from string import Template as stringTemplate
|
||||||
|
|
||||||
import setuptools
|
import setuptools
|
||||||
@@ -39,25 +39,30 @@ class PublisherService(PublisherABC):
|
|||||||
self._included_dirs: list[str] = []
|
self._included_dirs: list[str] = []
|
||||||
self._distributed_files: list[str] = []
|
self._distributed_files: list[str] = []
|
||||||
|
|
||||||
|
self._path_mark = '/'
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
self._path_mark = '\\'
|
||||||
|
|
||||||
|
self._src_path_part = f'src{self._path_mark}'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_path(self) -> str:
|
def source_path(self) -> str:
|
||||||
return ''
|
return self._source_path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dist_path(self) -> str:
|
def dist_path(self) -> str:
|
||||||
return ''
|
return self._output_path
|
||||||
|
|
||||||
@staticmethod
|
def _get_module_name_from_dirs(self, file: str) -> str:
|
||||||
def _get_module_name_from_dirs(file: str) -> str:
|
|
||||||
"""
|
"""
|
||||||
Extracts module name from directories
|
Extracts module name from directories
|
||||||
:param file:
|
:param file:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if 'src/' in file:
|
if self._src_path_part in file:
|
||||||
file = file.replace('src/', '', 1)
|
file = file.replace(self._src_path_part, '', 1)
|
||||||
|
|
||||||
dirs = os.path.dirname(file).split('/')
|
dirs = os.path.dirname(file).split(self._path_mark)
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
if d.__contains__('.'):
|
if d.__contains__('.'):
|
||||||
dirs.remove(d)
|
dirs.remove(d)
|
||||||
@@ -138,11 +143,9 @@ class PublisherService(PublisherABC):
|
|||||||
relative_path = os.path.relpath(r)
|
relative_path = os.path.relpath(r)
|
||||||
file_path = os.path.join(relative_path, os.path.relpath(sub_file))
|
file_path = os.path.join(relative_path, os.path.relpath(sub_file))
|
||||||
|
|
||||||
print(file_path)
|
|
||||||
self._included_files.append(os.path.relpath(file_path))
|
self._included_files.append(os.path.relpath(file_path))
|
||||||
|
|
||||||
elif os.path.isfile(rel_path):
|
elif os.path.isfile(rel_path):
|
||||||
print(rel_path)
|
|
||||||
self._included_files.append(rel_path)
|
self._included_files.append(rel_path)
|
||||||
|
|
||||||
for r, d, f in os.walk(self._build_settings.source_path):
|
for r, d, f in os.walk(self._build_settings.source_path):
|
||||||
@@ -230,8 +233,8 @@ class PublisherService(PublisherABC):
|
|||||||
|
|
||||||
for file in self._included_files:
|
for file in self._included_files:
|
||||||
dist_file = file
|
dist_file = file
|
||||||
if 'src/' in dist_file:
|
if self._src_path_part in dist_file:
|
||||||
dist_file = dist_file.replace('src/', '', 1)
|
dist_file = dist_file.replace(self._src_path_part, '', 1)
|
||||||
|
|
||||||
output_path = os.path.join(build_path, os.path.dirname(dist_file))
|
output_path = os.path.join(build_path, os.path.dirname(dist_file))
|
||||||
output_file = os.path.join(build_path, dist_file)
|
output_file = os.path.join(build_path, dist_file)
|
||||||
@@ -252,8 +255,8 @@ class PublisherService(PublisherABC):
|
|||||||
|
|
||||||
for empty_dir in self._included_dirs:
|
for empty_dir in self._included_dirs:
|
||||||
dist_dir = empty_dir
|
dist_dir = empty_dir
|
||||||
if 'src/' in dist_dir:
|
if self._src_path_part in dist_dir:
|
||||||
dist_dir = dist_dir.replace('src/', '', 1)
|
dist_dir = dist_dir.replace(self._src_path_part, '', 1)
|
||||||
|
|
||||||
output_path = os.path.join(build_path, dist_dir)
|
output_path = os.path.join(build_path, dist_dir)
|
||||||
if not os.path.isdir(output_path):
|
if not os.path.isdir(output_path):
|
||||||
@@ -272,7 +275,7 @@ class PublisherService(PublisherABC):
|
|||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if os.path.isdir(path):
|
if path != self._output_path and os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
def _create_setup(self):
|
def _create_setup(self):
|
||||||
@@ -288,14 +291,30 @@ class PublisherService(PublisherABC):
|
|||||||
|
|
||||||
main = None
|
main = None
|
||||||
try:
|
try:
|
||||||
main = importlib.import_module(self._build_settings.main)
|
main_name = self._build_settings.main
|
||||||
|
|
||||||
|
if '.' in self._build_settings.main:
|
||||||
|
length = len(self._build_settings.main.split('.'))
|
||||||
|
main_name = self._build_settings.main.split('.')[length - 1]
|
||||||
|
|
||||||
|
sys.path.insert(0, self._source_path)
|
||||||
|
main_mod = __import__(self._build_settings.main)
|
||||||
|
main = getattr(main_mod, main_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error('Could not find entry point', str(e))
|
Console.error('Could not find entry point', str(e))
|
||||||
|
return
|
||||||
|
|
||||||
if main is None or not hasattr(main, 'main'):
|
if main is None or not callable(main) and not hasattr(main, 'main'):
|
||||||
Console.error('Could not find entry point')
|
Console.error('Could not find entry point')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if callable(main):
|
||||||
|
mod_name = main.__module__
|
||||||
|
func_name = main.__name__
|
||||||
|
else:
|
||||||
|
mod_name = main.__name__
|
||||||
|
func_name = main.main.__name__
|
||||||
|
|
||||||
with open(setup_file, 'w+') as setup_py:
|
with open(setup_file, 'w+') as setup_py:
|
||||||
setup_string = stringTemplate(SetupTemplate.get_setup_py()).substitute(
|
setup_string = stringTemplate(SetupTemplate.get_setup_py()).substitute(
|
||||||
Name=self._project_settings.name,
|
Name=self._project_settings.name,
|
||||||
@@ -311,7 +330,7 @@ class PublisherService(PublisherABC):
|
|||||||
Dependencies=self._project_settings.dependencies,
|
Dependencies=self._project_settings.dependencies,
|
||||||
EntryPoints={
|
EntryPoints={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
f'{self._build_settings.entry_point} = {main.__name__}:{main.main.__name__}'
|
f'{self._build_settings.entry_point} = {mod_name}:{func_name}'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
PackageData=self._build_settings.package_data
|
PackageData=self._build_settings.package_data
|
||||||
@@ -368,9 +387,13 @@ class PublisherService(PublisherABC):
|
|||||||
"""
|
"""
|
||||||
self._output_path = os.path.join(self._output_path, 'build')
|
self._output_path = os.path.join(self._output_path, 'build')
|
||||||
|
|
||||||
Console.spinner('Reading source files:', self._read_sources, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
Console.spinner('Reading source files:', self._read_sources, text_foreground_color=ForegroundColorEnum.green,
|
||||||
Console.spinner('Creating internal packages:', self._create_packages, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
spinner_foreground_color=ForegroundColorEnum.blue)
|
||||||
Console.spinner('Building application:', self._dist_files, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
Console.spinner('Creating internal packages:', self._create_packages,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue)
|
||||||
|
Console.spinner('Building application:', self._dist_files, text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue)
|
||||||
|
|
||||||
def publish(self):
|
def publish(self):
|
||||||
"""
|
"""
|
||||||
@@ -385,12 +408,40 @@ class PublisherService(PublisherABC):
|
|||||||
self._output_path = os.path.join(self._output_path, 'publish')
|
self._output_path = os.path.join(self._output_path, 'publish')
|
||||||
|
|
||||||
Console.write_line('Build:')
|
Console.write_line('Build:')
|
||||||
Console.spinner('Reading source files:', self._read_sources, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
Console.spinner(
|
||||||
Console.spinner('Creating internal packages:', self._create_packages, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
'Reading source files:',
|
||||||
Console.spinner('Building application:', self._dist_files, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
self._read_sources,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue
|
||||||
|
)
|
||||||
|
|
||||||
|
Console.spinner(
|
||||||
|
'Creating internal packages:',
|
||||||
|
self._create_packages,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue
|
||||||
|
)
|
||||||
|
|
||||||
|
Console.spinner(
|
||||||
|
'Building application:',
|
||||||
|
self._dist_files,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue
|
||||||
|
)
|
||||||
|
|
||||||
Console.write_line('\nPublish:')
|
Console.write_line('\nPublish:')
|
||||||
Console.spinner('Generating setup.py:', self._create_setup, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
Console.spinner(
|
||||||
|
'Generating setup.py:',
|
||||||
|
self._create_setup,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue
|
||||||
|
)
|
||||||
|
|
||||||
Console.write_line('Running setup.py:\n')
|
Console.write_line('Running setup.py:\n')
|
||||||
self._run_setup()
|
self._run_setup()
|
||||||
Console.spinner('Cleaning dist path:', self._clean_dist_files, text_foreground_color=ForegroundColorEnum.green, spinner_foreground_color=ForegroundColorEnum.blue)
|
Console.spinner(
|
||||||
|
'Cleaning dist path:',
|
||||||
|
self._clean_dist_files,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.blue
|
||||||
|
)
|
||||||
|
25
src/cpl_cli/source_creator/__init__.py
Normal file
25
src/cpl_cli/source_creator/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.source_creator'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
73
src/cpl_cli/source_creator/console_builder.py
Normal file
73
src/cpl_cli/source_creator/console_builder.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||||
|
from cpl.console.console import Console
|
||||||
|
from cpl_cli.source_creator.template_builder import TemplateBuilder
|
||||||
|
from cpl_cli.templates.new.console.appsettings_json import AppsettingsTemplate
|
||||||
|
from cpl_cli.templates.new.console.license import LicenseTemplate
|
||||||
|
from cpl_cli.templates.new.console.readme_py import ReadmeTemplate
|
||||||
|
from cpl_cli.templates.new.console.src.name.application import ApplicationTemplate
|
||||||
|
from cpl_cli.templates.new.console.src.name.init import MainInitTemplate
|
||||||
|
from cpl_cli.templates.new.console.src.name.main import MainWithApplicationHostAndStartupTemplate, \
|
||||||
|
MainWithoutApplicationBaseTemplate, MainWithApplicationBaseTemplate, MainWithDependencyInjection
|
||||||
|
from cpl_cli.templates.new.console.src.name.startup import StartupTemplate
|
||||||
|
from cpl_cli.templates.new.console.src.tests.init import TestsInitTemplate
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class ConsoleBuilder:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def build(project_path: str, use_application_api: bool, use_startup: bool, use_service_providing: bool,
|
||||||
|
project_name: str, project_settings: dict):
|
||||||
|
"""
|
||||||
|
Builds the console project files
|
||||||
|
:param project_path:
|
||||||
|
:param use_application_api:
|
||||||
|
:param use_startup:
|
||||||
|
:param use_service_providing:
|
||||||
|
:param project_name:
|
||||||
|
:param project_settings:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if not os.path.isdir(project_path):
|
||||||
|
os.makedirs(project_path)
|
||||||
|
|
||||||
|
with open(os.path.join(project_path, 'cpl.json'), 'w') as project_json:
|
||||||
|
project_json.write(json.dumps(project_settings, indent=2))
|
||||||
|
project_json.close()
|
||||||
|
|
||||||
|
templates: list[TemplateFileABC] = [
|
||||||
|
LicenseTemplate(),
|
||||||
|
ReadmeTemplate(),
|
||||||
|
TestsInitTemplate(),
|
||||||
|
AppsettingsTemplate(),
|
||||||
|
MainInitTemplate(project_name)
|
||||||
|
]
|
||||||
|
|
||||||
|
if use_application_api:
|
||||||
|
templates.append(ApplicationTemplate(project_name))
|
||||||
|
|
||||||
|
if use_startup:
|
||||||
|
templates.append(StartupTemplate(project_name))
|
||||||
|
templates.append(MainWithApplicationHostAndStartupTemplate(project_name))
|
||||||
|
else:
|
||||||
|
templates.append(MainWithApplicationBaseTemplate(project_name))
|
||||||
|
else:
|
||||||
|
if use_service_providing:
|
||||||
|
templates.append(MainWithDependencyInjection(project_name))
|
||||||
|
else:
|
||||||
|
templates.append(MainWithoutApplicationBaseTemplate(project_name))
|
||||||
|
|
||||||
|
for template in templates:
|
||||||
|
Console.spinner(
|
||||||
|
f'Creating {project_name}/{template.path}{template.name}',
|
||||||
|
TemplateBuilder.build,
|
||||||
|
project_path,
|
||||||
|
template,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
|
)
|
73
src/cpl_cli/source_creator/library_builder.py
Normal file
73
src/cpl_cli/source_creator/library_builder.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||||
|
from cpl.console.console import Console
|
||||||
|
from cpl_cli.source_creator.template_builder import TemplateBuilder
|
||||||
|
from cpl_cli.templates.new.library.appsettings_json import AppsettingsTemplate
|
||||||
|
from cpl_cli.templates.new.library.license import LicenseTemplate
|
||||||
|
from cpl_cli.templates.new.library.readme_py import ReadmeTemplate
|
||||||
|
from cpl_cli.templates.new.library.src.cli.application import ApplicationTemplate
|
||||||
|
from cpl_cli.templates.new.library.src.cli.init import CLIInitTemplate
|
||||||
|
from cpl_cli.templates.new.library.src.cli.main import MainWithApplicationHostAndStartupTemplate, \
|
||||||
|
MainWithoutApplicationBaseTemplate, MainWithApplicationBaseTemplate, MainWithDependencyInjection
|
||||||
|
from cpl_cli.templates.new.library.src.cli.startup import StartupTemplate
|
||||||
|
from cpl_cli.templates.new.library.src.tests.init import TestsInitTemplate
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class LibraryBuilder:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def build(project_path: str, use_application_api: bool, use_startup: bool, use_service_providing: bool,
|
||||||
|
project_name: str, project_settings: dict):
|
||||||
|
"""
|
||||||
|
Builds the library project files
|
||||||
|
:param project_path:
|
||||||
|
:param use_application_api:
|
||||||
|
:param use_startup:
|
||||||
|
:param use_service_providing:
|
||||||
|
:param project_name:
|
||||||
|
:param project_settings:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if not os.path.isdir(project_path):
|
||||||
|
os.makedirs(project_path)
|
||||||
|
|
||||||
|
with open(os.path.join(project_path, 'cpl.json'), 'w') as project_json:
|
||||||
|
project_json.write(json.dumps(project_settings, indent=2))
|
||||||
|
project_json.close()
|
||||||
|
|
||||||
|
templates: list[TemplateFileABC] = [
|
||||||
|
LicenseTemplate(),
|
||||||
|
ReadmeTemplate(),
|
||||||
|
TestsInitTemplate(),
|
||||||
|
CLIInitTemplate(project_name),
|
||||||
|
AppsettingsTemplate()
|
||||||
|
]
|
||||||
|
|
||||||
|
if use_application_api:
|
||||||
|
templates.append(ApplicationTemplate(project_name))
|
||||||
|
|
||||||
|
if use_startup:
|
||||||
|
templates.append(StartupTemplate(project_name))
|
||||||
|
templates.append(MainWithApplicationHostAndStartupTemplate(project_name))
|
||||||
|
else:
|
||||||
|
templates.append(MainWithApplicationBaseTemplate())
|
||||||
|
else:
|
||||||
|
if use_service_providing:
|
||||||
|
templates.append(MainWithDependencyInjection())
|
||||||
|
else:
|
||||||
|
templates.append(MainWithoutApplicationBaseTemplate())
|
||||||
|
|
||||||
|
for template in templates:
|
||||||
|
Console.spinner(
|
||||||
|
f'Creating {project_name}/{template.path}{template.name}',
|
||||||
|
TemplateBuilder.build,
|
||||||
|
project_path,
|
||||||
|
template,
|
||||||
|
text_foreground_color=ForegroundColorEnum.green,
|
||||||
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
|
)
|
24
src/cpl_cli/source_creator/template_builder.py
Normal file
24
src/cpl_cli/source_creator/template_builder.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateBuilder:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def build(project_path: str, template: TemplateFileABC):
|
||||||
|
"""
|
||||||
|
Creates template
|
||||||
|
:param project_path:
|
||||||
|
:param template:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
file_path = os.path.join(project_path, template.path, template.name)
|
||||||
|
file_rel_path = os.path.join(project_path, template.path)
|
||||||
|
|
||||||
|
if not os.path.isdir(file_rel_path):
|
||||||
|
os.makedirs(file_rel_path)
|
||||||
|
|
||||||
|
with open(file_path, 'w') as license_file:
|
||||||
|
license_file.write(template.value)
|
||||||
|
license_file.close()
|
@@ -52,7 +52,8 @@ class Startup(StartupABC):
|
|||||||
ConsoleArgument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True)
|
ConsoleArgument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True)
|
||||||
)
|
)
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'new', ['n', 'N'], '', console_arguments=[
|
self._configuration.add_console_argument(ConsoleArgument('', 'new', ['n', 'N'], '', console_arguments=[
|
||||||
ConsoleArgument('', 'console', ['c', 'C'], ' ')
|
ConsoleArgument('', 'console', ['c', 'C'], ' '),
|
||||||
|
ConsoleArgument('', 'library', ['l', 'L'], ' ')
|
||||||
]))
|
]))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'publish', ['p', 'P'], ''))
|
self._configuration.add_console_argument(ConsoleArgument('', 'publish', ['p', 'P'], ''))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'start', ['s', 'S'], ''))
|
self._configuration.add_console_argument(ConsoleArgument('', 'start', ['s', 'S'], ''))
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.build'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.generate'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
32
src/cpl_cli/templates/generate/init_template.py
Normal file
32
src/cpl_cli/templates/generate/init_template.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import textwrap
|
||||||
|
from string import Template
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class InitTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = f'__init__.py'
|
||||||
|
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||||
|
self._path = path
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
# imports
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return Template(self._value).substitute(
|
||||||
|
Name=self._class_name
|
||||||
|
)
|
@@ -14,13 +14,10 @@ class ServiceTemplate(TemplateFileABC):
|
|||||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||||
self._path = path
|
self._path = path
|
||||||
self._value = textwrap.dedent("""\
|
self._value = textwrap.dedent("""\
|
||||||
from cpl.dependency_injection import ServiceABC
|
class $Name:
|
||||||
|
|
||||||
|
|
||||||
class $Name(ServiceABC):
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
ServiceABC.__init__(self)
|
pass
|
||||||
""")
|
""")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
41
src/cpl_cli/templates/new/console/appsettings_json.py
Normal file
41
src/cpl_cli/templates/new/console/appsettings_json.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class AppsettingsTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = 'appsettings.json'
|
||||||
|
self._path = ''
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
{
|
||||||
|
"TimeFormatSettings": {
|
||||||
|
"DateFormat": "%Y-%m-%d",
|
||||||
|
"TimeFormat": "%H:%M:%S",
|
||||||
|
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||||
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
|
},
|
||||||
|
|
||||||
|
"LoggingSettings": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "log_$start_time.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "WARN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
25
src/cpl_cli/templates/new/console/src/name/__init__.py
Normal file
25
src/cpl_cli/templates/new/console/src/name/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.templates.new.console.src.name'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
@@ -1,15 +1,17 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
class ApplicationTemplate(TemplateFileABC):
|
class ApplicationTemplate(TemplateFileABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, name: str):
|
||||||
TemplateFileABC.__init__(self)
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
self._name = 'application.py'
|
self._name = 'application.py'
|
||||||
self._path = 'src/'
|
self._path = f'src/{name}/'
|
||||||
self._value = textwrap.dedent("""\
|
self._value = textwrap.dedent("""\
|
||||||
from cpl.application import ApplicationABC
|
from cpl.application import ApplicationABC
|
||||||
from cpl.configuration import ConfigurationABC
|
from cpl.configuration import ConfigurationABC
|
29
src/cpl_cli/templates/new/console/src/name/init.py
Normal file
29
src/cpl_cli/templates/new/console/src/name/init.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class MainInitTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = '__init__.py'
|
||||||
|
self._path = f'src/{name}/'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
# imports:
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
158
src/cpl_cli/templates/new/console/src/name/main.py
Normal file
158
src/cpl_cli/templates/new/console/src/name/main.py
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = 'main.py'
|
||||||
|
self._path = f'src/{name}/'
|
||||||
|
self._value = textwrap.dedent(f"""\
|
||||||
|
from cpl.application import ApplicationBuilder
|
||||||
|
|
||||||
|
from {name}.application import Application
|
||||||
|
from {name}.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:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
||||||
|
|
||||||
|
|
||||||
|
class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = 'main.py'
|
||||||
|
self._path = f'src/{name}'
|
||||||
|
self._value = textwrap.dedent(f"""\
|
||||||
|
from cpl.application import ApplicationBuilder
|
||||||
|
|
||||||
|
from {name}.application import Application
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app_builder = ApplicationBuilder(Application)
|
||||||
|
app_builder.build().run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
||||||
|
|
||||||
|
|
||||||
|
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = 'main.py'
|
||||||
|
self._path = f'src/{name}'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
from cpl.console import Console
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
Console.write_line('Hello World')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
||||||
|
|
||||||
|
|
||||||
|
class MainWithDependencyInjection(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = 'main.py'
|
||||||
|
self._path = f'src/{name}'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
from cpl.configuration import Configuration, ConfigurationABC
|
||||||
|
from cpl.console import Console
|
||||||
|
from cpl.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:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
@@ -1,15 +1,17 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
class StartupTemplate(TemplateFileABC):
|
class StartupTemplate(TemplateFileABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, name: str):
|
||||||
TemplateFileABC.__init__(self)
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
self._name = 'startup.py'
|
self._name = 'startup.py'
|
||||||
self._path = 'src/'
|
self._path = f'src/{name}/'
|
||||||
self._value = textwrap.dedent("""\
|
self._value = textwrap.dedent("""\
|
||||||
from cpl.application import StartupABC
|
from cpl.application import StartupABC
|
||||||
from cpl.configuration import ConfigurationABC
|
from cpl.configuration import ConfigurationABC
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src.tests'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
25
src/cpl_cli/templates/new/library/__init__.py
Normal file
25
src/cpl_cli/templates/new/library/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.templates.new.library'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
41
src/cpl_cli/templates/new/library/appsettings_json.py
Normal file
41
src/cpl_cli/templates/new/library/appsettings_json.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class AppsettingsTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = 'appsettings.json'
|
||||||
|
self._path = ''
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
{
|
||||||
|
"TimeFormatSettings": {
|
||||||
|
"DateFormat": "%Y-%m-%d",
|
||||||
|
"TimeFormat": "%H:%M:%S",
|
||||||
|
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||||
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
|
},
|
||||||
|
|
||||||
|
"LoggingSettings": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "log_$start_time.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "WARN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
23
src/cpl_cli/templates/new/library/license.py
Normal file
23
src/cpl_cli/templates/new/library/license.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class LicenseTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = 'LICENSE'
|
||||||
|
self._path = ''
|
||||||
|
self._value = """"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
23
src/cpl_cli/templates/new/library/readme_py.py
Normal file
23
src/cpl_cli/templates/new/library/readme_py.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class ReadmeTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = 'README.md'
|
||||||
|
self._path = ''
|
||||||
|
self._value = """"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
25
src/cpl_cli/templates/new/library/src/__init__.py
Normal file
25
src/cpl_cli/templates/new/library/src/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.templates.new.library.src'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
25
src/cpl_cli/templates/new/library/src/cli/__init__.py
Normal file
25
src/cpl_cli/templates/new/library/src/cli/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.templates.new.library.src.cli'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
44
src/cpl_cli/templates/new/library/src/cli/application.py
Normal file
44
src/cpl_cli/templates/new/library/src/cli/application.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = 'application.py'
|
||||||
|
self._path = f'src/{name}_cli/'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
from cpl.application import ApplicationABC
|
||||||
|
from cpl.configuration import ConfigurationABC
|
||||||
|
from cpl.console import Console
|
||||||
|
from cpl.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:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
29
src/cpl_cli/templates/new/library/src/cli/init.py
Normal file
29
src/cpl_cli/templates/new/library/src/cli/init.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class CLIInitTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = '__init__.py'
|
||||||
|
self._path = f'src/{name}_cli/'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
# imports:
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
@@ -1,20 +1,22 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, name: str):
|
||||||
TemplateFileABC.__init__(self)
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
self._name = 'main.py'
|
self._name = 'main.py'
|
||||||
self._path = 'src/'
|
self._path = f'src/{name}_cli/'
|
||||||
self._value = textwrap.dedent("""\
|
self._value = textwrap.dedent(f"""\
|
||||||
from cpl.application import ApplicationBuilder
|
from cpl.application import ApplicationBuilder
|
||||||
|
|
||||||
from application import Application
|
from {name}_cli.application import Application
|
||||||
from startup import Startup
|
from {name}_cli.startup import Startup
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -47,10 +49,10 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
|
|||||||
|
|
||||||
self._name = 'main.py'
|
self._name = 'main.py'
|
||||||
self._path = 'src/'
|
self._path = 'src/'
|
||||||
self._value = textwrap.dedent("""\
|
self._value = textwrap.dedent(f"""\
|
||||||
from cpl.application import ApplicationBuilder
|
from cpl.application import ApplicationBuilder
|
||||||
|
|
||||||
from application import Application
|
from {name}_cli.application import Application
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
47
src/cpl_cli/templates/new/library/src/cli/startup.py
Normal file
47
src/cpl_cli/templates/new/library/src/cli/startup.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl.utils.string import String
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class StartupTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
name = String.convert_to_snake_case(name)
|
||||||
|
self._name = 'startup.py'
|
||||||
|
self._path = f'src/{name}_cli/'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
from cpl.application import StartupABC
|
||||||
|
from cpl.configuration import ConfigurationABC
|
||||||
|
from cpl.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||||
|
|
||||||
|
|
||||||
|
class Startup(StartupABC):
|
||||||
|
|
||||||
|
def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC):
|
||||||
|
StartupABC.__init__(self)
|
||||||
|
|
||||||
|
self._configuration = config
|
||||||
|
self._environment = self._configuration.environment
|
||||||
|
self._services = services
|
||||||
|
|
||||||
|
def configure_configuration(self) -> ConfigurationABC:
|
||||||
|
return self._configuration
|
||||||
|
|
||||||
|
def configure_services(self) -> ServiceProviderABC:
|
||||||
|
return self._services.build_service_provider()
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
25
src/cpl_cli/templates/new/library/src/name/__init__.py
Normal file
25
src/cpl_cli/templates/new/library/src/name/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.templates.new.library.src.name'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
27
src/cpl_cli/templates/new/library/src/name/init.py
Normal file
27
src/cpl_cli/templates/new/library/src/name/init.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class TestsInitTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = '__init__.py'
|
||||||
|
self._path = f'src/{name}/'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
# imports:
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
25
src/cpl_cli/templates/new/library/src/tests/__init__.py
Normal file
25
src/cpl_cli/templates/new/library/src/tests/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_cpl sh-edraft Common Python library
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library
|
||||||
|
|
||||||
|
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_cli.templates.new.library.src.tests'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
27
src/cpl_cli/templates/new/library/src/tests/init.py
Normal file
27
src/cpl_cli/templates/new/library/src/tests/init.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
|
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||||
|
|
||||||
|
|
||||||
|
class TestsInitTemplate(TemplateFileABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
TemplateFileABC.__init__(self)
|
||||||
|
|
||||||
|
self._name = '__init__.py'
|
||||||
|
self._path = 'src/tests/'
|
||||||
|
self._value = textwrap.dedent("""\
|
||||||
|
# imports:
|
||||||
|
""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> str:
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
return self._value
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.publish'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||||
__version__ = '2021.4.2'
|
__version__ = '2021.4.0'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
version_info = VersionInfo(major='2021', minor='04', micro='0')
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
"SourcePath": "src",
|
"SourcePath": "src",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "main",
|
"Main": "main",
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
"SourcePath": "",
|
"SourcePath": "",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "main",
|
"Main": "main",
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
"SourcePath": "src",
|
"SourcePath": "src",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "main",
|
"Main": "main",
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
"SourcePath": "src",
|
"SourcePath": "src",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "main",
|
"Main": "main",
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
"SourcePath": "src",
|
"SourcePath": "src",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "main",
|
"Main": "main",
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
"SourcePath": "src",
|
"SourcePath": "src",
|
||||||
"OutputPath": "dist",
|
"OutputPath": "dist",
|
||||||
"Main": "main",
|
"Main": "main",
|
||||||
|
Reference in New Issue
Block a user