From 9b4afdbe18d4e72ebd5d677544e3e8520225dd8c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 5 Apr 2023 18:12:31 +0200 Subject: [PATCH] Updated TranslationSettings & formatted code --- src/cpl_cli/command/new_service.py | 66 ++++++++++--------- .../configuration/discord_bot_settings.py | 6 +- src/cpl_translation/translation_settings.py | 21 ++---- unittests/unittests_cli/add_test_case.py | 1 - 4 files changed, 45 insertions(+), 49 deletions(-) diff --git a/src/cpl_cli/command/new_service.py b/src/cpl_cli/command/new_service.py index 226eb370..d27acba5 100644 --- a/src/cpl_cli/command/new_service.py +++ b/src/cpl_cli/command/new_service.py @@ -80,39 +80,43 @@ class NewService(CommandABC): python_path={sys.platform: "../../venv/" if self._use_venv else ""} ).python_executable self._rel_path = os.path.dirname(self._name) - self._project_dict = SettingsHelper.get_project_settings_dict(ProjectSettings( - os.path.basename(self._name), - VersionSettings("0", "0", "0"), - "", - "", - "", - "", - "", - "", - "", - "", - "", - [f"cpl-core>={version.parse(cpl_core.__version__)}"], - [f"cpl-cli>={version.parse(cpl_cli.__version__)}"], - f'>={sys.version.split(" ")[0]}', - {sys.platform: "../../venv/" if self._use_venv else ""}, - None, - [], - )) + self._project_dict = SettingsHelper.get_project_settings_dict( + ProjectSettings( + os.path.basename(self._name), + VersionSettings("0", "0", "0"), + "", + "", + "", + "", + "", + "", + "", + "", + "", + [f"cpl-core>={version.parse(cpl_core.__version__)}"], + [f"cpl-cli>={version.parse(cpl_cli.__version__)}"], + f'>={sys.version.split(" ")[0]}', + {sys.platform: "../../venv/" if self._use_venv else ""}, + None, + [], + ) + ) def _create_build_settings(self, project_type: str): - self._build_dict = SettingsHelper.get_build_settings_dict(BuildSettings( - ProjectTypeEnum[project_type], - "", - "../../dist", - f"{String.convert_to_snake_case(self._project_name)}.main", - self._project_name, - False, - [], - ["*/__pycache__", "*/logs", "*/tests"], - {}, - [], - )) + self._build_dict = SettingsHelper.get_build_settings_dict( + BuildSettings( + ProjectTypeEnum[project_type], + "", + "../../dist", + f"{String.convert_to_snake_case(self._project_name)}.main", + self._project_name, + False, + [], + ["*/__pycache__", "*/logs", "*/tests"], + {}, + [], + ) + ) def _create_project_json(self): """ diff --git a/src/cpl_discord/configuration/discord_bot_settings.py b/src/cpl_discord/configuration/discord_bot_settings.py index c5b954ca..08097351 100644 --- a/src/cpl_discord/configuration/discord_bot_settings.py +++ b/src/cpl_discord/configuration/discord_bot_settings.py @@ -3,9 +3,9 @@ from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC class DiscordBotSettings(ConfigurationModelABC): def __init__( - self, - token: str = None, - prefix: str = None, + self, + token: str = None, + prefix: str = None, ): ConfigurationModelABC.__init__(self) diff --git a/src/cpl_translation/translation_settings.py b/src/cpl_translation/translation_settings.py index e7b17bd9..fb6275a3 100644 --- a/src/cpl_translation/translation_settings.py +++ b/src/cpl_translation/translation_settings.py @@ -1,15 +1,16 @@ -import traceback - from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC -from cpl_core.console import Console class TranslationSettings(ConfigurationModelABC): - def __init__(self): + def __init__( + self, + languages: str = None, + default_lang: str = None, + ): ConfigurationModelABC.__init__(self) - self._languages = [] - self._default_lang = "" + self._languages = [] if languages is None else languages + self._default_lang = default_lang @property def languages(self) -> list[str]: @@ -18,11 +19,3 @@ class TranslationSettings(ConfigurationModelABC): @property def default_language(self) -> str: return self._default_lang - - def from_dict(self, settings: dict): - try: - self._languages = settings["Languages"] - self._default_lang = settings["DefaultLanguage"] - except Exception as e: - Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") - Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") diff --git a/unittests/unittests_cli/add_test_case.py b/unittests/unittests_cli/add_test_case.py index fcf3406b..bfc2243d 100644 --- a/unittests/unittests_cli/add_test_case.py +++ b/unittests/unittests_cli/add_test_case.py @@ -8,7 +8,6 @@ from unittests_shared.cli_commands import CLICommands class AddTestCase(CommandTestCase): - def __init__(self, method_name: str): CommandTestCase.__init__(self, method_name) self._source = "add-test-project"