2022.12 #133
| @@ -0,0 +1,26 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| """ | ||||
| cpl-cli sh-edraft Common Python library CLI | ||||
| ~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| sh-edraft Common Python library Command Line Interface | ||||
|  | ||||
| :copyright: (c) 2020 - 2022 sh-edraft.de | ||||
| :license: MIT, see LICENSE for more details. | ||||
|  | ||||
| """ | ||||
|  | ||||
| __title__ = 'cpl_cli' | ||||
| __author__ = 'Sven Heidemann' | ||||
| __license__ = 'MIT' | ||||
| __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' | ||||
| __version__ = '2022.12.0' | ||||
|  | ||||
| from collections import namedtuple | ||||
|  | ||||
|  | ||||
| # imports: | ||||
|  | ||||
| VersionInfo = namedtuple('VersionInfo', 'major minor micro') | ||||
| version_info = VersionInfo(major='2022', minor='12', micro='0') | ||||
|   | ||||
							
								
								
									
										39
									
								
								src/cpl_cli/.cpl/schematic_application.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/cpl_cli/.cpl/schematic_application.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import textwrap | ||||
|  | ||||
| from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC | ||||
|  | ||||
|  | ||||
| class Application(GenerateSchematicABC): | ||||
|  | ||||
|     def __init__(self, *args: str): | ||||
|         GenerateSchematicABC.__init__(self, *args) | ||||
|  | ||||
|     def get_code(self) -> str: | ||||
|         code = """\ | ||||
|         from cpl_core.application import ApplicationABC | ||||
|         from cpl_core.configuration import ConfigurationABC | ||||
|         from cpl_core.console import Console | ||||
|         from cpl_core.dependency_injection import ServiceProviderABC | ||||
|                      | ||||
|                      | ||||
|         class $Name(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') | ||||
|         """ | ||||
|         x = self.build_code_str(code, Name=self._class_name) | ||||
|         return x | ||||
|  | ||||
|     @classmethod | ||||
|     def register(cls): | ||||
|         GenerateSchematicABC.register( | ||||
|             cls, | ||||
|             'application', | ||||
|             ['app', 'APP'] | ||||
|         ) | ||||
							
								
								
									
										35
									
								
								src/cpl_cli/.cpl/schematic_application_extension.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/cpl_cli/.cpl/schematic_application_extension.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| import textwrap | ||||
|  | ||||
| from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC | ||||
|  | ||||
|  | ||||
| class ApplicationExtension(GenerateSchematicABC): | ||||
|  | ||||
|     def __init__(self, *args: str): | ||||
|         GenerateSchematicABC.__init__(self, *args) | ||||
|  | ||||
|     def get_code(self) -> str: | ||||
|         code = """\ | ||||
|         from cpl_core.application import ApplicationExtensionABC | ||||
|         from cpl_core.configuration import ConfigurationABC | ||||
|         from cpl_core.dependency_injection import ServiceProviderABC | ||||
|          | ||||
|          | ||||
|         class $Name(ApplicationExtensionABC): | ||||
|          | ||||
|             def __init__(self): | ||||
|                 ApplicationExtensionABC.__init__(self) | ||||
|          | ||||
|             def run(self, config: ConfigurationABC, services: ServiceProviderABC): | ||||
|                 pass | ||||
|         """ | ||||
|         x = self.build_code_str(code, Name=self._class_name) | ||||
|         return x | ||||
|  | ||||
|     @classmethod | ||||
|     def register(cls): | ||||
|         GenerateSchematicABC.register( | ||||
|             cls, | ||||
|             'application-extension', | ||||
|             ['appex', 'APPEX'] | ||||
|         ) | ||||
							
								
								
									
										51
									
								
								src/cpl_cli/.cpl/schematic_schematic.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/cpl_cli/.cpl/schematic_schematic.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC | ||||
| from cpl_core.utils import String | ||||
|  | ||||
|  | ||||
| class Schematic(GenerateSchematicABC): | ||||
|  | ||||
|     def __init__(self, name: str, path: str, schematic: str): | ||||
|         GenerateSchematicABC.__init__(self, name, path, schematic) | ||||
|         self._name = f'schematic_{String.convert_to_snake_case(name)}.py' | ||||
|         self._path = '.cpl/' | ||||
|         self._class_name = String.convert_to_camel_case(name) | ||||
|  | ||||
|     def get_code(self) -> str: | ||||
|         code = """\ | ||||
|         from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC | ||||
|  | ||||
|  | ||||
|         class $Name(GenerateSchematicABC): | ||||
|          | ||||
|             def __init__(self, *args: str): | ||||
|                 GenerateSchematicABC.__init__(self, *args) | ||||
|          | ||||
|             def get_code(self) -> str: | ||||
|                 import textwrap | ||||
|                 code = textwrap.dedent(\"\"\"\\ | ||||
|                 from enum import Enum | ||||
|                  | ||||
|                  | ||||
|                 class $Name(Enum): | ||||
|                  | ||||
|                     atr = 0 | ||||
|                 \"\"\") | ||||
|                 return self.build_code_str(code, Name=self._class_name) | ||||
|          | ||||
|             @classmethod | ||||
|             def register(cls): | ||||
|                 GenerateSchematicABC.register( | ||||
|                     cls, | ||||
|                     '$NameLower', | ||||
|                     [] | ||||
|                 ) | ||||
|         """ | ||||
|         return self.build_code_str(code, Name=self._class_name) | ||||
|  | ||||
|     @classmethod | ||||
|     def register(cls): | ||||
|         GenerateSchematicABC.register( | ||||
|             cls, | ||||
|             'schematic', | ||||
|             ['scheme', 'SCHEME'] | ||||
|         ) | ||||
							
								
								
									
										39
									
								
								src/cpl_cli/.cpl/schematic_startup.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/cpl_cli/.cpl/schematic_startup.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import textwrap | ||||
|  | ||||
| from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC | ||||
|  | ||||
|  | ||||
| class Startup(GenerateSchematicABC): | ||||
|  | ||||
|     def __init__(self, *args: str): | ||||
|         GenerateSchematicABC.__init__(self, *args) | ||||
|  | ||||
|     def get_code(self) -> str: | ||||
|         code = """\ | ||||
|         from cpl_core.application import StartupABC | ||||
|         from cpl_core.configuration import ConfigurationABC | ||||
|         from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC | ||||
|         from cpl_core.environment import ApplicationEnvironment | ||||
|          | ||||
|          | ||||
|         class $Name(StartupABC): | ||||
|          | ||||
|             def __init__(self): | ||||
|                 StartupABC.__init__(self) | ||||
|          | ||||
|             def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: | ||||
|                 return configuration | ||||
|          | ||||
|             def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: | ||||
|                 return services.build_service_provider() | ||||
|         """ | ||||
|         x = self.build_code_str(code, Name=self._class_name) | ||||
|         return x | ||||
|  | ||||
|     @classmethod | ||||
|     def register(cls): | ||||
|         GenerateSchematicABC.register( | ||||
|             cls, | ||||
|             'startup', | ||||
|             ['stup', 'STUP'] | ||||
|         ) | ||||
							
								
								
									
										39
									
								
								src/cpl_cli/.cpl/schematic_startup_extension.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/cpl_cli/.cpl/schematic_startup_extension.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import textwrap | ||||
|  | ||||
| from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC | ||||
|  | ||||
|  | ||||
| class StartupExtension(GenerateSchematicABC): | ||||
|  | ||||
|     def __init__(self, *args: str): | ||||
|         GenerateSchematicABC.__init__(self, *args) | ||||
|  | ||||
|     def get_code(self) -> str: | ||||
|         code = """\ | ||||
|         from cpl_core.application.startup_extension_abc import StartupExtensionABC | ||||
|         from cpl_core.configuration.configuration_abc import ConfigurationABC | ||||
|         from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC | ||||
|         from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC | ||||
|          | ||||
|          | ||||
|         class $Name(StartupExtensionABC): | ||||
|          | ||||
|             def __init__(self): | ||||
|                 pass | ||||
|          | ||||
|             def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): | ||||
|                 pass | ||||
|          | ||||
|             def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): | ||||
|                 pass | ||||
|         """ | ||||
|         x = self.build_code_str(code, Name=self._class_name) | ||||
|         return x | ||||
|  | ||||
|     @classmethod | ||||
|     def register(cls): | ||||
|         GenerateSchematicABC.register( | ||||
|             cls, | ||||
|             'startup-extension', | ||||
|             ['stupex', 'STUPEX'] | ||||
|         ) | ||||
| @@ -1 +1,26 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| """ | ||||
| cpl-cli sh-edraft Common Python library CLI | ||||
| ~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| sh-edraft Common Python library Command Line Interface | ||||
|  | ||||
| :copyright: (c) 2020 - 2022 sh-edraft.de | ||||
| :license: MIT, see LICENSE for more details. | ||||
|  | ||||
| """ | ||||
|  | ||||
| __title__ = 'cpl_cli.abc' | ||||
| __author__ = 'Sven Heidemann' | ||||
| __license__ = 'MIT' | ||||
| __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' | ||||
| __version__ = '2022.12.0' | ||||
|  | ||||
| from collections import namedtuple | ||||
|  | ||||
|  | ||||
| # imports | ||||
|  | ||||
| VersionInfo = namedtuple('VersionInfo', 'major minor micro') | ||||
| version_info = VersionInfo(major='2022', minor='12', micro='0') | ||||
|   | ||||
| @@ -35,11 +35,14 @@ class GenerateService(CommandABC): | ||||
|         self._env = self._config.environment | ||||
|         self._schematics = {} | ||||
|  | ||||
|         for package_name in Dependencies.get_cpl_packages(): | ||||
|             package = importlib.import_module(String.convert_to_snake_case(package_name[0])) | ||||
|         for package_name, version in Dependencies.get_cpl_packages(): | ||||
|             if package_name == 'cpl-cli': | ||||
|                 continue | ||||
|             package = importlib.import_module(String.convert_to_snake_case(package_name)) | ||||
|             self._read_custom_schematics_from_path(os.path.dirname(package.__file__)) | ||||
|  | ||||
|         self._read_custom_schematics_from_path(self._env.working_directory) | ||||
|         self._read_custom_schematics_from_path(self._env.runtime_directory) | ||||
|  | ||||
|         if len(GenerateSchematicABC.__subclasses__()) == 0: | ||||
|             Console.error(f'No schematics found in template directory: .cpl') | ||||
|   | ||||
| @@ -2,18 +2,18 @@ import os | ||||
| import sys | ||||
| import textwrap | ||||
|  | ||||
| from cpl_cli import Error | ||||
| from cpl_cli.error import Error | ||||
| from cpl_cli.command_abc import CommandABC | ||||
| from cpl_cli.configuration import WorkspaceSettings | ||||
| from cpl_cli.configuration.workspace_settings import WorkspaceSettings | ||||
| from cpl_cli.configuration.build_settings import BuildSettings | ||||
| from cpl_cli.configuration.project_settings import ProjectSettings | ||||
| from cpl_cli.live_server.start_executable import StartExecutable | ||||
| from cpl_cli.publish import PublisherService | ||||
| from cpl_core.configuration import ConfigurationABC | ||||
| from cpl_cli.publish.publisher_service import PublisherService | ||||
| from cpl_core.configuration.configuration_abc import ConfigurationABC | ||||
| from cpl_core.console.console import Console | ||||
| from cpl_core.dependency_injection import ServiceProviderABC | ||||
| from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC | ||||
| from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC | ||||
| from cpl_core.utils import String | ||||
| from cpl_core.utils.string import String | ||||
|  | ||||
|  | ||||
| class RunService(CommandABC): | ||||
| @@ -91,6 +91,7 @@ class RunService(CommandABC): | ||||
|  | ||||
|         self._env.set_working_directory(self._src_dir) | ||||
|         self._publisher.build() | ||||
|         self._env.set_working_directory(self._src_dir) | ||||
|         self._src_dir = os.path.abspath(os.path.join( | ||||
|             self._src_dir, | ||||
|             self._build_settings.output_path, | ||||
|   | ||||
| @@ -123,7 +123,7 @@ class ProjectSettings(ConfigurationModelABC): | ||||
|             self._python_path = settings[ProjectSettingsNameEnum.python_path.value] | ||||
|  | ||||
|             if ProjectSettingsNameEnum.python_path.value in settings and sys.platform in settings[ProjectSettingsNameEnum.python_path.value]: | ||||
|                 path = settings[ProjectSettingsNameEnum.python_path.value][sys.platform] | ||||
|                 path = f'{settings[ProjectSettingsNameEnum.python_path.value][sys.platform]}/bin/python' | ||||
|                 if path == '' or path is None: | ||||
|                     Error.warn(f'{ProjectSettingsNameEnum.python_path.value} not set') | ||||
|                     path = sys.executable | ||||
|   | ||||
| @@ -0,0 +1,26 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| """ | ||||
| cpl-cli sh-edraft Common Python library CLI | ||||
| ~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| sh-edraft Common Python library Command Line Interface | ||||
|  | ||||
| :copyright: (c) 2020 - 2022 sh-edraft.de | ||||
| :license: MIT, see LICENSE for more details. | ||||
|  | ||||
| """ | ||||
|  | ||||
| __title__ = 'cpl_cli.helper' | ||||
| __author__ = 'Sven Heidemann' | ||||
| __license__ = 'MIT' | ||||
| __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' | ||||
| __version__ = '2022.12.0' | ||||
|  | ||||
| from collections import namedtuple | ||||
|  | ||||
|  | ||||
| # imports: | ||||
|  | ||||
| VersionInfo = namedtuple('VersionInfo', 'major minor micro') | ||||
| version_info = VersionInfo(major='2022', minor='12', micro='0') | ||||
|   | ||||
| @@ -103,9 +103,8 @@ class LiveServerService(FileSystemEventHandler): | ||||
|             return | ||||
|  | ||||
|         self._env.set_working_directory(self._src_dir) | ||||
|         Console.disable() | ||||
|         self._publisher.build() | ||||
|         Console.enable() | ||||
|         self._env.set_working_directory(self._src_dir) | ||||
|         self._wd = os.path.abspath(os.path.join( | ||||
|             self._src_dir, | ||||
|             self._build_settings.output_path, | ||||
|   | ||||
| @@ -1,13 +1,12 @@ | ||||
| import os | ||||
| import subprocess | ||||
| import sys | ||||
| import threading | ||||
| from datetime import datetime | ||||
|  | ||||
| from cpl_core.console.console import Console | ||||
| from cpl_core.console.foreground_color_enum import ForegroundColorEnum | ||||
| from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC | ||||
| from cpl_cli.configuration import BuildSettings | ||||
| from cpl_cli.configuration.build_settings import BuildSettings | ||||
|  | ||||
|  | ||||
| class StartExecutable: | ||||
| @@ -43,7 +42,10 @@ class StartExecutable: | ||||
|         self._env_vars['VIRTUAL_ENV'] = path | ||||
|  | ||||
|     def run(self, args: list[str], executable: str, path: str, output=True): | ||||
|         self._executable = os.path.abspath(executable) | ||||
|         self._executable = os.path.abspath(os.path.join(self._env.working_directory, executable)) | ||||
|         if not os.path.exists(self._executable): | ||||
|             Console.error(f'Executable not found') | ||||
|             return | ||||
|  | ||||
|         main = self._build_settings.main | ||||
|         if '.' in self._build_settings.main: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user