Fixed cpl g path problems & package names #93

This commit is contained in:
2022-11-30 18:04:40 +01:00
parent f0a8d69e22
commit 1bbec27d1a
61 changed files with 153 additions and 86 deletions

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli'
__title__ = 'cpl-cli'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates'
__title__ = '_templates'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.build'
__title__ = '_templates.build'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.generate'
__title__ = '_templates.generate'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new'
__title__ = '_templates.new'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.console'
__title__ = '_templates.new.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.console.source'
__title__ = '_templates.new.console.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.console.source.name'
__title__ = '_templates.new.console.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.library'
__title__ = '_templates.new.library'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.library.source'
__title__ = '_templates.new.library.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.library.source.name'
__title__ = '_templates.new.library.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.unittest'
__title__ = '_templates.new.unittest'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.unittest.source'
__title__ = '_templates.new.unittest.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.new.unittest.source.name'
__title__ = '_templates.new.unittest.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli._templates.publish'
__title__ = '_templates.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.command'
__title__ = 'command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -14,6 +14,7 @@ from cpl_cli._templates.generate.thread_template import ThreadTemplate
from cpl_cli._templates.generate.validator_template import ValidatorTemplate
from cpl_cli._templates.template_file_abc import TemplateFileABC
from cpl_cli.command_abc import CommandABC
from cpl_cli.configuration import WorkspaceSettings
from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.console.console import Console
from cpl_core.console.foreground_color_enum import ForegroundColorEnum
@@ -22,13 +23,20 @@ from cpl_core.utils.string import String
class GenerateService(CommandABC):
def __init__(self, configuration: ConfigurationABC):
def __init__(
self,
configuration: ConfigurationABC,
workspace: WorkspaceSettings,
):
"""
Service for the CLI command generate
:param configuration:
"""
CommandABC.__init__(self)
self._config = configuration
self._workspace = workspace
self._schematics = {
"abc": {
"Upper": "ABC",
@@ -129,27 +137,7 @@ class GenerateService(CommandABC):
template.write(value)
template.close()
def _generate(self, schematic: str, name: str, template: TemplateFileABC):
"""
Generates files by given schematic, name and template
:param schematic:
:param name:
:param template:
:return:
"""
class_name = name
rel_path = ''
if '/' in name:
parts = name.split('/')
rel_path = '/'.join(parts[:-1])
class_name = parts[len(parts) - 1]
if 'src' not in rel_path and not os.path.exists(os.path.join(self._env.working_directory, rel_path)):
rel_path = f'src/{rel_path}'
template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
file_path = os.path.join(self._env.working_directory, template.path, template.name)
def _create_init_files(self, file_path: str, template: TemplateFileABC, class_name: str, schematic: str, rel_path: str):
if not os.path.isdir(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
directory = ''
@@ -171,6 +159,29 @@ class GenerateService(CommandABC):
spinner_foreground_color=ForegroundColorEnum.cyan
)
def _generate(self, schematic: str, name: str, template: TemplateFileABC):
"""
Generates files by given schematic, name and template
:param schematic:
:param name:
:param template:
:return:
"""
class_name = name
rel_path = ''
if '/' in name:
parts = name.split('/')
rel_path = '/'.join(parts[:-1])
class_name = parts[len(parts) - 1]
if self._workspace is not None and parts[0] in self._workspace.projects:
rel_path = os.path.dirname(self._workspace.projects[parts[0]])
template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
file_path = os.path.join(self._env.working_directory, template.path, template.name)
self._create_init_files(file_path, template, class_name, schematic, rel_path)
if os.path.isfile(file_path):
Console.error(f'{String.first_to_upper(schematic)} already exists!\n')
sys.exit()

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.configuration'
__title__ = 'configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.live_server'
__title__ = 'live_server'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.migrations'
__title__ = 'migrations'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.migrations.base'
__title__ = 'migrations.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.migrations.service'
__title__ = 'migrations.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.publish'
__title__ = 'publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.source_creator'
__title__ = 'source_creator'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
"""
__title__ = 'cpl_cli.validators'
__title__ = 'validators'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core'
__title__ = 'cpl-core'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.application'
__title__ = 'application'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.configuration'
__title__ = 'configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.console'
__title__ = 'console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.database'
__title__ = 'database'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.database.connection'
__title__ = 'database.connection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.database.context'
__title__ = 'database.context'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.dependency_injection'
__title__ = 'dependency_injection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.environment'
__title__ = 'environment'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.logging'
__title__ = 'logging'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.mailing'
__title__ = 'mailing'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.pipes'
__title__ = 'pipes'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.time'
__title__ = 'time'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library
"""
__title__ = 'cpl_core.utils'
__title__ = 'utils'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord'
__title__ = 'cpl-discord'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.application'
__title__ = 'application'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.command'
__title__ = 'command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.configuration'
__title__ = 'configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.container'
__title__ = 'container'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.events'
__title__ = 'events'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.helper'
__title__ = 'helper'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library link between discord.py and CPL
"""
__title__ = 'cpl_discord.service'
__title__ = 'service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Python integrated Queries
"""
__title__ = 'cpl_query'
__title__ = 'cpl-query'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Python integrated Queries
"""
__title__ = 'cpl_query.base'
__title__ = 'base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Python integrated Queries
"""
__title__ = 'cpl_query.enumerable'
__title__ = 'enumerable'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Python integrated Queries
"""
__title__ = 'cpl_query.extension'
__title__ = 'extension'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Python integrated Queries
"""
__title__ = 'cpl_query.iterable'
__title__ = 'iterable'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'

View File

@@ -11,7 +11,7 @@ sh-edraft Common Python library Python Translation
"""
__title__ = 'cpl_translation'
__title__ = 'cpl-translation'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'