Renamed by internal convention

This commit is contained in:
Sven Heidemann 2021-03-12 15:58:30 +01:00
parent 8a95c03038
commit ac63751583
40 changed files with 92 additions and 65 deletions

View File

@ -23,7 +23,7 @@ from collections import namedtuple
from .configuration import Configuration
from .configuration_abc import ConfigurationABC
from .configuration_model_abc import ConfigurationModelABC
from .configuration_variable_name import ConfigurationVariableName
from .configuration_variable_name_enum import ConfigurationVariableNameEnum
from .console_argument import ConsoleArgument
VersionInfo = namedtuple('VersionInfo', 'major minor micro')

View File

@ -6,13 +6,13 @@ from typing import Union, Type, Optional
from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.configuration.configuration_variable_name import ConfigurationVariableName
from cpl.configuration.configuration_variable_name_enum import ConfigurationVariableNameEnum
from cpl.configuration.console_argument import ConsoleArgument
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.environment.hosting_environment import HostingEnvironment
from cpl.environment.environment_abc import EnvironmentABC
from cpl.environment.environment_name import EnvironmentName
from cpl.environment.environment_name_enum import EnvironmentName
class Configuration(ConfigurationABC):
@ -69,13 +69,13 @@ class Configuration(ConfigurationABC):
Console.set_foreground_color(ForegroundColor.default)
def _set_variable(self, name: str, value: str):
if name == ConfigurationVariableName.environment.value:
if name == ConfigurationVariableNameEnum.environment.value:
self._hosting_environment.environment_name = EnvironmentName(value)
elif name == ConfigurationVariableName.name.value:
elif name == ConfigurationVariableNameEnum.name.value:
self._hosting_environment.application_name = value
elif name == ConfigurationVariableName.customer.value:
elif name == ConfigurationVariableNameEnum.customer.value:
self._hosting_environment.customer = value
else:
@ -155,7 +155,7 @@ class Configuration(ConfigurationABC):
return result
def add_environment_variables(self, prefix: str):
for variable in ConfigurationVariableName.to_list():
for variable in ConfigurationVariableNameEnum.to_list():
var_name = f'{prefix}{variable}'
if var_name in [key.upper() for key in os.environ.keys()]:
self._set_variable(variable, os.environ[var_name])
@ -164,7 +164,7 @@ class Configuration(ConfigurationABC):
self._argument_types.append(argument)
def add_console_arguments(self):
for arg_name in ConfigurationVariableName.to_list():
for arg_name in ConfigurationVariableNameEnum.to_list():
self.add_console_argument(ConsoleArgument('--', str(arg_name).upper(), [str(arg_name).lower()], '='))
arg_list = sys.argv[1:]
@ -243,13 +243,13 @@ class Configuration(ConfigurationABC):
def get_configuration(self, search_type: Union[str, Type[ConfigurationModelABC]]) -> Union[str, Callable[ConfigurationModelABC]]:
if type(search_type) is str:
if search_type == ConfigurationVariableName.environment.value:
if search_type == ConfigurationVariableNameEnum.environment.value:
return self._hosting_environment.environment_name
elif search_type == ConfigurationVariableName.name.value:
elif search_type == ConfigurationVariableNameEnum.name.value:
return self._hosting_environment.application_name
elif search_type == ConfigurationVariableName.customer.value:
elif search_type == ConfigurationVariableNameEnum.customer.value:
return self._hosting_environment.customer
if search_type not in self._config:

View File

@ -1,7 +1,7 @@
from enum import Enum
class ConfigurationVariableName(Enum):
class ConfigurationVariableNameEnum(Enum):
environment = 'ENVIRONMENT'
name = 'NAME'
@ -9,4 +9,4 @@ class ConfigurationVariableName(Enum):
@staticmethod
def to_list():
return [var.value for var in ConfigurationVariableName]
return [var.value for var in ConfigurationVariableNameEnum]

View File

@ -1,6 +1,7 @@
class ConsoleArgument:
def __init__(self, token: str, name: str, aliases: list[str], value_token: str, console_arguments: list['ConsoleArgument'] = None):
def __init__(self, token: str, name: str, aliases: list[str], value_token: str, console_arguments: list[
'ConsoleArgument'] = None):
self._token = token
self._name = name
self._aliases = aliases

View File

@ -20,10 +20,10 @@ __version__ = '2021.4.1'
from collections import namedtuple
# imports:
from .background_color import BackgroundColor
from .background_color_enum import BackgroundColorEnum
from .console import Console
from .console_call import ConsoleCall
from .foreground_color import ForegroundColor
from .foreground_color_enum import ForegroundColor
from .spinner_thread import SpinnerThread
VersionInfo = namedtuple('VersionInfo', 'major minor micro')

View File

@ -1,7 +1,7 @@
from enum import Enum
class BackgroundColor(Enum):
class BackgroundColorEnum(Enum):
default = 'on_default'
grey = 'on_grey'

View File

@ -6,16 +6,16 @@ import pyfiglet
from tabulate import tabulate
from termcolor import colored
from cpl.console.background_color import BackgroundColor
from cpl.console.background_color_enum import BackgroundColorEnum
from cpl.console.console_call import ConsoleCall
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.console.spinner_thread import SpinnerThread
class Console:
_is_first_write = True
_background_color: BackgroundColor = BackgroundColor.default
_background_color: BackgroundColorEnum = BackgroundColorEnum.default
_foreground_color: ForegroundColor = ForegroundColor.default
_x: Optional[int] = None
_y: Optional[int] = None
@ -47,9 +47,9 @@ class Console:
cls._hold_back = value
@classmethod
def set_background_color(cls, color: Union[BackgroundColor, str]):
def set_background_color(cls, color: Union[BackgroundColorEnum, str]):
if type(color) is str:
cls._background_color = BackgroundColor[color]
cls._background_color = BackgroundColorEnum[color]
else:
cls._background_color = color
@ -88,11 +88,11 @@ class Console:
args.append(f'\033[{cls._y};{cls._x}H')
colored_args.append(string)
if cls._foreground_color != ForegroundColor.default and cls._background_color == BackgroundColor.default:
if cls._foreground_color != ForegroundColor.default and cls._background_color == BackgroundColorEnum.default:
colored_args.append(cls._foreground_color.value)
elif cls._foreground_color == ForegroundColor.default and cls._background_color != BackgroundColor.default:
elif cls._foreground_color == ForegroundColor.default and cls._background_color != BackgroundColorEnum.default:
colored_args.append(cls._background_color.value)
elif cls._foreground_color != ForegroundColor.default and cls._background_color != BackgroundColor.default:
elif cls._foreground_color != ForegroundColor.default and cls._background_color != BackgroundColorEnum.default:
colored_args.append(cls._foreground_color.value)
colored_args.append(cls._background_color.value)
@ -182,7 +182,7 @@ class Console:
@classmethod
def reset(cls):
cls._background_color = BackgroundColor.default
cls._background_color = BackgroundColorEnum.default
cls._foreground_color = ForegroundColor.default
@classmethod
@ -252,7 +252,7 @@ class Console:
cls._output(string, x, y, end='')
@classmethod
def spinner(cls, message: str, call: Callable, *args, text_foreground_color: ForegroundColor = None, spinner_foreground_color: ForegroundColor = None, text_background_color: BackgroundColor = None, spinner_background_color: BackgroundColor = None) -> any:
def spinner(cls, message: str, call: Callable, *args, text_foreground_color: ForegroundColor = None, spinner_foreground_color: ForegroundColor = None, text_background_color: BackgroundColorEnum = None, spinner_background_color: BackgroundColorEnum = None) -> any:
if cls._hold_back:
cls._hold_back_calls.append(ConsoleCall(cls.spinner, message, call, *args))
return
@ -272,7 +272,7 @@ class Console:
cls.set_hold_back(False)
cls.set_foreground_color(ForegroundColor.default)
cls.set_background_color(BackgroundColor.default)
cls.set_background_color(BackgroundColorEnum.default)
for call in cls._hold_back_calls:
call.function(*call.args)

View File

@ -5,13 +5,13 @@ import time
from termcolor import colored
from cpl.console.background_color import BackgroundColor
from cpl.console.foreground_color import ForegroundColor
from cpl.console.background_color_enum import BackgroundColorEnum
from cpl.console.foreground_color_enum import ForegroundColor
class SpinnerThread(threading.Thread):
def __init__(self, msg_len: int, foreground_color: ForegroundColor, background_color: BackgroundColor):
def __init__(self, msg_len: int, foreground_color: ForegroundColor, background_color: BackgroundColorEnum):
threading.Thread.__init__(self)
self._msg_len = msg_len

View File

@ -22,7 +22,7 @@ from collections import namedtuple
# imports:
from .database_model import DatabaseModel
from .database_settings import DatabaseSettings
from .database_settings_name import DatabaseSettingsName
from .database_settings_name_enum import DatabaseSettingsName
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -4,7 +4,7 @@ from sqlalchemy import engine, create_engine
from sqlalchemy.orm import Session, sessionmaker
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.database.connection.database_connection_abc import DatabaseConnectionABC
from cpl.database.database_settings import DatabaseSettings

View File

@ -2,7 +2,7 @@ from sqlalchemy import engine, Table
from sqlalchemy.orm import Session
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.database.connection.database_connection import DatabaseConnection
from cpl.database.connection.database_connection_abc import DatabaseConnectionABC
from cpl.database.context.database_context_abc import DatabaseContextABC

View File

@ -3,8 +3,8 @@ from typing import Optional
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.database.database_settings_name import DatabaseSettingsName
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.database.database_settings_name_enum import DatabaseSettingsName
class DatabaseSettings(ConfigurationModelABC):

View File

@ -21,7 +21,7 @@ from collections import namedtuple
# imports:
from .environment_abc import EnvironmentABC
from .environment_name import EnvironmentName
from .environment_name_enum import EnvironmentName
from .hosting_environment import HostingEnvironment
VersionInfo = namedtuple('VersionInfo', 'major minor micro')

View File

@ -2,7 +2,7 @@ from socket import gethostname
from typing import Optional
from cpl.environment.environment_abc import EnvironmentABC
from cpl.environment.environment_name import EnvironmentName
from cpl.environment.environment_name_enum import EnvironmentName
class HostingEnvironment(EnvironmentABC):

View File

@ -20,11 +20,11 @@ __version__ = '2021.4.1'
from collections import namedtuple
# imports:
from .logger import Logger
from .logger_service import Logger
from .logger_abc import LoggerABC
from .logging_level import LoggingLevel
from .logging_level_enum import LoggingLevel
from .logging_settings import LoggingSettings
from .logging_settings_name import LoggingSettingsName
from .logging_settings_name_enum import LoggingSettingsName
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -5,9 +5,9 @@ from string import Template
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.logging.logger_abc import LoggerABC
from cpl.logging.logging_level import LoggingLevel
from cpl.logging.logging_level_enum import LoggingLevel
from cpl.logging.logging_settings import LoggingSettings
from cpl.time.time_format_settings import TimeFormatSettings

View File

@ -3,9 +3,9 @@ from typing import Optional
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.logging.logging_level import LoggingLevel
from cpl.logging.logging_settings_name import LoggingSettingsName
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.logging.logging_level_enum import LoggingLevel
from cpl.logging.logging_settings_name_enum import LoggingSettingsName
class LoggingSettings(ConfigurationModelABC):

View File

@ -21,10 +21,10 @@ from collections import namedtuple
# imports:
from .email import EMail
from .email_client import EMailClient
from .email_client_service import EMailClient
from .email_client_abc import EMailClientABC
from .email_client_settings import EMailClientSettings
from .email_client_settings_name import EMailClientSettingsName
from .email_client_settings_name_enum import EMailClientSettingsName
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -2,7 +2,7 @@ import traceback
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.console.console import Console
from cpl.mailing.email_client_settings_name import EMailClientSettingsName
from cpl.mailing.email_client_settings_name_enum import EMailClientSettingsName
class EMailClientSettings(ConfigurationModelABC):

View File

@ -21,7 +21,7 @@ from collections import namedtuple
# imports:
from .time_format_settings import TimeFormatSettings
from .time_format_settings_names import TimeFormatSettingsNames
from .time_format_settings_names_enum import TimeFormatSettingsNames
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -3,8 +3,8 @@ from typing import Optional
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.time.time_format_settings_names import TimeFormatSettingsNames
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.time.time_format_settings_names_enum import TimeFormatSettingsNames
class TimeFormatSettings(ConfigurationModelABC):

View File

@ -21,6 +21,7 @@ from collections import namedtuple
# imports:
from .credential_manager import CredentialManager
from .string import String
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -3,7 +3,7 @@ from collections import Callable
from cpl.application.application_abc import ApplicationRuntimeABC
from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.console.console import Console
from cpl.utils.string import String
from cpl_cli.command_abc import CommandABC
@ -26,7 +26,7 @@ class Generate(CommandABC):
"Template": ABCTemplate
},
"class": {
"Upper": "Class",
"Upper": "",
"Template": ClassTemplate
},
"enum": {

View File

@ -1,5 +1,5 @@
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl_cli.command_abc import CommandABC

View File

@ -6,7 +6,7 @@ from typing import Optional
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.console.console import Console
from cpl_cli.command_abc import CommandABC
from cpl_cli.configuration.build_settings import BuildSettings

View File

@ -7,7 +7,7 @@ import pkg_resources
import cpl
import cpl_cli
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl_cli.command_abc import CommandABC

View File

@ -3,7 +3,7 @@ from typing import Optional
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl_cli.configuration.build_settings_name import BuildSettingsName

View File

@ -3,7 +3,7 @@ from typing import Optional
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
from cpl.console.console import Console
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl_cli.configuration.version import Version
from cpl_cli.configuration.project_settings_name import ProjectSettingsName

View File

@ -7,7 +7,7 @@ import setuptools
from setuptools import sandbox
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
from cpl.console.foreground_color import ForegroundColor
from cpl.console.foreground_color_enum import ForegroundColor
from cpl.console.console import Console
from cpl_cli.configuration.build_settings import BuildSettings
from cpl_cli.configuration.project_settings import ProjectSettings

View 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.generate'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -10,8 +10,8 @@ class ClassTemplate(TemplateFileABC):
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
TemplateFileABC.__init__(self)
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
self._name = f'{String.convert_to_snake_case(name)}.py'
self._class_name = f'{String.first_to_upper(name)}'
self._path = path
self._value = textwrap.dedent("""\
class $Name:

View File

@ -7,9 +7,9 @@ from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.database.context.database_context import DatabaseContext
from cpl.database.database_settings import DatabaseSettings
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
from cpl.logging.logger import Logger
from cpl.logging.logger_service import Logger
from cpl.logging.logger_abc import LoggerABC
from cpl.mailing.email_client import EMailClient
from cpl.mailing.email_client_service import EMailClient
from cpl.mailing.email_client_abc import EMailClientABC
from cpl.utils.credential_manager import CredentialManager