From 61d9912950bc85f0d97a9d97b214e31b56c142ac Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 17 Sep 2022 12:09:05 +0200 Subject: [PATCH] Removed duplicated schematic name in generate command #92 --- src/cpl_cli/_templates/generate/abc_template.py | 6 ++++++ src/cpl_cli/_templates/generate/configmodel_template.py | 6 ++++++ src/cpl_cli/_templates/generate/enum_template.py | 6 ++++++ src/cpl_cli/_templates/generate/init_template.py | 3 +++ src/cpl_cli/_templates/generate/pipe_template.py | 6 ++++++ src/cpl_cli/_templates/generate/service_template.py | 6 ++++++ src/cpl_cli/_templates/generate/test_case_template.py | 6 ++++++ src/cpl_cli/_templates/generate/thread_template.py | 6 ++++++ src/cpl_cli/_templates/generate/validator_template.py | 6 ++++++ 9 files changed, 51 insertions(+) diff --git a/src/cpl_cli/_templates/generate/abc_template.py b/src/cpl_cli/_templates/generate/abc_template.py index 4e6d645d..3e292182 100644 --- a/src/cpl_cli/_templates/generate/abc_template.py +++ b/src/cpl_cli/_templates/generate/abc_template.py @@ -11,7 +11,13 @@ class ABCTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ from abc import ABC, abstractmethod diff --git a/src/cpl_cli/_templates/generate/configmodel_template.py b/src/cpl_cli/_templates/generate/configmodel_template.py index 2ddf3354..f4b9ce41 100644 --- a/src/cpl_cli/_templates/generate/configmodel_template.py +++ b/src/cpl_cli/_templates/generate/configmodel_template.py @@ -11,7 +11,13 @@ class ConfigModelTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ import traceback diff --git a/src/cpl_cli/_templates/generate/enum_template.py b/src/cpl_cli/_templates/generate/enum_template.py index 9b0689cb..b8c04b49 100644 --- a/src/cpl_cli/_templates/generate/enum_template.py +++ b/src/cpl_cli/_templates/generate/enum_template.py @@ -11,7 +11,13 @@ class EnumTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ from enum import Enum diff --git a/src/cpl_cli/_templates/generate/init_template.py b/src/cpl_cli/_templates/generate/init_template.py index 316d9fa2..48c2e2da 100644 --- a/src/cpl_cli/_templates/generate/init_template.py +++ b/src/cpl_cli/_templates/generate/init_template.py @@ -12,6 +12,9 @@ class InitTemplate(TemplateFileABC): self._name = f'__init__.py' self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ # imports diff --git a/src/cpl_cli/_templates/generate/pipe_template.py b/src/cpl_cli/_templates/generate/pipe_template.py index bd8b4661..6a33035b 100644 --- a/src/cpl_cli/_templates/generate/pipe_template.py +++ b/src/cpl_cli/_templates/generate/pipe_template.py @@ -11,7 +11,13 @@ class PipeTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ from cpl_core.pipes.pipe_abc import PipeABC diff --git a/src/cpl_cli/_templates/generate/service_template.py b/src/cpl_cli/_templates/generate/service_template.py index 0e762685..24846155 100644 --- a/src/cpl_cli/_templates/generate/service_template.py +++ b/src/cpl_cli/_templates/generate/service_template.py @@ -11,7 +11,13 @@ class ServiceTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ class $Name: diff --git a/src/cpl_cli/_templates/generate/test_case_template.py b/src/cpl_cli/_templates/generate/test_case_template.py index 7fa9a4a7..5888bb5c 100644 --- a/src/cpl_cli/_templates/generate/test_case_template.py +++ b/src/cpl_cli/_templates/generate/test_case_template.py @@ -11,7 +11,13 @@ class TestCaseTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ import unittest diff --git a/src/cpl_cli/_templates/generate/thread_template.py b/src/cpl_cli/_templates/generate/thread_template.py index c8bd641e..4609d678 100644 --- a/src/cpl_cli/_templates/generate/thread_template.py +++ b/src/cpl_cli/_templates/generate/thread_template.py @@ -11,7 +11,13 @@ class ThreadTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ import threading diff --git a/src/cpl_cli/_templates/generate/validator_template.py b/src/cpl_cli/_templates/generate/validator_template.py index e5ed47a5..683cea5e 100644 --- a/src/cpl_cli/_templates/generate/validator_template.py +++ b/src/cpl_cli/_templates/generate/validator_template.py @@ -11,7 +11,13 @@ class ValidatorTemplate(TemplateFileABC): TemplateFileABC.__init__(self) self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + if schematic in name.lower(): + self._name = f'{String.convert_to_snake_case(name)}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + if schematic in name.lower(): + self._class_name = f'{String.first_to_upper(name)}' + self._path = path self._value = textwrap.dedent("""\ from cpl_core.configuration.validator_abc import ValidatorABC