Updated TranslationSettings & formatted code

This commit is contained in:
Sven Heidemann 2023-04-05 18:12:31 +02:00
parent 6751541269
commit 9b4afdbe18
4 changed files with 45 additions and 49 deletions

View File

@ -80,7 +80,8 @@ class NewService(CommandABC):
python_path={sys.platform: "../../venv/" if self._use_venv else ""} python_path={sys.platform: "../../venv/" if self._use_venv else ""}
).python_executable ).python_executable
self._rel_path = os.path.dirname(self._name) self._rel_path = os.path.dirname(self._name)
self._project_dict = SettingsHelper.get_project_settings_dict(ProjectSettings( self._project_dict = SettingsHelper.get_project_settings_dict(
ProjectSettings(
os.path.basename(self._name), os.path.basename(self._name),
VersionSettings("0", "0", "0"), VersionSettings("0", "0", "0"),
"", "",
@ -98,10 +99,12 @@ class NewService(CommandABC):
{sys.platform: "../../venv/" if self._use_venv else ""}, {sys.platform: "../../venv/" if self._use_venv else ""},
None, None,
[], [],
)) )
)
def _create_build_settings(self, project_type: str): def _create_build_settings(self, project_type: str):
self._build_dict = SettingsHelper.get_build_settings_dict(BuildSettings( self._build_dict = SettingsHelper.get_build_settings_dict(
BuildSettings(
ProjectTypeEnum[project_type], ProjectTypeEnum[project_type],
"", "",
"../../dist", "../../dist",
@ -112,7 +115,8 @@ class NewService(CommandABC):
["*/__pycache__", "*/logs", "*/tests"], ["*/__pycache__", "*/logs", "*/tests"],
{}, {},
[], [],
)) )
)
def _create_project_json(self): def _create_project_json(self):
""" """

View File

@ -1,15 +1,16 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class TranslationSettings(ConfigurationModelABC): class TranslationSettings(ConfigurationModelABC):
def __init__(self): def __init__(
self,
languages: str = None,
default_lang: str = None,
):
ConfigurationModelABC.__init__(self) ConfigurationModelABC.__init__(self)
self._languages = [] self._languages = [] if languages is None else languages
self._default_lang = "" self._default_lang = default_lang
@property @property
def languages(self) -> list[str]: def languages(self) -> list[str]:
@ -18,11 +19,3 @@ class TranslationSettings(ConfigurationModelABC):
@property @property
def default_language(self) -> str: def default_language(self) -> str:
return self._default_lang 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()}")

View File

@ -8,7 +8,6 @@ from unittests_shared.cli_commands import CLICommands
class AddTestCase(CommandTestCase): class AddTestCase(CommandTestCase):
def __init__(self, method_name: str): def __init__(self, method_name: str):
CommandTestCase.__init__(self, method_name) CommandTestCase.__init__(self, method_name)
self._source = "add-test-project" self._source = "add-test-project"