2023.4 #168

Merged
edraft merged 56 commits from 2023.4 into master 2023-04-12 13:57:51 +02:00
4 changed files with 34 additions and 94 deletions
Showing only changes of commit 9a6ce704b7 - Show all commits

View File

@ -11,13 +11,13 @@ import cpl_cli
import cpl_core
from cpl_cli.abc.project_type_abc import ProjectTypeABC
from cpl_cli.command_abc import CommandABC
from cpl_cli.configuration import VersionSettings, VersionSettingsNameEnum
from cpl_cli.configuration.build_settings import BuildSettings
from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum
from cpl_cli.configuration.project_settings import ProjectSettings
from cpl_cli.configuration.project_settings_name_enum import ProjectSettingsNameEnum
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
from cpl_cli.configuration.venv_helper_service import VenvHelper
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
from cpl_cli.configuration.workspace_settings import WorkspaceSettings
from cpl_cli.helper.dependencies import Dependencies
from cpl_cli.source_creator.template_builder import TemplateBuilder
@ -101,6 +101,25 @@ class NewService(CommandABC):
}
self._project.from_dict(self._project_dict)
self._project = 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 = {
@ -115,7 +134,19 @@ class NewService(CommandABC):
BuildSettingsNameEnum.package_data.value: {},
BuildSettingsNameEnum.project_references.value: [],
}
self._build.from_dict(self._build_dict)
# self._build.from_dict(self._build_dict)
self._build = 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):
"""

View File

@ -93,44 +93,3 @@ class BuildSettings(ConfigurationModelABC):
@property
def project_references(self) -> list[str]:
return self._project_references
def from_dict(self, settings: dict):
try:
self._project_type = settings[BuildSettingsNameEnum.project_type.value]
self._source_path = settings[BuildSettingsNameEnum.source_path.value]
self._output_path = settings[BuildSettingsNameEnum.output_path.value]
self._include_package_data = bool(settings[BuildSettingsNameEnum.include_package_data.value])
self._main = settings[BuildSettingsNameEnum.main.value]
self._entry_point = settings[BuildSettingsNameEnum.entry_point.value]
self._included = settings[BuildSettingsNameEnum.included.value]
self._excluded = settings[BuildSettingsNameEnum.excluded.value]
self._package_data = settings[BuildSettingsNameEnum.package_data.value]
if BuildSettingsNameEnum.project_references.value in settings:
self._project_references = settings[BuildSettingsNameEnum.project_references.value]
else:
self._project_references = []
if sys.platform == "win32":
self._source_path = str(self._source_path).replace("/", "\\")
self._output_path = str(self._output_path).replace("/", "\\")
# windows paths for excluded files
excluded = []
for ex in self._excluded:
excluded.append(str(ex).replace("/", "\\"))
self._excluded = excluded
# windows paths for included files
included = []
for inc in self._included:
included.append(str(inc).replace("/", "\\"))
self._included = included
except Exception as e:
Console.set_foreground_color(ForegroundColorEnum.red)
Console.write_line(f"[ ERROR ] [ {__name__} ]: Reading error in {BuildSettings.__name__} settings")
Console.write_line(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")
Console.set_foreground_color(ForegroundColorEnum.default)

View File

@ -1,14 +1,11 @@
import os
import sys
import traceback
from typing import Optional
from cpl_cli.configuration.project_settings_name_enum import ProjectSettingsNameEnum
from cpl_cli.configuration.version_settings import VersionSettings
from cpl_cli.error import Error
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console.console import Console
from cpl_core.console.foreground_color_enum import ForegroundColorEnum
class ProjectSettings(ConfigurationModelABC):
@ -133,51 +130,3 @@ class ProjectSettings(ConfigurationModelABC):
@property
def classifiers(self) -> list[str]:
return self._classifiers
def from_dict(self, settings: dict):
try:
self._name = settings[ProjectSettingsNameEnum.name.value]
self._version.from_dict(settings[ProjectSettingsNameEnum.version.value])
self._author = settings[ProjectSettingsNameEnum.author.value]
self._author_email = settings[ProjectSettingsNameEnum.author_email.value]
self._description = settings[ProjectSettingsNameEnum.description.value]
self._long_description = settings[ProjectSettingsNameEnum.long_description.value]
self._url = settings[ProjectSettingsNameEnum.url.value]
self._copyright_date = settings[ProjectSettingsNameEnum.copyright_date.value]
self._copyright_name = settings[ProjectSettingsNameEnum.copyright_name.value]
self._license_name = settings[ProjectSettingsNameEnum.license_name.value]
self._license_description = settings[ProjectSettingsNameEnum.license_description.value]
self._dependencies = settings[ProjectSettingsNameEnum.dependencies.value]
if ProjectSettingsNameEnum.dev_dependencies.value not in settings:
settings[ProjectSettingsNameEnum.dev_dependencies.value] = []
self._dev_dependencies = settings[ProjectSettingsNameEnum.dev_dependencies.value]
self._python_version = settings[ProjectSettingsNameEnum.python_version.value]
self._python_path = settings[ProjectSettingsNameEnum.python_path.value]
if (
ProjectSettingsNameEnum.python_path.value in settings
and sys.platform in settings[ProjectSettingsNameEnum.python_path.value]
):
path = f"{settings[ProjectSettingsNameEnum.python_path.value][sys.platform]}"
if path == "" or path is None:
Error.warn(f"{ProjectSettingsNameEnum.python_path.value} not set")
path = sys.executable
else:
if not path.endswith("bin/python"):
path = os.path.join(path, "bin/python")
else:
path = sys.executable
self._python_executable = path
if ProjectSettingsNameEnum.classifiers.value:
self._classifiers = settings[ProjectSettingsNameEnum.classifiers.value]
else:
self._classifiers = []
except Exception as e:
Console.set_foreground_color(ForegroundColorEnum.red)
Console.write_line(f"[ ERROR ] [ {__name__} ]: Reading error in {ProjectSettings.__name__} settings")
Console.write_line(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")
Console.set_foreground_color(ForegroundColorEnum.default)

View File

@ -5,3 +5,4 @@ class ProjectTypeEnum(Enum):
console = "console"
library = "library"
unittest = "unittest"
discord_bot = "discord-bot"